<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>How to Config &#187; debian</title>
	<atom:link href="http://www.howtoconfig.com/tag/debian/feed" rel="self" type="application/rss+xml" />
	<link>http://www.howtoconfig.com</link>
	<description>how to config - how to configure</description>
	<lastBuildDate>Fri, 29 Apr 2011 09:52:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>How to use IPMI on Debian</title>
		<link>http://www.howtoconfig.com/system/how-to-use-ipmi-on-debian.html</link>
		<comments>http://www.howtoconfig.com/system/how-to-use-ipmi-on-debian.html#comments</comments>
		<pubDate>Mon, 01 Nov 2010 18:00:17 +0000</pubDate>
		<dc:creator>อัทศักดิ์ วงศ์กิตตะ</dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[IPhone]]></category>
		<category><![CDATA[IPMI]]></category>

		<guid isPermaLink="false">http://www.siambox.com/blog/?p=52</guid>
		<description><![CDATA[โหลด IPMI Kernel Modules modprobe ipmi_watchdog modprobe ipmi_poweroff modprobe ipmi_msghandler modprobe ipmi_devintf modprobe ipmi_si ติดตั้ง ipmitool apt-get install ipmitool ทำการ config ipmi ipmitool lan set 1 ipaddr 192.168.1.101 ipmitool lan set 1 netmask 255.255.255.0 ipmitool lan set 1 defgw ipaddr 192.168.1.254 ipmitool lan set 1 password mypassword ipmitool lan set 1 access on ipmitool lan [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.yellowkompressor.com/ipmi-touch/screenshots/"><img class="alignnone" title="IPMI Touch" src="http://www.yellowkompressor.com/ipmi-touch/wp-content/uploads/ipmi-touch-on-iPhone-e1270867381478.png" alt="" width="250" height="375" /></a></p>
<p>โหลด IPMI Kernel Modules</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">modprobe ipmi_watchdog
modprobe ipmi_poweroff
modprobe ipmi_msghandler
modprobe ipmi_devintf
modprobe ipmi_si</pre></div></div>

<p>ติดตั้ง ipmitool</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> ipmitool</pre></div></div>

<p>ทำการ config ipmi</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ipmitool lan <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #000000;">1</span> ipaddr 192.168.1.101
ipmitool lan <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #000000;">1</span> netmask 255.255.255.0
ipmitool lan <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #000000;">1</span> defgw ipaddr 192.168.1.254
ipmitool lan <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #000000;">1</span> password mypassword
ipmitool lan <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #000000;">1</span> access on
ipmitool lan <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #000000;">1</span> arp respond on
ipmitool mc reset cold</pre></div></div>

<p>วิธีการใช้งาน</p>
<p>ดู สถาณะ Power</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ipmitool <span style="color: #660033;">-H</span> 192.168.1.101 <span style="color: #660033;">-U</span> root <span style="color: #660033;">-P</span> mypassword power status</pre></div></div>

<p>Reset  เครื่อง</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ipmitool <span style="color: #660033;">-H</span> 192.168.1.101 <span style="color: #660033;">-U</span> root <span style="color: #660033;">-P</span> mypassword power reset</pre></div></div>

<p>หากท่านใช้ iPhone  ผมแนะนำ <a href="http://www.yellowkompressor.com" target="_blank">IPNI Touch</a> ครับ  สามารถสั่ง Power On/Off/Reset  ได้เลย ทำให้ Admin อย่างเราๆมีชีวิตที่แสนสบายขึ้นเยอะเลยครับ</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fsystem%2Fhow-to-use-ipmi-on-debian.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/system/how-to-use-ipmi-on-debian.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenVPN on UDP 53 &#8211; ไปที่ไหนก็เล่น Net ได้!!!</title>
		<link>http://www.howtoconfig.com/os/debian/openvpn-on-udp-53-%e0%b9%84%e0%b8%9b%e0%b8%97%e0%b8%b5%e0%b9%88%e0%b9%84%e0%b8%ab%e0%b8%99%e0%b8%81%e0%b9%87%e0%b9%80%e0%b8%a5%e0%b9%88%e0%b8%99-net-%e0%b9%84%e0%b8%94%e0%b9%89.html</link>
		<comments>http://www.howtoconfig.com/os/debian/openvpn-on-udp-53-%e0%b9%84%e0%b8%9b%e0%b8%97%e0%b8%b5%e0%b9%88%e0%b9%84%e0%b8%ab%e0%b8%99%e0%b8%81%e0%b9%87%e0%b9%80%e0%b8%a5%e0%b9%88%e0%b8%99-net-%e0%b9%84%e0%b8%94%e0%b9%89.html#comments</comments>
		<pubDate>Mon, 25 Oct 2010 08:07:42 +0000</pubDate>
		<dc:creator>อัทศักดิ์ วงศ์กิตตะ</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[OpenVPN]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://www.siambox.com/blog/?p=43</guid>
		<description><![CDATA[สมัยนี้ไปไหนก็มีก็มี Wifi ให้เราใช้งาน ไม่ว่าจะเป็นแบบฟรี หรือ เสียเงิน    วันนี้ผมเอาจุดอ่อน ที่ผู้ให้บริการ Hotspot  มองข้ามคือ การเปิด Any DNS  หรือ การเปิดให้ Client สามารถ Query DNS ข้างน้อกได้ โดยไม่ได้ทำการ Auth      ซึ่ง Wifi หลายๆที่เปิดไว้เพื่อความสะดวก   แต่ตรงนี้แหละเป็นจุดอ่อน  ที่จะทำให้เราสามารถใช้งาน Internet ได้โดยไม่โดนจำกัด Bandwidth สิ่งที่ต้องเตรียม ต้องมี Server ที่เป็น Fix IP ไว้ข้างนอก ติดตั้ง OpenVPN ติดตั้ง Server apt-get install openvpn openvpn --genkey --secret /etc/openvpn/mysecret.key &#160; vi /etc/openvpn/server-udp-53.conf # File /etc/openvpn/server-udp-53.conf dev [...]]]></description>
			<content:encoded><![CDATA[<p>สมัยนี้ไปไหนก็มีก็มี Wifi ให้เราใช้งาน ไม่ว่าจะเป็นแบบฟรี หรือ เสียเงิน    วันนี้ผมเอาจุดอ่อน ที่ผู้ให้บริการ Hotspot  มองข้ามคือ การเปิด Any DNS  หรือ การเปิดให้ Client สามารถ Query DNS ข้างน้อกได้ โดยไม่ได้ทำการ Auth      ซึ่ง Wifi หลายๆที่เปิดไว้เพื่อความสะดวก   แต่ตรงนี้แหละเป็นจุดอ่อน  ที่จะทำให้เราสามารถใช้งาน Internet ได้โดยไม่โดนจำกัด Bandwidth</p>
<p>สิ่งที่ต้องเตรียม</p>
<ol>
<li>ต้องมี Server ที่เป็น Fix IP ไว้ข้างนอก</li>
<li>ติดตั้ง OpenVPN</li>
</ol>
<p>ติดตั้ง Server</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> openvpn
openvpn <span style="color: #660033;">--genkey</span> <span style="color: #660033;">--secret</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>mysecret.key
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>server-udp-<span style="color: #000000;">53</span>.conf</pre></div></div>

<pre># File /etc/openvpn/server-udp-53.conf
dev tap
mode p2p
proto udp
#ping 1
port 53
ifconfig 10.10.10.1 255.255.255.252
secret /etc/openvpn/mysecret.key
tun-mtu 1500
tun-mtu-extra 32
mssfix 1400

push "route 192.168.10.0 255.255.255.0"</pre>
<p>ติดตั้ง Client</p>
<p>Download Client จาก   http://openvpn.net/index.php/openvpn-client.html  และทำการติดตั้ง</p>
<p>Copy file  mysecret.key   มาไว้ในเครื่อง  และสร้างไฟล์ config   โดยใช้ชื่อ     client.ovpn</p>
<pre>#file client.ovpn
dev tap
mode p2p
proto udp
remote &lt;IP Server&gt;
#ping 1
port 53
ifconfig 10.10.30.2 255.255.255.252
secret mysecret.key

tun-mtu 1500
tun-mtu-extra 32
mssfix 1400
ping 5</pre>
<p>แค่นี้ก็สามารถ  Connect VPN ผ่าน  UDP/53 ได้แล้วครับ</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fos%2Fdebian%2Fopenvpn-on-udp-53-%25e0%25b9%2584%25e0%25b8%259b%25e0%25b8%2597%25e0%25b8%25b5%25e0%25b9%2588%25e0%25b9%2584%25e0%25b8%25ab%25e0%25b8%2599%25e0%25b8%2581%25e0%25b9%2587%25e0%25b9%2580%25e0%25b8%25a5%25e0%25b9%2588%25e0%25b8%2599-net-%25e0%25b9%2584%25e0%25b8%2594%25e0%25b9%2589.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/os/debian/openvpn-on-udp-53-%e0%b9%84%e0%b8%9b%e0%b8%97%e0%b8%b5%e0%b9%88%e0%b9%84%e0%b8%ab%e0%b8%99%e0%b8%81%e0%b9%87%e0%b9%80%e0%b8%a5%e0%b9%88%e0%b8%99-net-%e0%b9%84%e0%b8%94%e0%b9%89.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Citrix &#8211; Missing gpg key</title>
		<link>http://www.howtoconfig.com/os/debian/citrix-missing-gpg-key.html</link>
		<comments>http://www.howtoconfig.com/os/debian/citrix-missing-gpg-key.html#comments</comments>
		<pubDate>Wed, 20 Oct 2010 18:39:43 +0000</pubDate>
		<dc:creator>อัทศักดิ์ วงศ์กิตตะ</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[apt-get]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.siambox.com/blog/?p=30</guid>
		<description><![CDATA[วันนี้ติดตั้ง Xen Server  และลง Debian ในเครื่อง  Xen จะทำการ Add  source ของ citrix ให้เองอัตโนมัตติ   แต่เมื่อเราทำการ update  package   จะฟ้อง Error  ว่าไม่พบ GPG key ของ Citrix     เราสามารถติดตั้งได้  ดั่งนี้ server:~# wget -q http://updates.vmd.citrix.com/XenServer/5.5.0/GPG-KEY -O- &#124; apt-key add - แค่นี้เวลาเราสั่ง apt-get ก็จะไม่ฟ้อง error gpg key อีกแล้วครับ]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="margin: 10px;" title="Xen Server" src="http://www.citrix.com/site/resources/dynamic/additional/demos/bin/mm/inpg/landing_xenserver.jpg" alt="" width="576" height="198" />วันนี้ติดตั้ง Xen Server  และลง Debian ในเครื่อง  Xen จะทำการ Add  source ของ citrix ให้เองอัตโนมัตติ   แต่เมื่อเราทำการ update  package   จะฟ้อง Error  ว่าไม่พบ GPG key ของ Citrix     เราสามารถติดตั้งได้  ดั่งนี้</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">server:~<span style="color: #666666; font-style: italic;"># wget -q http://updates.vmd.citrix.com/XenServer/5.5.0/GPG-KEY -O- | apt-key add -</span></pre></div></div>

<p>แค่นี้เวลาเราสั่ง apt-get  ก็จะไม่ฟ้อง error gpg key อีกแล้วครับ</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fos%2Fdebian%2Fcitrix-missing-gpg-key.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/os/debian/citrix-missing-gpg-key.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HA Proxy High Performance TCP/HTTP Load Balancer</title>
		<link>http://www.howtoconfig.com/system/load-balancing/ha-proxy-high-performance-tcphttp-load-balancer.html</link>
		<comments>http://www.howtoconfig.com/system/load-balancing/ha-proxy-high-performance-tcphttp-load-balancer.html#comments</comments>
		<pubDate>Wed, 20 Oct 2010 17:14:39 +0000</pubDate>
		<dc:creator>อัทศักดิ์ วงศ์กิตตะ</dc:creator>
				<category><![CDATA[Load balancing]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[haproxy]]></category>
		<category><![CDATA[load balance]]></category>

		<guid isPermaLink="false">http://www.siambox.com/blog/?p=5</guid>
		<description><![CDATA[วันนี้ประเดิม Blog แรกด้วย HAProxy   ซึ่งเป็น Software load balance  ที่สามารถทำงานได้ถึง Layer7    หลักๆผมเอามาทำเป็น HTTP Load Balance    เป้าหมายหลักๆที่ต้องการคือ แยกโหลดไปยังเครื่อง Web Node แต่ละเครื่องได้ กำหนด weight  ของแต่ละ Server ได้ สามารถทำ health check script ได้เอง สามารถ ทำงานได้ในระดับ Layer 7 ได้ หลังจากผมใช้งาน Linux-Ha (ipvsadm) มานาน  ผมพบปัญหาว่า บางครั้งหากเครื่อง Web Node มีปัญหาเครื่อง Load balance จะไม่ปลดโหลดออก ทำให้ผู้ใช้งานไม่สามารถใช้งานได้       ผมเลยลองค้นหาเรื่อง L7 Load Balance   จึงมาพบ  HA Proxy    [...]]]></description>
			<content:encoded><![CDATA[<p>วันนี้ประเดิม Blog แรกด้วย HAProxy   ซึ่งเป็น Software load balance  ที่สามารถทำงานได้ถึง Layer7    หลักๆผมเอามาทำเป็น HTTP Load Balance    เป้าหมายหลักๆที่ต้องการคือ</p>
<ul>
<li>แยกโหลดไปยังเครื่อง Web Node แต่ละเครื่องได้</li>
<li>กำหนด weight  ของแต่ละ Server ได้</li>
<li>สามารถทำ health check script ได้เอง</li>
<li>สามารถ ทำงานได้ในระดับ Layer 7 ได้</li>
</ul>
<p>หลังจากผมใช้งาน Linux-Ha (ipvsadm) มานาน  ผมพบปัญหาว่า บางครั้งหากเครื่อง Web Node มีปัญหาเครื่อง Load balance  จะไม่ปลดโหลดออก ทำให้ผู้ใช้งานไม่สามารถใช้งานได้       ผมเลยลองค้นหาเรื่อง L7 Load Balance   จึงมาพบ  HA Proxy    เลยลอง apt-get install haproxy   ดูพบว่าใน Debian ก็มี package มาให้ เลยลองติดตั้งพบว่า สามารถตอบสนอง ความต้องการของผมได้เป็นอย่างดี  ยังไงลองมาดูกันครับ ว่าติดตั้งและใช้งานเป็นยังไง</p>
<p style="text-align: center;"><a href="http://www.siambox.com/blog/wp-content/uploads/2010/10/HAProxy-1.jpg"><img class="size-medium wp-image-49 aligncenter" style="margin-top: 10px; margin-bottom: 10px;" title="HAProxy 1" src="http://www.siambox.com/blog/wp-content/uploads/2010/10/HAProxy-1-212x300.jpg" alt="" width="212" height="300" /></a></p>
<p><strong>ติดตั้ง</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> haproxy</pre></div></div>

<pre style="padding-left: 30px;"># File /etc/haproxy/haproxy.cfg
global
 daemon
 user            haproxy
 group   haproxy
 maxconn 8192
 log             127.0.0.1       local0
 log             127.0.0.1       local1 notice
 stats           socket  /var/run/haproxy.sock mode 666

defaults
 log             global
 mode    http
 option  httplog
 option  dontlognull
 option  httpclose
 #option forwardfor

 stats           enable
 retries 3
 option  redispatch
 maxconn 65535
 contimeout      5000
 clitimeout      50000
 srvtimeout      50000

listen  igetweb.com 0.0.0.0:80
 balance roundrobin

 acl     url_static              path_beg                /images /image /css
 acl     url_static              path_end                .jpg .jpeg .JPG .gif .png .ico .css .zip .tgz .gz .rar .bz2 .doc .xls .exe .pdf .ppt .txt .tar .mid .midi .wav .bmp .rtf .js .swf .wma .wmv

 use_backend             pool_static                     if url_static
 default_backend         pool_dynamic

backend pool_dynamic
 balance roundrobin
 option  httpchk HEAD /check.txt HTTP/1.0
 server web1 192.168.1.11:80  check inter 2000 fall 3 weight 1
 server web2 192.168.1.12:80  check inter 2000 fall 3 weight 1

backend pool_static
 balance roundrobin
 option  httpchk HEAD /check.txt HTTP/1.0
 server web1 192.168.1.21:80  check inter 2000 fall 3 weight 1
 server web2 192.168.1.22:80  check inter 2000 fall 3 weight 1
</pre>
<p>ส่วนสำคัญคือ ACL   โดยเราได้ทำการประกาศ ACL ที่ชื่อ  url_static  โดยหากผู้ใช้งานเรียก  url ที่ขึ้นต้นด้วย /image /images /css หรือ ไฟล์ที่ลงท้ายด้วย  jpg, jpge   และทำการประกาศว่า  หาก macth acl  url_static  ให้ไปเรียกใช้  pool_static     แค่นี้เราก็มี L7 Load Balance  ไว้ใช้งาน โดยไม่ต้องเสียงินหลักแสน ซื้อ Hardware Load balance แล้วครับ</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fsystem%2Fload-balancing%2Fha-proxy-high-performance-tcphttp-load-balancer.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/system/load-balancing/ha-proxy-high-performance-tcphttp-load-balancer.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IPTables statefull firewall for Linux</title>
		<link>http://www.howtoconfig.com/os/ubuntu/iptables_statefull_firewall_linux_debian_centos.html</link>
		<comments>http://www.howtoconfig.com/os/ubuntu/iptables_statefull_firewall_linux_debian_centos.html#comments</comments>
		<pubDate>Tue, 23 Mar 2010 11:04:18 +0000</pubDate>
		<dc:creator>อัทศักดิ์ วงศ์กิตตะ</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[Shell script]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[INPUT]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.howtoconfig.com/?p=87</guid>
		<description><![CDATA[หายไปนานครับ วันี้เอาเรื่องเก่าๆมาหากินใหม่ IPTables ที่ทำๆอยู่ทุกวันนี้แหละครับ พอดีทำ Shell Script ทิ้งไว้เลยเอามาแจกจ่ายให้เพื่อนๆเอาไปใช้งาน หลายๆคนถามว่าทำไมต้องเขียนเอง ก็เหตุผลง่ายๆครับ เราเขียนเองเรารู้ทุกๆ rules ที่มันทำงานอย่างไร เวลาเกิดปัญหา เราสามารถแก้ไขปัญหาได้ รวดเร็ว มาดูความสามารถของ script firewall ตัวนี้ครับ ความสามารถ: &#8211; State full firewall &#8211; สามารถกำหนด Interface ที่ทำงานได้ &#8211; สามารถกำหนด VIP IP ได้ &#8211; สามารถกำหนด Band IP ได้ &#8211; มีการเก็บ Log ลง syslog &#8211; ป้องกันการ Scan port ได้ &#8211; ป้องกัน IP Spoofig &#8211; ป้องกัน [...]]]></description>
			<content:encoded><![CDATA[<p>     หายไปนานครับ วันี้เอาเรื่องเก่าๆมาหากินใหม่ IPTables ที่ทำๆอยู่ทุกวันนี้แหละครับ พอดีทำ Shell Script ทิ้งไว้เลยเอามาแจกจ่ายให้เพื่อนๆเอาไปใช้งาน   หลายๆคนถามว่าทำไมต้องเขียนเอง   ก็เหตุผลง่ายๆครับ   เราเขียนเองเรารู้ทุกๆ rules ที่มันทำงานอย่างไร เวลาเกิดปัญหา เราสามารถแก้ไขปัญหาได้ รวดเร็ว  มาดูความสามารถของ script firewall ตัวนี้ครับ</p>
<p>ความสามารถ:<br />
  &#8211; State full  firewall<br />
  &#8211; สามารถกำหนด Interface ที่ทำงานได้<br />
  &#8211; สามารถกำหนด VIP IP ได้<br />
  &#8211; สามารถกำหนด Band IP ได้<br />
  &#8211; มีการเก็บ Log ลง syslog<br />
  &#8211; ป้องกันการ Scan port ได้<br />
  &#8211; ป้องกัน IP Spoofig<br />
  &#8211; ป้องกัน SSH Attatch<br />
<span id="more-87"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># rc.firewall - Initial IP Firewall</span>
<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
<span style="color: #007800;">INET_IFACE</span>=<span style="color: #ff0000;">&quot;eth0&quot;</span>
<span style="color: #007800;">IPTABLES</span>=<span style="color: #ff0000;">&quot;/sbin/iptables&quot;</span>
&nbsp;
<span style="color: #007800;">IP_ALLOW</span>=<span style="color: #ff0000;">&quot;61.19.249.66&quot;</span>
<span style="color: #007800;">IP_BAND</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #007800;">ICMP_ALLOW</span>=<span style="color: #ff0000;">&quot;0 3 5 11&quot;</span>
<span style="color: #007800;">TCP_ALLOW</span>=<span style="color: #ff0000;">&quot;22 25 53 80 8000 90 3128 20001&quot;</span> 
<span style="color: #007800;">UDP_ALLOW</span>=<span style="color: #ff0000;">&quot;53&quot;</span>
&nbsp;
<span style="color: #007800;">FTP_PORT</span>=<span style="color: #ff0000;">&quot;1024:65335&quot;</span>
<span style="color: #007800;">FTP_ENABLE</span>=<span style="color: #000000;">1</span>
&nbsp;
&nbsp;
<span style="color: #007800;">SSH_ATTACH</span>=<span style="color: #000000;">1</span>
<span style="color: #007800;">SSH_HITCOUNT</span>=<span style="color: #000000;">5</span>
<span style="color: #007800;">SSH_PORT</span>=<span style="color: #000000;">22</span>
&nbsp;
<span style="color: #007800;">PORTSCAN_CHECK</span>=<span style="color: #000000;">1</span>
<span style="color: #007800;">SPOOFINGIP_CHECK</span>=<span style="color: #000000;">1</span>
&nbsp;
<span style="color: #007800;">LOGLEVEL</span>=<span style="color: #ff0000;">&quot;DEBUG&quot;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Load IPTables Modules</span>
<span style="color: #666666; font-style: italic;">#</span>
modprobe ip_conntrack
modprobe ip_conntrack_ftp
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Reset IPTables</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-F</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-F</span> <span style="color: #660033;">-t</span> nat
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-X</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-X</span> <span style="color: #660033;">-t</span> nat
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Create separate chains for ICMP, TCP and UDP to traverse</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> vip_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> band_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> icmp_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> tcp_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> udp_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> log_attach
&nbsp;
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> DROP_TRAFFIC
&nbsp;
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Drop packet</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> DROP_TRAFFIC <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-j</span> REJECT <span style="color: #660033;">--reject-with</span> tcp-reset 
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> DROP_TRAFFIC <span style="color: #660033;">-p</span> UDP <span style="color: #660033;">-j</span> REJECT <span style="color: #660033;">--reject-with</span> icmp-port-unreachable
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Log Attack</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> log_attach <span style="color: #660033;">-j</span> LOG <span style="color: #660033;">--log-level</span> <span style="color: #007800;">$LOGLEVEL</span> <span style="color: #660033;">--log-prefix</span> <span style="color: #ff0000;">&quot;Attack:&quot;</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> log_attach <span style="color: #660033;">-j</span> DROP_TRAFFIC
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># VIP IPaddress</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">for</span> ip <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$IP_ALLOW</span>
<span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> vip_packets <span style="color: #660033;">-s</span> <span style="color: #007800;">$ip</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Band IPaddress</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">for</span> ip <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$IP_BAND</span>
<span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> band_packets <span style="color: #660033;">-s</span> <span style="color: #007800;">$ip</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># ICMP rules</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">for</span> icmp <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$ICMP_ALLOW</span>
<span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> icmp_packets <span style="color: #660033;">-p</span> ICMP <span style="color: #660033;">-s</span> <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span> <span style="color: #660033;">--icmp-type</span> <span style="color: #007800;">$icmp</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># TCP rules</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">for</span> port <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$TCP_ALLOW</span>
<span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> tcp_packets <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-s</span> <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span> <span style="color: #660033;">--dport</span> <span style="color: #007800;">$port</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># UDP rules</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">for</span> port <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$UDP_ALLOW</span>
<span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> udp_packets <span style="color: #660033;">-p</span> UDP <span style="color: #660033;">-s</span> <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span> <span style="color: #660033;">--dport</span> <span style="color: #007800;">$port</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># INPUT chain</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> ALL <span style="color: #660033;">-i</span> <span style="color: #007800;">$INET_IFACE</span> <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-i</span> <span style="color: #007800;">$INET_IFACE</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">--syn</span> <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> NEW <span style="color: #660033;">-j</span> log_attach
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Rules for incoming packets from the internet</span>
<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SPOOFINGIP_CHECK</span>&quot;</span> == <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> spoofing_check
&nbsp;
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> spoofing_check <span style="color: #660033;">-s</span> 10.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> spoofing_check <span style="color: #660033;">-s</span> 169.254.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> spoofing_check <span style="color: #660033;">-s</span> 172.16.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">12</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> spoofing_check <span style="color: #660033;">-s</span> 127.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC
&nbsp;
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> spoofing_check <span style="color: #660033;">-s</span> 224.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> spoofing_check <span style="color: #660033;">-d</span> 224.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> spoofing_check <span style="color: #660033;">-s</span> 240.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> spoofing_check <span style="color: #660033;">-d</span> 240.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> spoofing_check <span style="color: #660033;">-s</span> 0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> spoofing_check <span style="color: #660033;">-d</span> 0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> spoofing_check <span style="color: #660033;">-d</span> 239.255.255.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> spoofing_check <span style="color: #660033;">-d</span> 255.255.255.255 <span style="color: #660033;">-j</span> DROP_TRAFFIC
&nbsp;
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$INET_IFACE</span> <span style="color: #660033;">-j</span> spoofing_check
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SSH_ATTACH</span>&quot;</span> == <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> sshattach_check
        <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> sshattach_check <span style="color: #660033;">-m</span> recent <span style="color: #660033;">--set</span> <span style="color: #660033;">--name</span> SSH
        <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> sshattach_check <span style="color: #660033;">-m</span> recent <span style="color: #660033;">--update</span> <span style="color: #660033;">--seconds</span> <span style="color: #000000;">60</span> <span style="color: #660033;">--hitcount</span> <span style="color: #007800;">$SSH_HITCOUNT</span> <span style="color: #660033;">--name</span> SSH <span style="color: #660033;">-j</span> log_attach
&nbsp;
        <span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$INET_IFACE</span> <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #007800;">$SSH_PORT</span> <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> NEW <span style="color: #660033;">-j</span> sshattach_check
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Port scan</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$PORTSCAN_CHECK</span>&quot;</span> == <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> check-flags
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> check-flags <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> ALL FIN,URG,PSH <span style="color: #660033;">-m</span> limit <span style="color: #660033;">--limit</span> <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>minute <span style="color: #660033;">-j</span> LOG <span style="color: #660033;">--log-level</span> <span style="color: #007800;">$LOGLEVEL</span> <span style="color: #660033;">--log-prefix</span> <span style="color: #ff0000;">&quot;NMAP:&quot;</span>
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> check-flags <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> ALL FIN,URG,PSH <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> check-flags <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> ALL ALL <span style="color: #660033;">-m</span> limit <span style="color: #660033;">--limit</span> <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>minute <span style="color: #660033;">-j</span> LOG <span style="color: #660033;">--log-level</span> <span style="color: #007800;">$LOGLEVEL</span> <span style="color: #660033;">--log-prefix</span> <span style="color: #ff0000;">&quot;XMAS:&quot;</span>
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> check-flags <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> ALL ALL <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> check-flags <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> ALL SYN,RST,ACK,FIN,URG <span style="color: #660033;">-m</span> limit <span style="color: #660033;">--limit</span> <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>minute <span style="color: #660033;">-j</span> LOG <span style="color: #660033;">--log-level</span> <span style="color: #007800;">$LOGLEVEL</span> <span style="color: #660033;">--log-prefix</span> <span style="color: #ff0000;">&quot;XMAS-PSH:&quot;</span>
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> check-flags <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> ALL SYN,RST,ACK,FIN,URG <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> check-flags <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> ALL NONE <span style="color: #660033;">-m</span> limit <span style="color: #660033;">--limit</span> <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>minute <span style="color: #660033;">-j</span> LOG <span style="color: #660033;">--log-level</span> <span style="color: #007800;">$LOGLEVEL</span> <span style="color: #660033;">--log-prefix</span> <span style="color: #ff0000;">&quot;NULL_SCAN:&quot;</span>
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> check-flags <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> ALL NONE <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> check-flags <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> SYN,RST SYN,RST <span style="color: #660033;">-m</span> limit <span style="color: #660033;">--limit</span> <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>minute <span style="color: #660033;">-j</span> LOG <span style="color: #660033;">--log-level</span> <span style="color: #007800;">$LOGLEVEL</span> <span style="color: #660033;">--log-prefix</span> <span style="color: #ff0000;">&quot;SYN/RST:&quot;</span>
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> check-flags <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> SYN,RST SYN,RST <span style="color: #660033;">-j</span> DROP_TRAFFIC
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> check-flags <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> SYN,FIN SYN,FIN <span style="color: #660033;">-m</span> limit <span style="color: #660033;">--limit</span> <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>minute <span style="color: #660033;">-j</span> LOG <span style="color: #660033;">--log-level</span> <span style="color: #007800;">$LOGLEVEL</span> <span style="color: #660033;">--log-prefix</span> <span style="color: #ff0000;">&quot;SYN/FIN:&quot;</span>
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> check-flags <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> SYN,FIN SYN,FIN <span style="color: #660033;">-j</span> DROP_TRAFFIC
&nbsp;
	<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-i</span> <span style="color: #007800;">$INET_IFACE</span> <span style="color: #660033;">-j</span> check-flags
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$FTP_ENABLE</span>&quot;</span> == <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #666666; font-style: italic;">#Allow FTP traffic (Control)</span>
        iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--sport</span> <span style="color: #007800;">$FTP_PORT</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">21</span> <span style="color: #660033;">-j</span> ACCEPT
        iptables <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--sport</span> <span style="color: #000000;">21</span> <span style="color: #660033;">--dport</span> <span style="color: #007800;">$FTP_PORT</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
        <span style="color: #666666; font-style: italic;">#Allow FTP traffic (Data)</span>
        iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--sport</span> <span style="color: #007800;">$FTP_PORT</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">20</span> <span style="color: #660033;">-j</span> ACCEPT
        iptables <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--sport</span> <span style="color: #000000;">20</span> <span style="color: #660033;">--dport</span> <span style="color: #007800;">$FTP_PORT</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
&nbsp;
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$INET_IFACE</span> <span style="color: #660033;">-j</span> vip_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$INET_IFACE</span> <span style="color: #660033;">-j</span> band_packets
&nbsp;
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> ICMP <span style="color: #660033;">-i</span> <span style="color: #007800;">$INET_IFACE</span> <span style="color: #660033;">-j</span> icmp_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-i</span> <span style="color: #007800;">$INET_IFACE</span> <span style="color: #660033;">-j</span> tcp_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> UDP <span style="color: #660033;">-i</span> <span style="color: #007800;">$INET_IFACE</span> <span style="color: #660033;">-j</span> udp_packets
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># Default policy</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$INET_IFACE</span> <span style="color: #660033;">-j</span> DROP_TRAFFIC</pre></div></div>

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fos%2Fubuntu%2Fiptables_statefull_firewall_linux_debian_centos.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/os/ubuntu/iptables_statefull_firewall_linux_debian_centos.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>OpenVPN on Debian</title>
		<link>http://www.howtoconfig.com/os/debian/openvpn-on-debian.html</link>
		<comments>http://www.howtoconfig.com/os/debian/openvpn-on-debian.html#comments</comments>
		<pubDate>Thu, 15 Jan 2009 16:43:25 +0000</pubDate>
		<dc:creator>อัทศักดิ์ วงศ์กิตตะ</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[OpenVPN]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://www.howtoconfig.com/?p=50</guid>
		<description><![CDATA[สวัสดีอีกครั้งครับหลังจากหายหน้าหายตาไปนาน จริงๆก็ไม่ได้ไปไหนแค่หลังๆมางานที่ office ค่อนข้างมากแล้วผมเองก็ไปเที่ยวสะบ่อยๆ เลยไม่ค่อยได้มาเขียนบทความให้อ่านกัน   วันนี้เป็นเรื่องการทำ VPN  โดยใช้ OpenVPN    ทำไมต้องเป็น OpenVPN  สาเหตุของผมคือ ผมเองต้องติดตั้งระบบ Auth System (Radius + Chillispot + Syslog-ng)    แต่ละที่ดันเป็น Dynamic IP หมด  เวลาจะแก้ไขอะไรก็ต้องไป set router    ซึ่งมันไม่ใช่ทางเลือกที่ดีเลย    ทางแก้ผมเลย set up ที่ Center แล้วให้ Site แต่ละที่ทำการสร้าง VPN Connection ไปยัง Center Server# apt-get install openvpn Server# vi /etc/openvpn/server.conf # ไฟล์ /etc/openvpn/server.conf dev tap0 proto tcp-server ping [...]]]></description>
			<content:encoded><![CDATA[<p>สวัสดีอีกครั้งครับหลังจากหายหน้าหายตาไปนาน จริงๆก็ไม่ได้ไปไหนแค่หลังๆมางานที่ office ค่อนข้างมากแล้วผมเองก็ไปเที่ยวสะบ่อยๆ เลยไม่ค่อยได้มาเขียนบทความให้อ่านกัน   วันนี้เป็นเรื่องการทำ VPN  โดยใช้ OpenVPN    ทำไมต้องเป็น OpenVPN  สาเหตุของผมคือ ผมเองต้องติดตั้งระบบ Auth System (Radius + Chillispot + Syslog-ng)    แต่ละที่ดันเป็น Dynamic IP หมด  เวลาจะแก้ไขอะไรก็ต้องไป set router    ซึ่งมันไม่ใช่ทางเลือกที่ดีเลย    ทางแก้ผมเลย set up ที่ Center แล้วให้ Site แต่ละที่ทำการสร้าง VPN Connection ไปยัง Center</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Server<span style="color: #666666; font-style: italic;"># apt-get install openvpn</span>
Server<span style="color: #666666; font-style: italic;"># vi /etc/openvpn/server.conf</span></pre></div></div>

<p># ไฟล์ /etc/openvpn/server.conf</p>
<pre>
dev tap0
proto tcp-server
ping 1
ping-restart 5
port 10000
ifconfig 10.10.10.1 255.255.255.0
</pre>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Client<span style="color: #666666; font-style: italic;"># apt-get install openvpn</span>
Client<span style="color: #666666; font-style: italic;"># vi /etc/openvpn/client.conf</span></pre></div></div>

<p># ไฟล์ /etc/openvpn/server.conf</p>
<pre>
dev tap0
proto tcp-client
ping 1
ping-restart 5
port 10003
ifconfig 10.10.10.2 255.255.255.0
remote 203.1.1.1
</pre>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Server<span style="color: #666666; font-style: italic;"># /etc/init.d/openvpn start</span>
Client<span style="color: #666666; font-style: italic;"># /etc/init.d/openvpn start</span></pre></div></div>

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fos%2Fdebian%2Fopenvpn-on-debian.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/os/debian/openvpn-on-debian.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ยกเลิก Blank Screen บน Linux Console</title>
		<link>http://www.howtoconfig.com/os/ubuntu/disable-screen-blanking-screen-going-blank-on-linux.html</link>
		<comments>http://www.howtoconfig.com/os/ubuntu/disable-screen-blanking-screen-going-blank-on-linux.html#comments</comments>
		<pubDate>Thu, 03 Jul 2008 05:39:18 +0000</pubDate>
		<dc:creator>กวิน ชัยเลิศ</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[blank screen]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[concole]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux console]]></category>
		<category><![CDATA[setterm]]></category>
		<category><![CDATA[X window]]></category>

		<guid isPermaLink="false">http://www.howtoconfig.com/?p=30</guid>
		<description><![CDATA[ไม่ยากใช่ไหมครับหากต้องการยกเลิก screen saver บน X window แต่สำหรับ text mode (linux console) ผมคิดว่าหลายๆ คนยังไม่เคยยกเลิก blank screen หรือกำลังหาทางยกเลิกมันอยู่ สำหรับผมแล้วการยกเลิก blank screen บน linux console นั้นมีประโยชน์มากครับ ยกตัวอย่างเช่น เราสามารถทำงานไปพร้อมๆ กันกับการ monitor ดู error หรือ log จากอีกจอนึง (กรณีมีจอ monitor มากกว่าหนึ่งจอ) โดยที่ไม่ต้องคอยกดคีย์บอร์ดหรือเลื่อนเมาส์เพื่อให้ linux console แสดงผลอยู่ตลอดเวลา สำหรับวิธีการนั้นก็ไม่ได้ยุ่งยากเลยครับ แค่ใช้คำสั่ง setterm เท่านั้น setterm -blank 0 -powersave off -powerdown 0 &#60; /dev/console &#62; /dev/console 2&#62;&#38;1 [...]]]></description>
			<content:encoded><![CDATA[<p>ไม่ยากใช่ไหมครับหากต้องการยกเลิก screen saver บน X window แต่สำหรับ text mode (linux console) ผมคิดว่าหลายๆ คนยังไม่เคยยกเลิก blank screen หรือกำลังหาทางยกเลิกมันอยู่ สำหรับผมแล้วการยกเลิก blank screen บน linux console นั้นมีประโยชน์มากครับ ยกตัวอย่างเช่น เราสามารถทำงานไปพร้อมๆ กันกับการ monitor ดู error หรือ log จากอีกจอนึง (กรณีมีจอ monitor มากกว่าหนึ่งจอ) โดยที่ไม่ต้องคอยกดคีย์บอร์ดหรือเลื่อนเมาส์เพื่อให้ linux console แสดงผลอยู่ตลอดเวลา</p>
<p>สำหรับวิธีการนั้นก็ไม่ได้ยุ่งยากเลยครับ แค่ใช้คำสั่ง setterm เท่านั้น</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">setterm</span> <span style="color: #660033;">-blank</span> <span style="color: #000000;">0</span> <span style="color: #660033;">-powersave</span> off <span style="color: #660033;">-powerdown</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>console <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>console <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span></pre></div></div>

<p>หากต้องการยกเลิก blank screen ทุกครั้งหลังจาก start linux ให้ทำการเพิ่มคำสั่งดังกล่าวในไฟล์ /etc/rc.local เพียงเท่านี้ก็ไม่ต้องคอยกดคีย์บอร์ดหรือเลื่อนเมาส์ทุกๆ 5 นาทีแล้วครับ</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fos%2Fubuntu%2Fdisable-screen-blanking-screen-going-blank-on-linux.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/os/ubuntu/disable-screen-blanking-screen-going-blank-on-linux.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>เปลี่ยน default editor บน ubuntu</title>
		<link>http://www.howtoconfig.com/os/ubuntu/change-default-editor-on-ubuntu.html</link>
		<comments>http://www.howtoconfig.com/os/ubuntu/change-default-editor-on-ubuntu.html#comments</comments>
		<pubDate>Tue, 24 Jun 2008 10:32:48 +0000</pubDate>
		<dc:creator>กวิน ชัยเลิศ</dc:creator>
				<category><![CDATA[Operating System]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[default editor]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[hardy]]></category>
		<category><![CDATA[nano]]></category>
		<category><![CDATA[pine]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[system administrator]]></category>
		<category><![CDATA[ubuntu 8.04 hardy]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.howtoconfig.com/?p=25</guid>
		<description><![CDATA[จากประสบการณ์ที่ผ่านมา default editor บน linux และ *bsd มักจะเป็น vi ซึ่งตามปกติแล้ว system administrator (sysadmin) จำเป็นต้องใช้ default editor ของ os ในหลายๆ เหตุการณ์ เช่น ใช้ในคำสั่ง crontab เป็นต้น หลังจากที่ติดตั้ง Ubuntu 8.04 hardy ก็พบว่า default editor ไม่ใช่ vi ที่ผมคุ้นเคย กลับกลายเป็น nano editor หน้าตาเหมือนกับ pineapple สมัยที่ linux ยังไม่เฟื่องฟู (pine e-mail client) ไม่รู้ว่าคนแก่แถวๆ นี้มีใครนิยมกิน pine บ้างครับ &#8230; เพื่อไม่ให้ยืดเยื้อไปกว่านี้ เรามาเปลี่ยน default editor บน [...]]]></description>
			<content:encoded><![CDATA[<p>จากประสบการณ์ที่ผ่านมา default editor บน linux และ *bsd มักจะเป็น vi ซึ่งตามปกติแล้ว system administrator (sysadmin) จำเป็นต้องใช้ default editor ของ os ในหลายๆ เหตุการณ์ เช่น ใช้ในคำสั่ง crontab เป็นต้น</p>
<p>หลังจากที่ติดตั้ง Ubuntu 8.04 hardy ก็พบว่า default editor ไม่ใช่ vi ที่ผมคุ้นเคย กลับกลายเป็น nano editor หน้าตาเหมือนกับ pineapple สมัยที่ linux ยังไม่เฟื่องฟู (pine e-mail client) ไม่รู้ว่าคนแก่แถวๆ นี้มีใครนิยมกิน pine บ้างครับ &#8230; เพื่อไม่ให้ยืดเยื้อไปกว่านี้ เรามาเปลี่ยน default editor บน ubuntu กันดีกว่าครับ</p>
<p><span id="more-25"></span><br />
แปลงร่างเป็น root หรือใครถนัดใช้ sudo ก็ข้ามไปใช้ sudo ตามสะดวกครับ</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">su</span> -</pre></div></div>

<p>ทีนี้ก็เปลี่ยน default editor ตามนี้ครับ</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">update-alternatives <span style="color: #660033;">--config</span> editor</pre></div></div>

<blockquote><p>
There are 4 alternatives which provide `editor&#8217;.</p>
<p>  Selection    Alternative<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
          1    /usr/bin/vim.tiny<br />
          2    /bin/ed<br />
 +        3    /bin/nano<br />
*         4    /usr/bin/vim.basic</p>
<p>Press enter to keep the default[*], or type selection number:
</p></blockquote>
<p>แฟนพันธุ์ vi ก็ต้องเลือกหมายเลข 4 อยู่แล้ว &#8230; เพื่อนๆ เลือกหมายเลขอะไรกันครับ</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fos%2Fubuntu%2Fchange-default-editor-on-ubuntu.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/os/ubuntu/change-default-editor-on-ubuntu.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ติดตั้ง Linux ผ่าน Network ด้วย PXE Server</title>
		<link>http://www.howtoconfig.com/os/ubuntu/network-install-via-pxe-server.html</link>
		<comments>http://www.howtoconfig.com/os/ubuntu/network-install-via-pxe-server.html#comments</comments>
		<pubDate>Fri, 20 Jun 2008 17:41:01 +0000</pubDate>
		<dc:creator>กวิน ชัยเลิศ</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[dhcp]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[intel]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[network booting]]></category>
		<category><![CDATA[network install]]></category>
		<category><![CDATA[open standard]]></category>
		<category><![CDATA[PXE]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[syslinux]]></category>
		<category><![CDATA[tftp-server]]></category>

		<guid isPermaLink="false">http://www.howtoconfig.com/?p=24</guid>
		<description><![CDATA[มาทำความรู้รักกับ PXE กันก่อนครับ PXE หรือ Preboot eXecution Environment เป็น Open Standard ที่พัฒนาขึ้นโดย Intel ซึ่ง PXE นี้จะยอมให้ Computer ต่างๆ (Server, PC, Laptop, Notebook ที่ BIOS ลองรับ PXE Booting) สามารถ boot ผ่าน network ได้ไม่ต้องง้อ floppy, cd หรือ dvd กันเลยทีเดียว (มันสุดยอดจริงๆ ครับ) มาลุยกันเลยครับ Server : CentOS 5.1 + dhcp + tftp-server + httpd + syslinux Client : Ubuntu [...]]]></description>
			<content:encoded><![CDATA[<p><strong>มาทำความรู้รักกับ PXE กันก่อนครับ</strong><br />
<span style="color: #0000ff;">PXE</span> หรือ <span style="color: #0000ff;">P</span>reboot e<span style="color: #0000ff;">X</span>ecution <span style="color: #0000ff;">E</span>nvironment เป็น Open Standard ที่พัฒนาขึ้นโดย Intel ซึ่ง PXE นี้จะยอมให้ Computer ต่างๆ (Server, PC, Laptop, Notebook ที่ BIOS ลองรับ PXE Booting) สามารถ boot ผ่าน network ได้ไม่ต้องง้อ floppy, cd หรือ dvd กันเลยทีเดียว (มันสุดยอดจริงๆ ครับ)</p>
<p>มาลุยกันเลยครับ<br />
Server : CentOS 5.1 + dhcp + tftp-server + httpd + syslinux<br />
Client : Ubuntu 8.04</p>
<p>เอาเป็นว่าทุกๆ ท่านติดตั้ง CentOS ไว้เป็นที่เรียบร้อย ทีนี้ก็เป็นขั้นตอนการติดตั้ง PXE Server ละครับ</p>
<p>แปลงร่างเป็น root</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">su</span> -</pre></div></div>

<p>ติดตั้ง dhcp, tftp-server, httpd และ syslinux</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> dhcp tftp-server httpd syslinux</pre></div></div>

<p>เตรียม install files (ผมเลือกติดตั้ง Ubuntu 8.04)<br />
<a href="http://www.howtoconfig.com/linux/how-to-mount-iso-image-under-linux.html">>>วิธี mount iso image บน linux</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>ftp.science.nus.edu.sg<span style="color: #000000; font-weight: bold;">/</span>linux<span style="color: #000000; font-weight: bold;">/</span>ubuntu-ISO<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8.04</span><span style="color: #000000; font-weight: bold;">/</span>ubuntu-<span style="color: #000000;">8.04</span>-server-i386.iso
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/</span>mirror<span style="color: #000000; font-weight: bold;">/</span>ubuntu<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8.04</span>
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> loop ubuntu-<span style="color: #000000;">8.04</span>-server-i386.iso <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/</span>mirror<span style="color: #000000; font-weight: bold;">/</span>ubuntu<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8.04</span>
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-fr</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/</span>mirror<span style="color: #000000; font-weight: bold;">/</span>ubuntu<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8.04</span><span style="color: #000000; font-weight: bold;">/</span>install<span style="color: #000000; font-weight: bold;">/</span>netboot<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #000000; font-weight: bold;">/</span>tftpboot</pre></div></div>

<p><span id="more-24"></span><br />
Config tftp-server<br />
โดย default CentOS จะ disable tftp ที่ start ผ่าน xinetd ให้ทำการ configuration file &#8220;/etc/xinetd.d/tftp&#8221; ใหม่ด้วยการเปลี่ยน &#8220;disable = yes&#8221; ให้เป็น &#8220;disable = no&#8221; หรือใช้ sed ทำการแก้ไขก็ได้ครับ</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'/disable/ s/yes/no/'</span> <span style="color: #660033;">-i</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>xinetd.d<span style="color: #000000; font-weight: bold;">/</span>tftp
<span style="color: #666666; font-style: italic;">#restart xinetd</span>
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>xinetd restart</pre></div></div>

<p>Config dhcpd<br />
โดย default CentOS จะให้ copy configuration file มาจาก &#8220;/usr/share/doc/dhcp*/dhcpd.conf.sample&#8221; ส่วนตัวแล้วผมใช้เพียง configuration และ parameters บางตัวเท่านั้น ตามตัวอย่างนี้ครับ</p>

<div class="wp_syntax"><div class="code"><pre class="scheme" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">;</span>
<span style="color: #808080; font-style: italic;">;</span>
<span style="color: #808080; font-style: italic;">;</span>
<span style="color: #808080; font-style: italic;">;</span>
<span style="color: #808080; font-style: italic;">;</span>
<span style="color: #ff0000;">&quot;pxelinux.0&quot;</span><span style="color: #808080; font-style: italic;">;</span>
&nbsp;</pre></div></div>

<p>หลังจากทำการแก้ไข configuration file &#8220;/etc/dhcpd.conf&#8221; ก็ Start dhcpd ได้เลยครับ</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>dhcpd start</pre></div></div>

<p><span style="color: #ff0000;">Note : สามารถกำหนดได้ว่าจะให้ dhcpd ใช้ Interface ใดๆ โดย config ที่ file &#8220;/etc/sysconfig/dhcpd&#8221; ทำการเปลี่ยนค่าของ Interface DHCPDARGS=<em>ethX</em></span></p>
<p>เท่านี้ก็สามารถ Install Ubuntu ผ่าน Network โดย PXE Server บน CentOS ได้แล้วครับ<br />
หากเพื่อนๆ มีข้อสงสัยก็ถามมาได้เลยนะครับ webmaster@howtoconfig.com</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fos%2Fubuntu%2Fnetwork-install-via-pxe-server.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/os/ubuntu/network-install-via-pxe-server.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL Cluster on Debian AMD64</title>
		<link>http://www.howtoconfig.com/database/mysql-database/mysql-cluster-on-debian-amd64.html</link>
		<comments>http://www.howtoconfig.com/database/mysql-database/mysql-cluster-on-debian-amd64.html#comments</comments>
		<pubDate>Thu, 05 Jun 2008 20:46:51 +0000</pubDate>
		<dc:creator>อัทศักดิ์ วงศ์กิตตะ</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[NDB]]></category>

		<guid isPermaLink="false">http://www.howtoconfig.com/?p=19</guid>
		<description><![CDATA[สวัสดีเพื่อนๆรวมโลกทุกท่าน วันนี้ก็ได้โอกาศมาเขียนบทความเรื่อง MySQL Cluster สะที หลังจากที่ได้ทำการติดตั้ง และงมกะ Config มาหลายวันจริงๆผมต้องย้าย Database ให้เสร็จตั้งแต่วันที่ 2/6/2008 แต่จนถึงวันนนี้ก็ยังไม่ได้ย้าย Database เลย เหตุผลหลักคือ 1. Database ค่อนข้างใหญ่ ประมาณ 7G และมี Redcord อยู่ประมาณ 38 ล้าน Redcord 2. ตอน Import Data ผม Dump database มาผิดแบบ 3. MySQL ตอนที่ผม Lab test + ใช้งานจริงเป็นคนละ Version ด้วยเหตุผลเหล่านี้ทำให้ผมขึ้น MySQL Cluster ไม่ได้ หลังจากลองหาทางแก้อยู่หลายวัน ก็แก้ได้จนหมด งั้นวันนี้ผมก็ของบอกวิธีติดตั้ง และ Config ให้สามารถใช้งานได้ก่อนละกันนะครับ ส่วนเรื่องการ Tuning [...]]]></description>
			<content:encoded><![CDATA[<p>สวัสดีเพื่อนๆรวมโลกทุกท่าน  วันนี้ก็ได้โอกาศมาเขียนบทความเรื่อง MySQL Cluster สะที หลังจากที่ได้ทำการติดตั้ง และงมกะ Config  มาหลายวันจริงๆผมต้องย้าย Database ให้เสร็จตั้งแต่วันที่ 2/6/2008  แต่จนถึงวันนนี้ก็ยังไม่ได้ย้าย</p>
<p>Database เลย   เหตุผลหลักคือ</p>
<p>1. Database ค่อนข้างใหญ่ ประมาณ  7G และมี Redcord อยู่ประมาณ  38 ล้าน Redcord<br />
2. ตอน Import Data ผม Dump database มาผิดแบบ<br />
3. MySQL ตอนที่ผม Lab test + ใช้งานจริงเป็นคนละ Version</p>
<p>ด้วยเหตุผลเหล่านี้ทำให้ผมขึ้น MySQL Cluster ไม่ได้ หลังจากลองหาทางแก้อยู่หลายวัน ก็แก้ได้จนหมด  งั้นวันนี้ผมก็ของบอกวิธีติดตั้ง และ Config ให้สามารถใช้งานได้ก่อนละกันนะครับ  ส่วนเรื่องการ Tuning เอาไว้เดี๋ยวมาบอกอีกที</p>
<p>อุปกรณ์<br />
- Dell 1950, CPU 4Core 2.66GHz x2,  Ram 16G (ndbd+mysqld)<br />
- PC P4, Ram 1G (ndb_memd)</p>
<p>การตั้งค่า<br />
- DBC1     IP: 192.168.1.21<br />
- BDC2     IP: 192.168.1.22<br />
- MGM     IP: 192.168.1.11<br />
<span id="more-19"></span><br />
1. ทำการ Download ไฟล์มาเพื่อทำการติดตั้ง ทีแรกผมดันไปเอา Version ใหม่มาลงทำให้เกิดปัญหา  แนะนำให้ใช้ MySQL 5.1x + ndb 6.2.x นะครับ</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>mirror.siambox.com<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>mysql-5.1.23-ndb-6.2.15.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxf mysql-5.1.23-ndb-6.2.15.tar.gz
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> mysql-5.1.23-ndb-6.2.15
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql <span style="color: #660033;">--with-plugins</span>=max <span style="color: #660033;">--with-ndbcluster</span> <span style="color: #660033;">--with-charset</span>=tis620 <span style="color: #660033;">--with-extra-charsets</span>=all <span style="color: #660033;">--with-collation</span>=tis620_thai_ci
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #660033;">-j9</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>2. หลังจากติดตั้งทุกเครื่องแล้ว ให้ทำการตั้งค่า config ที่เครื่อง Manager Node (MGM)  ดั่งนี้</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>mysql-cluster
<span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>mysql-cluster<span style="color: #000000; font-weight: bold;">/</span>config.ini</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="scheme" style="font-family:monospace;">&nbsp;</pre></div></div>

<p>ค่าที่ต้องแก้ไขคือ</p>
<p>NoOfReplicas       คือจำนวนของ DataNode ที่มี<br />
Datadir               คือ Directory ที่จะทำการเก็บ Data ของ DataNode<br />
DataMemory       คือจำนวน Memory ที่จะ Allow ให้ MySQL  นำมาใช้งานเก็บ Data    ควรเหลือให้ System ใช้งานอย่างน้อง 1G    สูตรคือ (SizeofDatabase × NumberOfReplicas × 1.1 ) / NumberOfDataNodes<br />
IndexMemory      คือการกำหนดค่าให้ NDB ทำการ Allow Memory ที่จะให้เก็บ Index  ส่วนใหญ่ใช้ค่า  DataMemory/8 ครับ</p>
<p>3. ทำการตั้งค่าที่เครื่อง  NDB  ทั้ง 2 เครื่อง</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>my.cnf</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="scheme" style="font-family:monospace;"><span style="color: #ff0000;">&quot;192.168.1.11&quot;</span></pre></div></div>

<p>4. ทำการ start ndb_mgmd ก่อนและทำการตรวจสอบว่าทำงาน ดั่งนี้</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>ndb_memd <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>mysql-cluster<span style="color: #000000; font-weight: bold;">/</span>config.ini
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ndb_mgm</pre></div></div>

<p>5. ทำการ start ndbd  โดยการ start ครั้งแรกนั้นต้องใส่ options  &#8211;initial ด้วย   หากทำการ shutdown ndbd ไปแล้ว ครั้งต่อไปไม่ต้องทำการใส่ option อีก  หากใส่เข้าไป ndb จะทำการ clean data เก่าทั้งหมดทิ้ง</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>ndbd  <span style="color: #660033;">--initial</span></pre></div></div>

<p>6. ทำการตรวจสองว่า NDB ทำงานแล้ว โดยไปที่เครื่อง Manager Node  แล้วใช้คำสั่ง show เพื่อดู status ของ   ndb</p>

<div class="wp_syntax"><div class="code"><pre class="scheme" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">; show</span>
<span style="color: #808080; font-style: italic;">;</span></pre></div></div>

<p>หรือใช้คำสั่ง  ALL STATUS   จะเป็นการ show status ของแต่ละ node ดั่งนี้</p>

<div class="wp_syntax"><div class="code"><pre class="scheme" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">; ALL STATUS</span>
<span style="color: #808080; font-style: italic;">;</span></pre></div></div>

<p>7. ทำการ start mysqld  เพื่อให้ Client conenct มายัง API Node ได้</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">useradd <span style="color: #660033;">-u</span> <span style="color: #000000;">90</span> mysql
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysql_install_db
<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> mysql:mysql <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysqld_safe <span style="color: #000000; font-weight: bold;">&amp;</span>amp;</pre></div></div>

<p>ทำการตรวจสองว่า API Node ได้ทำการ Connect ไปยังเครื่อง Manager Node แล้ว โดยตรวจสอบที่เครื่อง MGM</p>

<div class="wp_syntax"><div class="code"><pre class="scheme" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">; show</span>
<span style="color: #808080; font-style: italic;">;</span></pre></div></div>

<p>หากขึ้นแบบ ขั้นต้น  ก็แปลว่า MySQL Cluster  ของเราสามารถทำงานได้แล้วครับผม</p>
<p>วิธีการใช้งาน  ก็สามารถให้ Client Connect มายังเครื่อง DBC1, DBC2 ได้เลยครับ   เวลา Create tables  เราก็เปลี่ยจาก Engine=MyISAM  เป็น  Engine=NDBCLUSTER    แค่นี้ ก็สามารถใช้งานได้แล้วครับ      เรื่องการทำ HA และการ Convert Data  เอาไว้ครั้งหน้าผมจะมาเขียนให้อีกทีแล้วกันนะครับ</pre>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fdatabase%2Fmysql-database%2Fmysql-cluster-on-debian-amd64.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/database/mysql-database/mysql-cluster-on-debian-amd64.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

