PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 1 PPPoE Server + Multiwan Loadbalance บน CentOS 5 up
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 1
PPPoE Server + Multiwan Loadbalance
บน
CentOS 5 up
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 2
อนดบแรกท าให ADSL เปน Bridge Mode กอนครบ ( ADSL แตละตวไมเหมอนกน อนนหาเอานะครบ )
*** รปแบบ
เลอกการดแลนทเราตองการใชงานเปน PPPoE ทเอาไวส าหรบท า Mutiwan LoadBalance
ในตวอยาง จาก Server ของผม
eth0 ------| รบเนตมาจาก ADSL Router WAN 1 = ppp0
||------- > Multiwan Loadbalance
eth1 ------| รบเนตมาจาก ADSL Router WAN 2 = ppp1
eth2 ----- Chillispot : TUN0 : IP Gateway = 10.0.0.1
eth3 ----- DHCP Server : IP Gateway = 192.168.100.1
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 3
ท าการ config ใหการดแลนทตองการท า PPPoE ในตวอยางจะเปน eth0 และ eth1
เรมดวยการ config การด eth0
# nano /etc/sysconfig/network-scripts/ifcfg-eth0
แกใหเหลออยแค 5 บรรทด
TYPE=Ethernet
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:07:e9:10:52:ce <-- ของใครของมน ไมเหมอนกน
ONBOOT=yes
แลวตอดวย การด eth1
# nano /etc/sysconfig/network-scripts/ifcfg-eth1
TYPE=Ethernet
DEVICE=eth3
BOOTPROTO=none
HWADDR=74:EA:3A:80:04:FA <-- ของใครของมน ไมเหมอนกน
ONBOOT=yes
จากนน restart network
# /etc/init.d/network restart
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 4
ตอจากนเปนขนตอนการท า PPPoE
ส าหรบการดแลน eth0 จะใช device เปน ppp0
เราจะท าการสราง Device Interface หลงจากเสรจ 2 ขนตอนน
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 5
อนดบแรกใหท าการใส Username และ Password ของผใหบรการ Internet (ISP)
# nano /etc/ppp/pap-secrets
แกเปน User และ Passwd ของ ISP
# LIC: GPL
# Edit this file and place it in /etc/ppp/pap-secrets
#User #Device #Password
####### redhat-config-network will overwrite this part!!! (begin) ##########
"vzw89xcaqu@indy" "ppp0" "hiGEbRep" <-- ppp0 ตองตรงกบชอ device eth0 ทจะท า
"vzw89xcaqu@indy" * "hiGEbRep"
####### redhat-config-network will overwrite this part!!! (end) ############
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 6
จากนนกใส Username และ Password ของผใหบรการ Internet (ISP) เหมอนเดม
# nano /etc/ppp/chap-secrets
แกเปน User และ Passwd ของ ISP
# LIC: GPL
# Edit this file and place it in /etc/ppp/pap-secrets
#User #Device #Password
####### redhat-config-network will overwrite this part!!! (begin) ##########
"vzw89xcaqu@indy" "ppp0" "hiGEbRep" <-- ppp0 ตองตรงกบชอ device eth0 ทจะท า
"vzw89xcaqu@indy" * "hiGEbRep"
####### redhat-config-network will overwrite this part!!! (end) ############
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 7
ตอดวยการ check option ของ pppoe
# cat /etc/ppp/pppoe-server-options
คาทระบบอานออกมา
# PPP options for the PPPoE server
# LIC: GPL
require-pap <-- แจง username และ password ผใหบรการ Internet (ISP)
login <-- ระบบการ login isp โดยระบบ server เอง
lcp-echo-interval 10 <-- ตวนบเวลา readme ขอมลออกมาโชว
lcp-echo-failure 2
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 8
Device Interface ส าหรบ ppp0 โดยการ alias device ของการดแลน eth0
เราตองท าการสรางไฟลขนมาใหส าหรบ ppp0 เพราะระบบไมไดสรางไฟลนมาให
( ถาลงแบบ Text mode )
# touch /etc/sysconfig/network-scripts/ifcfg-ppp0
สรางไฟลเสรจกท าการใสโคดบรรทดค าสงให ifcfg-ppp0 ไดเลย
# nano /etc/sysconfig/network-scripts/ifcfg-ppp0
ใสโคดค าสงน ลงไปใหทงหมดเลย
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
TYPE=xDSL <-- เปนชอโครงสรางบงคบ xDSL
DEVICE=ppp0 <-- ชอ device ของอปกรณทเราสรางในขนตอนหนาท 4 ตองตรงกน BOOTPROTO=dialup <-- เราตองใชงานแบบ PPPoE เองจาก Server ของเรา USERCTL=no
IPV6INIT=no
PEERDNS=yes
PIDFILE=/var/run/pppoe-adsl.pid <-- ไฟลโปรเซสของ pppoe ใสตามนเลย FIREWALL=NONE
PING=. <-- เปนการ ping ทก dns ( ใสแคคา จด . เฉยๆ นะครบ ) PPPOE_TIMEOUT=80
LCP_FAILURE=3
LCP_INTERVAL=20
CLAMPMSS=1412
CONNECT_POLL=6
CONNECT_TIMEOUT=60
PERSIST=no
SYNCHRONOUS=no
DEFROUTE=yes
USER="vzw89xcaqu@indy" <-- ยสเซอรเนม ของผใหบรการเนตในขนตอนหนาท 4
ETH=eth0 <-- เชอมตอ ppp0 โดยอาศยการดแลน eth0 เปนเสนทางของการเชอมตอ PROVIDER=ppp0 <-- ชอ device ทเราสรางในขนตอนหนาท 4 ตองตรงกน
DEMAND=no
ONBOOT=yes
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 9
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 10
ท าการเชอมตอ ADSL Router เพอการ PPPoE แทนตว Router
ทดสอบโดยการ Restart Service Network
# /etc/init.d/network restart
Bringing up interface ppp0: [ OK ] <-- เชอมตอ ppp0 ส าเรจ (ตองไมม error)
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 11
ท าการตรวจสอบ Interface ด
# ifconfig
……
……
ppp0 Link encap:Point-to-Point Protocol
inet addr:223.205.236.234 P-t-P:223.205.232.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:198 (198.0 b) TX bytes:54 (54.0 b)
…..
…..
ทานกจะเหน ppp0 ขนมาแสดงเพม (เหมอนกบการเพม tun0 ใน chillispot)
inet addr:223.205.236.234 P-t-P:223.205.232.1 Mask:255.255.255.255
( ใน inet addr จะไมคงท เปลยนใหมทกครง )
DNS ของผใหบรการ หรอ ไอพจรง ททานจะไดรบ แบบนงๆ ไมเปลยนแปลง ( 2 DNS )
ทานตองไปดใน /etc/resolv.conf เมอ ppp0 ท างาน
# cat /etc/resolv.conf
nameserver 110.164.252.222 <-- DNS1 ไอพจรงทไดรบ
nameserver 110.164.252.223 <-- DNS2 ไอพจรงทไดรบ
nameserver 192.168.2.1 <-- ตวเกาของการดแลน eth1 เพราะยงไมไดท า ppp1
search localhost
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 12
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 13
จากนนทดลองท าการ ping ไอพจรงด
# ping 110.164.252.222
connect: Network is unreachable
ระบบกจะแจงทานวา สอสารไมได ( มนตองเปนเชนนอยแลว~! )
เพราะเรายงไมไดท าการไปเพมคาใน
/etc/firewall และ /etc/rc.d/rc.firewall.local นนเอง~!
แตส าหรบ firewall ในคมอน ไดท าการ compiler firewall ส าหรบการท า Multiwan แลว
ดงนนถายงไมไดท าการตอนรบระบบ multiwan กตองไปแจงท /etc/firewall.iptables
ตอไปจะเปนขนตอนการ install package เพอการ compile firewall
รองรบระบบ Multiwan Loadbalance
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 14
CentOS – PPPoE - Multiwan Loadbalance
# cd /tmp/temp/
# yum -y install perl-Crypt-SSLeay
จากนนท าการ Download ทง 3 ไฟล มาเกบไวใน /tmp/temp
http://www.mediafire.com/?jt9cht99ju5ypa3
http://www.mediafire.com/?ogsry32fb74cvje
http://www.mediafire.com/?4d6wfxg47ea6snt
# rpm -Uvh cc-firewall-4.2-50.i386.rpm
Preparing... ########################################### [100%]
1:cc-firewall ########################################### [100%]
# rpm -Uvh cc-syswatch-4.2-10.i386.rpm Preparing... ########################################### [100%]
1:cc-syswatch ########################################### [100%]
# rpm -Uvh firewall-1.3.5-1.i386.rpm Preparing... #################################### [100%]
1:firewall ##################################### [100%]
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 15
ท าการสรางลงก
# cd /sbin/
# ln -sf iptables iptables-bin
# ls -l iptables-bin
lrwxrwxrwx 1 root root 8 Jun 20 18:40 iptables-bin -> iptables
# cd /etc/iproute2/
# ln -sf rt_dsfield rt_dsfield.rt_config
# ln -sf rt_protos rt_protos.rt_config
# ln -sf rt_realms rt_realms.rt_config
# ln -sf rt_scopes rt_scopes.rt_config
# ln -sf rt_tables rt_tables.rt_config
# ls -l
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 16
# nano +12 /etc/firewall
แกเปน # Firewall mode
#--------------
# Possible configurations: # gateway trustedgateway standalone trustedstandalone dmz
MODE="gateway"
จากนนท าการแก config ไฟล ใหใชงาน PPPoE บน Interface : ppp0
( ppp1 ยงใชงานเปน eth1 อย ท าการทดสอบใชงาน ppp0 กอน )
# nano +18 /etc/firewall เดม
# Interface roles #----------------
EXTIF="eth0"
LANIF=""
DMZIF="" WIFIF=""
HOTIF=""
แกเปน สวน eth0 = ppp0
สวน eth1 = ADSL Gateway wan2 ( 192.168.2.1 ) สวน eth2 = tun0 lan Chillispot ( 10.0.0.1 )
สวน eth3 = DHCP Server ( 192.168.100.1 )
EXTIF="ppp0 eth1" <-- ในขนตอนนเปน multiwan แลว ใชงานไดปกต เพยงแตยงไมได ppp1
LANIF="eth2 eth3" DMZIF=""
WIFIF=""
HOTIF=""
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 17
# nano +27 /etc/firewall
เดม # Bandwidth management (QoS)
#---------------------------
BANDWIDTH_QOS="on"
BANDWIDTH_UPSTREAM=1000000 BANDWIDTH_DOWNSTREAM=1000000
แกเปน # Bandwidth management (QoS)
#---------------------------
BANDWIDTH_QOS="off" BANDWIDTH_UPSTREAM=1000000
BANDWIDTH_DOWNSTREAM=1000000
# nano +38 /etc/firewall
เดม # Multipath
#----------
MULTIPATH="off"
MULTIPATH_WEIGHTS=""
แกเปน
# Multipath
#----------
MULTIPATH="on"
MULTIPATH_WEIGHTS="eth1|1 ppp0|1" <-- ส าหรบ LoadBalance เสน-ตอ-เสน
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 18
# nano +44 /etc/firewall เดม # Squid configuration
#--------------------
SQUID_TRANSPARENT="off"
SQUID_FILTER_PORT=""
*~ในขนตอนนเฉพาะทานทไดตดตง squid proxy แบบ transparent ผานแลว
แกเปน
# Squid configuration
#--------------------
SQUID_TRANSPARENT="on"
SQUID_FILTER_PORT=""
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 19
# nano +85 /etc/firewall
เดม
# NOTE: If editing these by hand, do not add spaces between fields.
RULES="\
webservice||0x10000001|6||1875| \
"
# vim: ts=4 syntax=sh
ในขนตอนนเปนการ Incomming เปด port ให remote จากขางนอกเขามา หรอ ทาง WAN นนเอง
แกเปน
# NOTE: If editing these by hand, do not add spaces between fields.
RULES="\
HTTP||0x10000001|6|110.164.252.222|80| \ <-เปนการระบไอพจรง remote เขามาทาง ppp0 DNS1
HTTP||0x10000001|6|110.164.252.223|80| \ <-เปนการระบไอพจรง remote เขามาทาง ppp0 DNS2
HTTP||0x10000001|6|192.168.2.1|80| \ <-เปนการระบไอพจรง remote เขามาทาง eth1 ตวเกา
HTTPS||0x10000001|6|110.164.252.222|443| \
HTTPS||0x10000001|6|110.164.252.223|443| \
HTTPS||0x10000001|6|192.168.2.1|443| \
SSH||0x10000001|6||22| \ <-เปนการไมระบไอพทจะ remote เขามา ระบบจะจดการแบบ multiwan เอง
Webmin||0x10000001|6||10000| \
"
# vim: ts=4 syntax=sh
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 20
# nano +8 /etc/syswatch
เดม
# Connection type
# - values: dhcp, static, or pppoe
conntype=pppoe
แกเปน
# Connection type
# - values: dhcp, static, or pppoe conntype= static
# nano +14 /etc/syswatch
แกเปน
# Server type
# - values: gateway, onlan
servtype=gateway
# nano +49 /etc/syswatch
เดม
firewall="/etc/rc.d/init.d/firewall restart >/dev/null"
ในขนตอนนถาไมแก เวลาระบบ restart ทกครง ไฟลจะวางเปลาตลอด
จะท าให iptable ของ firewall ตอง add ใหมทกครง ( ซงไมดแน )
แกเปน
firewall="/etc/rc.d/init.d/firewall restart"
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 21
# nano +57 /etc/syswatch
เดม
# Ping servers
# - The syswatch daemon by default will just ping the next hop on the Internet
# and another device. You can override this with a comma separated list of
# 2 servers.
ping_servers=203.146.237.222,203.144.144.163
ขนตอนนใหแกเปน DNS ของผใหบรการของแตละทาน
DNS1 ,DNS2 ,eth1 ( กนลม eth1 เรายงไมไดท า ppp1 ใช อนเกาไปกอน)
แกเปน
ping_servers=110.164.252.222 , 110.164.252.223 , 192.168.2.1
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 22
ขนตอนตอไป เปนการ config ไฟล chilli.conf และ rc.local
Chillispot
# nano +59 /etc/chilli.conf
เดม
# TAG: dns1
# Primary DNS server.
# Will be suggested to the client.
# If omitted the system default will be used.
# Normally you do not need to uncomment this tag.
dns1 192.168.1.100
# TAG: dns2
# Secondary DNS server.
# Will be suggested to the client.
# If omitted the system default will be used.
# Normally you do not need to uncomment this tag.
dns2 192.168.1.1
ท าการใสเครองหมาย # เพอใหระบบมองเปน comment
เพราะในสวนนระบบจะให Chillispot ไปอานคา DNS จากไฟล /etc/resolv.conf เอง
แกเปน
# TAG: dns1
# Primary DNS server.
# Will be suggested to the client.
# If omitted the system default will be used.
# Normally you do not need to uncomment this tag.
#dns1 192.168.1.254
# TAG: dns2
# Secondary DNS server.
# Will be suggested to the client.
# If omitted the system default will be used.
# Normally you do not need to uncomment this tag.
#dns2 192.168.1.1
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 23
ขนตอนตอไปน เปนขนตอนท IPTABLES จะตองน ามาใสในไฟลนเทานน เพราะต าแหนงไฟลเปลยนไปแลว
Firewall ของ CentOS ตอนนจะเปนเหมอนของ ClearOS แทน
เพราะ CentOS กบ ClearOS กอนเดยวกน ..คลอดออกมาทองเดยวกน แต ClearOS ถกออกแบบใหใช
firewall ส าหรบ Multiwan ตงแตตอนตดตง และถกออกแบบ WEB UI แทน
# nano /etc/rc.d/rc.firewall.local
เดม ( ไมมอะไร มแต comment ใหน า service tables มาใส )
# Custom firewall rules.
# This file is executed by the firewall on stop/start/restart.
เรากไปน าสวนของ IPTABLES อนเกา จากไฟล /etc/firewall.iptables มาใสแทน เฉพาะสวนทใชงาน
ใสเปน #Enable NAT on output device
$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
## Squid Proxy Allow transparent proxy
$IPTABLES -A INPUT -p tcp -m tcp --dport 3128 --syn -j ACCEPT
#
# Squid Proxy Allow transparent proxy for Tun0
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 3128 --syn -j DROP
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.0.0/24 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.0.0/16 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.0.0/8 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 127.0.0.0/8 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
แกเปน PPPoE ตามการดเลย #Enable NAT on output device
$IPTABLES -t nat -A POSTROUTING -o ppp0 -j MASQUERADE <-- กไมมไรมาก แกแค 2 ไฟลนเทานน
เพราะ WAN ม 2 ตว จงตองม nat 2 ตว
$IPTABLES -t nat -A POSTROUTING -o eth1 -j MASQUERADE จาก $EXTIF มาเปน PPPoE แทน
## Squid Proxy Allow transparent proxy
$IPTABLES -A INPUT -p tcp -m tcp --dport 3128 --syn -j ACCEPT
## Squid Proxy Allow transparent proxy for Tun0 -> eth2
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 3128 --syn -j DROP
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.0.0/24 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.0.0/16 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.0.0/8 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 127.0.0.0/8 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 24
Config file In
/etc/rc.d/rc.firewall.local
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 25
# nano /etc/rc.local
เดม
sh /etc/firewall.iptables
แกเปนการสง start firewall ส าหรบการ Multiwan อยางเดยว ( อนเดมปลอยทงไวเลย )
แกเปน
sh /etc/firewall
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 26
ตอไปเปนการ Restart Service ระบบ ทไดท าการแกไขใหเรมตนใหมหมด
# shutdown -r now
หมายเหต
ในขนตอนการน า IPTABLES มาใส หรอ เพมเตม ครงตอไป
ใหน าไปใสใน path /etc/rc.d/rc.firewall.local ทกครง
แลวสง Restart service firewall ใหมทกครงทเปลยนแปลง
# /etc/init.d/firewall restart
~รอสกพกในขนตอนน เพอรอการ ping ppp0 ทดสอบใชงานดกอน~ …
พอลอกอนเขาระบบเรยบรอยแลว ลองท าการ ping DNS1 และ DNS2 ทดสอบด
# cat /etc/resolv.conf
nameserver 110.164.252.222
nameserver 110.164.252.223
nameserver 192.168.2.1
search localhost
ท าการทดสอบ ping DNS1 แลวตอดวย DNS2
# ping 110.164.252.222
# ping 110.164.252.223
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 27
จากนทดลองทดสอบการ ping เพอออกเนต
# ping www.google.com
*ออกเนตไดอยางชดเจนครบ
ตอไปกเปนขนตอนการท าใหการดแลน eth1 เปน Interface ppp1
ท าการเรมตนอกครงตามคมอในหนาท 3
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 28
สรางไฟล PPPoE ส าหรบ ppp1
อนดบแรกใหท าการใส Username และ Password ของผใหบรการ Internet (ISP)
# nano /etc/ppp/pap-secrets
แกเปน User และ Passwd ของ ISP เพมตอจาก ppp0 ไดเลย
# LIC: GPL
# Edit this file and place it in /etc/ppp/pap-secrets
#User #Device #Password
####### redhat-config-network will overwrite this part!!! (begin) ##########
"vzw89xcaqu@indy" "ppp0" "hiGEbRep" <-- ppp0 ตองตรงกบชอ device eth0 ทจะท า
"vzw89xcaqu@indy" * "hiGEbRep"
"cznxv2cqqa@indy" "ppp1" "EIkkCRut" <-- ppp1 ตองตรงกบชอ device eth1 ทจะท า
"cznxv2cqqa@indy" * "EIkkCRut"
####### redhat-config-network will overwrite this part!!! (end) ############
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 29
จากนนกใส Username และ Password ของผใหบรการ Internet (ISP) เหมอนเดม
# nano /etc/ppp/chap-secrets
แกเปน User และ Passwd ของ ISP เพมตอจาก ppp0 ไดเลย
# LIC: GPL
# Edit this file and place it in /etc/ppp/pap-secrets
#User #Device #Password
####### redhat-config-network will overwrite this part!!! (begin) ##########
"vzw89xcaqu@indy" "ppp0" "hiGEbRep" <-- ppp0 ตองตรงกบชอ device eth0 ทจะท า
"vzw89xcaqu@indy" * "hiGEbRep"
"cznxv2cqqa@indy" "ppp1" "EIkkCRut" <-- ppp1 ตองตรงกบชอ device eth1 ทจะท า
"cznxv2cqqa@indy" * "EIkkCRut"
####### redhat-config-network will overwrite this part!!! (end) ############
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 30
Device Interface ส าหรบ ppp1 โดยการ alias device ของการดแลน eth1
เราตองท าการสรางไฟลขนมาใหส าหรบ ppp1 เพราะระบบไมไดสรางไฟลนมาให
( ถาลงแบบ Text mode )
# touch /etc/sysconfig/network-scripts/ifcfg-ppp1
สรางไฟลเสรจกท าการใสโคดบรรทดค าสงให ifcfg-ppp1 ไดเลย
# nano /etc/sysconfig/network-scripts/ifcfg-ppp1
ใสโคดค าสงน ลงไปใหทงหมดเลย
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
TYPE=xDSL <-- เปนชอโครงสรางบงคบ xDSL
DEVICE=ppp1 <-- ชอ device ของอปกรณทเราสรางในขนตอนหนาท 4 ตองตรงกน BOOTPROTO=dialup <-- เราตองใชงานแบบ PPPoE เองจาก Server ของเรา USERCTL=no
IPV6INIT=no
PEERDNS=yes
PIDFILE=/var/run/pppoe-adsl.pid <-- ไฟลโปรเซสของ pppoe ใสตามนเลย FIREWALL=NONE
PING=. <-- เปนการ ping ทก dns ( ใสแคคา จด . เฉยๆ นะครบ ) PPPOE_TIMEOUT=80
LCP_FAILURE=3
LCP_INTERVAL=20
CLAMPMSS=1412
CONNECT_POLL=6
CONNECT_TIMEOUT=60
PERSIST=no
SYNCHRONOUS=no
DEFROUTE=yes
USER="cznxv2cqqa@indy" <-- ยสเซอรเนม ของผใหบรการเนตในขนตอนหนาท 4
ETH=eth1 <-- เชอมตอ ppp0 โดยอาศยการดแลน eth0 เปนเสนทางของการเชอมตอ PROVIDER=ppp1 <-- ชอ device ทเราสรางในขนตอนหนาท 4 ตองตรงกน
DEMAND=no
ONBOOT=yes
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 31
ท าการเชอมตอ ADSL Router เพอการ PPPoE แทนตว Router
ทดสอบโดยการ Restart Service Network
# /etc/init.d/network restart
ท าการตรวจสอบ Interface ด
# ifconfig
……
……
ppp1 Link encap:Point-to-Point Protocol
inet addr:223.205.14.191 P-t-P:223.205.8.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:198 (198.0 b) TX bytes:54 (54.0 b)
…..
…..
ทานกจะเหน ppp1 ขนมาแสดงเพม (เหมอนกบการเพม tun0 ใน chillispot)
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 32
จากนนท าการแก config ไฟล ใหใชงาน PPPoE บน Interface : ppp0
( ppp1 ยงใชงานเปน eth1 อย ท าการทดสอบใชงาน ppp0 กอน )
# nano +18 /etc/firewall
เดม # Interface roles
#----------------
EXTIF="ppp0 eth1" <-- ในขนตอนนเปน multiwan แลว ใชงานไดปกต เพยงแตยงไมได ppp1 LANIF="eth2 eth3"
DMZIF=""
WIFIF=""
HOTIF="" แกเปน
สวน eth0 = ppp0 สวน eth1 = ppp1
สวน eth2 = tun0 lan Chillispot ( 10.0.0.1 )
สวน eth3 = DHCP Server ( 192.168.100.1 )
EXTIF="ppp0 ppp1" <-- ในขนตอนนเปน multiwan เตมทแลว
LANIF="eth2 eth3"
DMZIF=""
WIFIF=""
HOTIF=""
# nano +38 /etc/firewall เดม
# Multipath
#----------
MULTIPATH="on"
MULTIPATH_WEIGHTS="eth1|1 ppp0|1" <-- ส าหรบ LoadBalance เสน-ตอ-เสน
แกเปน
# Multipath #----------
MULTIPATH="on"
MULTIPATH_WEIGHTS="ppp1|1 ppp0|1" <-- ส าหรบ LoadBalance เสน-ตอ-เสน
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 33
# nano +85 /etc/firewall
เดม
# NOTE: If editing these by hand, do not add spaces between fields.
RULES="\
HTTP||0x10000001|6|110.164.252.222|80| \ <-เปนการระบไอพจรง remote เขามาทาง ppp0 DNS1
HTTP||0x10000001|6|110.164.252.223|80| \ <-เปนการระบไอพจรง remote เขามาทาง ppp0 DNS2
HTTP||0x10000001|6|192.168.2.1|80| \ <-เปนการระบไอพจรง remote เขามาทาง eth1 ตวเกา
HTTPS||0x10000001|6|110.164.252.222|443| \
HTTPS||0x10000001|6|110.164.252.223|443| \
HTTPS||0x10000001|6|192.168.2.1|443| \
SSH||0x10000001|6||22| \ <-เปนการไมระบไอพทจะ remote เขามา ระบบจะจดการแบบ multiwan เอง
Webmin||0x10000001|6||10000| \
"
# vim: ts=4 syntax=sh
ในขนตอนนเปนการ Incomming เปด port ให remote จากขางนอกเขามา หรอ ทาง WAN นนเอง
แกเปน (ขนตอนนไมตองใส ไอพจรง กได ปลอยวางเลย ใหระบบจดการเอง)
# NOTE: If editing these by hand, do not add spaces between fields.
RULES="\
HTTP||0x10000001|6|110.164.252.222|80| \ <-เปนการระบไอพจรง remote เขามาทาง ppp0 DNS1
HTTP||0x10000001|6|110.164.252.223|80| \ <-เปนการระบไอพจรง remote เขามาทาง ppp0 DNS2
HTTP||0x10000001|6|110.164.254.231|80| \ <-เปนการระบไอพจรง remote เขามาทาง ppp1 DNS1
HTTP||0x10000001|6|110.164.254.232|80| \ <-เปนการระบไอพจรง remote เขามาทาง ppp1 DNS2
HTTPS||0x10000001|6||443| \
SSH||0x10000001|6||22| \
Webmin||0x10000001|6||10000| \
"
# vim: ts=4 syntax=sh
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 34
# nano +57 /etc/syswatch
เดม
# Ping servers
# - The syswatch daemon by default will just ping the next hop on the Internet
# and another device. You can override this with a comma separated list of
# 2 servers.
ping_servers=110.164.252.222 , 110.164.252.223 , 192.168.2.1
ขนตอนนใหแกเปน DNS ของผใหบรการของแตละทาน
ppp0 -> DNS1 ,DNS2
ppp1 -> DNS1 ,DNS2
แกเปน
ping_servers=110.164.252.222 , 110.164.252.223 , 110.164.254.231 , 110.164.254.232
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 35
# nano /etc/rc.d/rc.firewall.local
เดม ( ไมมอะไร มแต comment ใหน า service tables มาใส )
# Custom firewall rules.
# This file is executed by the firewall on stop/start/restart.
เรากไปน าสวนของ IPTABLES อนเกา จากไฟล /etc/firewall.iptables มาใสแทน เฉพาะสวนทใชงาน
ใสเปน
แกเปน PPPoE ตามการดเลย #Enable NAT on output device
$IPTABLES -t nat -A POSTROUTING -o ppp0 -j MASQUERADE <-- กไมมไรมาก แกแค 2 ไฟลนเทานน
เพราะ WAN ม 2 ตว จงตองม nat 2 ตว
$IPTABLES -t nat -A POSTROUTING -o ppp1 -j MASQUERADE จาก $EXTIF มาเปน PPPoE แทน
## Squid Proxy Allow transparent proxy
$IPTABLES -A INPUT -p tcp -m tcp --dport 3128 --syn -j ACCEPT
## Squid Proxy Allow transparent proxy for Tun0 -> eth2
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 3128 --syn -j DROP
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.0.0/24 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.0.0/16 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.0.0/8 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 127.0.0.0/8 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 36
ตอไปเปนการ Restart Service ระบบ ทไดท าการแกไขใหเรมตนใหมหมด
# shutdown -r now
หมายเหต
ในขนตอนการน า IPTABLES มาใส หรอ เพมเตม ครงตอไป
ใหน าไปใสใน path /etc/rc.d/rc.firewall.local ทกครง
แลวสง Restart service firewall ใหมทกครงทเปลยนแปลง
# /etc/init.d/firewall restart
~รอสกพกในขนตอนน เพอรอการ ping ppp1 ทดสอบใชงานดกอน~ …
พอลอกอนเขาระบบเรยบรอยแลว ลองท าการ ping DNS1 และ DNS2 ทดสอบด
PortsProgrammer ( PPPoE + Multiwan Loadbalance ) - 37
ตรวจสอบแบบชดเจนทสด
ใหทานลองถอดสาย WAN เสนใดเสนหนง ออก
แลวลองใหเครองลกขายเลนเนตตามปกตด ชวงแรกๆ เนตจะ delay นดหนง
ทานกเปลยน URL ไปเปน www.google.com หรอเวบอนๆด
รบรองเหนไดชดวา Multiwan ท างานแทนกน เสนใดเสนหนง