Skip to content

Instantly share code, notes, and snippets.

@ya-pulser
Created April 5, 2012 21:47
Show Gist options
  • Save ya-pulser/2314446 to your computer and use it in GitHub Desktop.
Save ya-pulser/2314446 to your computer and use it in GitHub Desktop.
Configuration files for dual wan by openwrt at tp-link wr1043nd using adsl and docsis modems with dhcp settings
#!/bin/sh
IF_LAN=192.168.1.0/24
MDM_IP=192.168.100.1
ALIAS_NAME=eth0.2:1
ALIAS_IP=192.168.100.8
ifconfig $ALIAS_NAME add $ALIAS_IP
iptables -t nat -I POSTROUTING -o $ALIAS_NAME -s $IF_LAN -d $MDM_IP -j SNAT --to-source $ALIAS_IP
config 'multiwan' 'config'
option 'default_route' 'balancer'
option 'debug' '1'
config 'interface' 'wan'
option 'health_interval' '10'
option 'health_fail_retries' '3'
option 'health_recovery_retries' '5'
option 'failover_to' 'wan2'
option 'dns' 'auto'
option 'weight' '8'
option 'icmp_hosts' '192.168.15.XXX'
option 'timeout' '3'
config 'interface' 'wan2'
option 'health_interval' '10'
option 'health_fail_retries' '3'
option 'health_recovery_retries' '5'
option 'dns' 'auto'
option 'failover_to' 'wan'
option 'weight' '2'
option 'icmp_hosts' '212.48.XXX.XXX'
option 'timeout' '3'
config 'interface' 'loopback'
option 'ifname' 'lo'
option 'proto' 'static'
option 'ipaddr' '127.0.0.1'
option 'netmask' '255.0.0.0'
config 'interface' 'lan'
option 'ifname' 'eth0.1'
option 'type' 'bridge'
option 'proto' 'static'
option 'ipaddr' '192.168.1.1'
option 'netmask' '255.255.255.0'
config 'interface' 'wan'
option 'ifname' 'eth0.2'
option 'proto' 'dhcp'
option 'macaddr' 'XX:XX:XX:XX:XX:XX'
option 'defaultroute' '0'
config 'interface' 'wan2'
option 'ifname' 'eth0.3'
option 'proto' 'dhcp'
option 'macaddr' 'YY:YY:YY:YY:YY:YY'
config 'switch'
option 'name' 'rtl8366rb'
option 'reset' '1'
option 'enable_vlan' '1'
config 'switch_vlan'
option 'device' 'rtl8366rb'
option 'vlan' '1'
option 'ports' '1 2 3 5t'
config 'switch_vlan'
option 'device' 'rtl8366rb'
option 'vlan' '2'
option 'ports' '0 5t'
config 'switch_vlan'
option 'device' 'rtl8366rb'
option 'vlan' '3'
option 'ports' '4 5t'
root@OpenWrt:/etc/config# ping -I eth0.2 mail.ru
PING mail.ru (94.100.191.204): 56 data bytes
64 bytes from 94.100.191.204: seq=0 ttl=57 time=19.398 ms
64 bytes from 94.100.191.204: seq=1 ttl=57 time=17.016 ms
root@OpenWrt:/etc/config# ping -I eth0.3 mail.ru
PING mail.ru (94.100.191.204): 56 data bytes
64 bytes from 94.100.191.204: seq=0 ttl=56 time=15.049 ms
64 bytes from 94.100.191.204: seq=1 ttl=56 time=15.107 ms
root@OpenWrt:/etc/config# ip rule list
0: from all lookup local
9: from all fwmark 0x1 lookup LoadBalancer
10: from 10.224.XXX.XXX lookup MWAN1
11: from all fwmark 0x10 lookup MWAN1
20: from 192.168.12.101 lookup MWAN2
21: from all fwmark 0x20 lookup MWAN2
32766: from all lookup main
32767: from all lookup default
root@OpenWrt:/etc/config# ip route show table LoadBalancer
192.168.1.0/24 dev br-lan proto kernel scope link src 192.168.1.1
192.168.12.0/24 dev eth0.3 proto kernel scope link src 192.168.12.101
10.224.0.0/16 dev eth0.2 proto kernel scope link src 10.224.XXX.XXX
default proto static
nexthop via 10.224.0.1 dev eth0.2 weight 8
nexthop via 192.168.12.1 dev eth0.3 weight 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment