Created
May 1, 2012 15:04
-
-
Save taowen/2568620 to your computer and use it in GitHub Desktop.
PPPoE Multiwan
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dial | |
pppoecd vlan2 -u $user -p $password # wan1 | |
pppoecd vlan2 -u $user -p $password # wan2 | |
# Handle outgoing packet | |
# Make "ip route" contains a default route like this | |
# "ip route" final state | |
#default | |
# nexthop via $wan1_ip dev $wan1_dev weight 1 # such as 202.106.0.24 ppp0 | |
# nexthop via $wan2_ip dev $wan2_dev weight 1 | |
# action | |
ip route replace default scope global equalize nexthop via $wan1_gw dev $wan1_dev weight 1 nexthop via $wan2_gw dev $wan2_dev weight 1 | |
# Handle incoming packet | |
# Make "ip rule" contains rule to dispatch incoming packet to correct routing table | |
# "ip rule" final state | |
# 0: from all lookup local | |
# 50: from $wan1_ip lookup $wan1_rt #50, 100, 150, 200 is just a number to ensure order | |
# 100: from $wan2_ip lookup $wan2_rt | |
# 32766: from all lookup main | |
# 32767: from all lookup default | |
# action | |
ip rule flush | |
ip rule add lookup main prio 32766 | |
ip rule add lookup default prio 32767 | |
ip rule add from $wan1_ip table 50 prio 50 | |
ip rule add from $wan2_ip table 100 prio 100 | |
# Make "ip route show table $wan1_rt" contains correct routes | |
# $wan1_range dev pppoe-wan scope link src $wan1_ip #such as 202.106.0.0/24 for 202.106.0.20 | |
# 127.0.0.0/8 dev lo scope link | |
# default via $wan1_gateway dev $wan1_dev #such as 202.106.0.1 for 202.106.0.20 | |
ip route add $wan1_range dev $wan1_dev src $wan1_ip table 50 | |
ip route add "127.0.0.0/8" dev "lo" table 50 | |
ip route add default via $wan1_gw table 50 | |
# Setup NAT from LAN to WAN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment