Set Share Internet โดยใช้ NIC 2 ชุด
eth0 ip address 10.0.0.5/24
eth1 ip address 200.0.0.1/24

http://www.howtoforge.com/home-gateway-firewall-with-dhcp-server-for-connection-sharing-centos5
#yum install dhcp
ทำการสร้าง dhcpd.conf
#cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
ทำการแก้ไขตามกลุ่มเครือข่ายที่กำหนดไว้
#vim /etc/dhcpd.conf
กด I เพื่อทำการ Insert
ddns-update-style interim;
ignore client-updates;
DHCPARGS=eth1; subnet 200.0.0.0 netmask 255.255.255.0 {
# --- default gateway
option routers 200.0.0.1;
option subnet-mask 255.255.255.0;
option domain-name "coe.psu.ac.th"; # name server isp
option domain-name-servers 172.30.0.5;
option domain-name-servers 172.30.0.9;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 200.0.0.100 200.0.0.200;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
เมื่อกำหนดค่าเสร็จเรียบร้อย Esc+ “:wq” เพื่อทำการบันทึก
ทำการกำหนดค่า ip address ให้กับ eth1 โดยคำสั่ง
#vim /etc/sysconfig/network-scripts/ifcfg-eth1
กด I เพื่อทำการ Insert
DEVICE=eth01
BOOTPROTO=none
HWADDR=00:1D:0F:C9:BC:2C
IPADDR=200.0.0.1
NETWROK=200.0.0.0
NETMASK=255.255.255.0
ONBOOT=yes
เมื่อกำหนดค่าเสร็จเรียบร้อย Esc+ “:wq” เพื่อทำการบันทึก
เพื่อตรวจสอบการทำงานของ Internet ในเครื่องหลักโดยลองใช้คำสั่ง
#curl http://www.google.com
สั่งให้ระบบเครื่อข่ายทำงานใหม่โดย
#service network restart
ถ้าทุกอย่างขึ้น [OK] ถือว่าเรียบร้อย
สั่งให้ DHCP ทำงานโดย สั่ง
#service dhcpd restart
ถ้าทุกอย่างขึ้น [OK] ถือว่าเรียบร้อย
จัดการ สร้าง Route และ Firewall โดยการกำหนด Forward packet จาก eth1--> eth0
#service iptables stop
#iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
#service iptables save
#service iptables restart
#echo 1 > /proc/sys/net/ipv4/ip_forward
ทำการกำหนดให้ทุกครั้งที่เปิดเครื่องสามารถทำงานทันที
# vim /etc/sysctl.conf
net.ipv4.ip_forward = 0 เปลี่ยนเป็น 1
เมื่อกำหนดค่าเสร็จเรียบร้อย Esc+ “:wq” เพื่อทำการบันทึก
สั่ง restart เครื่องแม่ข่ายใหม่ โดย #reboot
จากนั้นไปเริ่มจัดการเครื่องลูกข่ายต่อไป
เมื่อเปิดเครื่องมาสำรวจ ip addrsss ที่ได้รับ จะเริ่มที่ 200.0.0.200
ทดสอบ ping 200.0.0.1
ทดสอบ ping 10.0.0.5
ทดสอบ ping www.google.com ถ้าสำเร็จก็ลองใช้ web browser เข้า internet ได้ทันที
ลองดูนะครับผิดพลาดอะไรแจ้งด้วยจะตามแก้ไข อีกที