Hello,
What it the right setup to switch to 3G when wan is down and switch back to wan when wan is up?
At the beginning:
root@openwrt:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.64.64.64 0.0.0.0 255.255.255.255 UH 0 0 0 3gg
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
192.168.30.0 0.0.0.0 255.255.255.0 U 10 0 0 eth1
0.0.0.0 192.168.30.1 0.0.0.0 UG 10 0 0 eth1
0.0.0.0 10.64.64.64 0.0.0.0 UG 30 0 0 3gg
64 bytes from 8.8.8.8: seq=109 ttl=47 time=25.610 ms
64 bytes from 8.8.8.8: seq=110 ttl=47 time=25.819 ms
64 bytes from 8.8.8.8: seq=111 ttl=47 time=25.669 ms
64 bytes from 8.8.8.8: seq=112 ttl=47 time=25.623 ms
64 bytes from 8.8.8.8: seq=113 ttl=47 time=25.315 ms
64 bytes from 8.8.8.8: seq=114 ttl=47 time=25.166 ms
After ifconfig eth1 down, it switches to 3G:
64 bytes from 8.8.8.8: seq=150 ttl=44 time=70.635 ms
64 bytes from 8.8.8.8: seq=151 ttl=44 time=70.490 ms
64 bytes from 8.8.8.8: seq=152 ttl=44 time=70.373 ms
64 bytes from 8.8.8.8: seq=153 ttl=44 time=70.270 ms
64 bytes from 8.8.8.8: seq=154 ttl=44 time=70.151 ms
64 bytes from 8.8.8.8: seq=155 ttl=44 time=70.028 ms
root@openwrt:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.64.64.64 0.0.0.0 255.255.255.255 UH 0 0 0 3gg
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
0.0.0.0 10.64.64.64 0.0.0.0 UG 30 0 0 3gg
After ifconfig eth1 up strange situation happens:
root@openwrt:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.64.64.64 0.0.0.0 255.255.255.255 UH 0 0 0 3gg
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
192.168.30.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
0.0.0.0 10.64.64.64 0.0.0.0 UG 30 0 0 3gg
64 bytes from 8.8.8.8: seq=5 ttl=44 time=71.091 ms
64 bytes from 8.8.8.8: seq=6 ttl=44 time=70.959 ms
64 bytes from 8.8.8.8: seq=7 ttl=44 time=70.824 ms
64 bytes from 8.8.8.8: seq=8 ttl=44 time=70.708 ms
64 bytes from 8.8.8.8: seq=9 ttl=44 time=70.582 ms
My configuration is:
Firewall default output policy (must be ACCEPT) :
ACCEPT
Output of "ip route show" :
10.64.64.64 dev 3gg proto kernel scope link src 188.196.84.26
192.168.1.0/24 dev br-lan proto kernel scope link src 192.168.1.1
192.168.30.0/24 dev eth1 proto static scope link metric 10
default via 192.168.30.1 dev eth1 proto static metric 10
default via 10.64.64.64 dev 3gg proto static metric 30
Output of "ip rule show" :
0: from all lookup local
1001: from all fwmark 0x100/0xff00 lookup 1001
1002: from all fwmark 0x200/0xff00 lookup 1002
1016: from all fwmark 0x1000/0xff00 lookup 1016
1017: from all fwmark 0x1100/0xff00 lookup 1017
1018: from all fwmark 0x1200/0xff00 lookup 1018
32766: from all lookup main
32767: from all lookup default
Output of "ip route list table 1001-1027" :
1001
default via 10.64.64.64 dev 3gg 1002
default via 192.168.30.1 dev eth1 1016
default via 192.168.30.1 dev eth1 metric 1 default via 10.64.64.64 dev 3gg metric 2 1017
default via 192.168.30.1 dev eth1 metric 1 1018
default via 10.64.64.64 dev 3gg metric 1
Output of "iptables -L -t mangle -v -n | awk '/mwan3/' RS=" :
Chain PREROUTING (policy ACCEPT 1171 packets, 460K bytes)
pkts bytes target prot opt in out source destination
44134 12M mwan3_pre all -- * * 0.0.0.0/0 0.0.0.0/0
Chain INPUT (policy ACCEPT 200 packets, 17294 bytes)
pkts bytes target prot opt in out source destination
13930 1280K mwan3_post all -- * * 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 138 packets, 49994 bytes)
pkts bytes target prot opt in out source destination
9754 2097K mwan3_pre all -- * * 0.0.0.0/0 0.0.0.0/0
Chain POSTROUTING (policy ACCEPT 1085 packets, 492K bytes)
pkts bytes target prot opt in out source destination
37863 12M mwan3_post all -- * * 0.0.0.0/0 0.0.0.0/0
Chain mwan3_default (1 references)
pkts bytes target prot opt in out source destination
14 1747 MARK all -- * * 0.0.0.0/0 224.0.0.0/3 mark match !0x8000/0x8000 MARK or 0x8000
0 0 MARK all -- * * 0.0.0.0/0 10.64.64.64 mark match !0x8000/0x8000 MARK or 0x8000
216 56243 MARK all -- * * 0.0.0.0/0 192.168.1.0/24 mark match !0x8000/0x8000 MARK or 0x8000
0 0 MARK all -- * * 0.0.0.0/0 192.168.30.0/24 mark match !0x8000/0x8000 MARK or 0x8000
Chain mwan3_post (2 references)
pkts bytes target prot opt in out source destination
521 251K MARK all -- * eth1 0.0.0.0/0 0.0.0.0/0 mark match !0x8000/0x8000 MARK xset 0x200/0xff00
3548 255K MARK all -- * 3gg 0.0.0.0/0 0.0.0.0/0 mark match !0x8000/0x8000 MARK xset 0x100/0xff00
27503 8669K MARK all -- * * 0.0.0.0/0 0.0.0.0/0 mark match 0x8000/0x8000 MARK and 0xffff7fff
51793 13M CONNMARK all -- * * 0.0.0.0/0 0.0.0.0/0 CONNMARK save mask 0xff00
Chain mwan3_pre (2 references)
pkts bytes target prot opt in out source destination
53888 14M CONNMARK all -- * * 0.0.0.0/0 0.0.0.0/0 CONNMARK restore mask 0xff00
540 201K MARK all -- eth1 * 0.0.0.0/0 0.0.0.0/0 MARK xset 0x8200/0xff00
837 72358 MARK all -- 3gg * 0.0.0.0/0 0.0.0.0/0 MARK xset 0x8100/0xff00
36034 7254K mwan3_default all -- * * 0.0.0.0/0 0.0.0.0/0 mark match !0x8000/0x8000
7090 520K mwan3_rules all -- * * 0.0.0.0/0 0.0.0.0/0 mark match 0x0/0xff00
Chain mwan3_rules (1 references)
pkts bytes target prot opt in out source destination
91 6317 MARK all -- * * 0.0.0.0/0 0.0.0.0/0 mark match 0x0/0xff00 MARK xset 0x1000/0xff00
Output of "ifconfig" :
3gg Link encap:Point-to-Point Protocol
inet addr:188.196.84.26 P-t-P:10.64.64.64 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:845 errors:0 dropped:0 overruns:0 frame:0
TX packets:3558 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:72510 (70.8 KiB) TX bytes:255119 (249.1 KiB)
br-lan Link encap:Ethernet HWaddr 00:D0:50:43:BF:C6
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::2d0:50ff:fe43:bfc6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:22550 errors:0 dropped:0 overruns:0 frame:0
TX packets:16874 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4937607 (4.7 MiB) TX bytes:7825113 (7.4 MiB)
eth0 Link encap:Ethernet HWaddr 00:D0:50:43:BF:C6
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:22605 errors:0 dropped:0 overruns:0 frame:0
TX packets:16836 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5623087 (5.3 MiB) TX bytes:7823261 (7.4 MiB)
Base address:0x6000
eth1 Link encap:Ethernet HWaddr 00:D0:50:43:BF:C7
inet addr:192.168.30.103 Bcast:192.168.30.255 Mask:255.255.255.0
inet6 addr: fe80::2d0:50ff:fe43:bfc7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:20259 errors:0 dropped:0 overruns:0 frame:0
TX packets:15199 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7150504 (6.8 MiB) TX bytes:4633305 (4.4 MiB)
Base address:0xe000
eth1.242 Link encap:Ethernet HWaddr 00:D0:50:43:BF:C7
inet6 addr: fe80::2d0:50ff:fe43:bfc7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:800 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:309512 (302.2 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3224 errors:0 dropped:0 overruns:0 frame:0
TX packets:3224 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:209362 (204.4 KiB) TX bytes:209362 (204.4 KiB)
Output of "cat /etc/config/mwan3" :
config rule 'wan_g3'
option dest_ip '0.0.0.0/0'
option use_policy 'wan_pri_3g_sec'
option proto 'all'
config interface '3g'
option enabled '1'
option reliability '1'
option count '1'
option timeout '2'
option interval '5'
list track_ip '8.8.8.8'
list track_ip '8.8.4.4'
option down '3'
option up '5'
config interface 'wan'
option enabled '1'
option reliability '1'
option count '1'
option timeout '2'
option interval '5'
list track_ip '8.8.8.8'
list track_ip '8.8.4.4'
option down '3'
option up '5'
config member 'wan_m1_w3'
option interface 'wan'
option metric '1'
option weight '2'
config member 'wan_m2_w3'
option interface 'wan'
option metric '2'
option weight '2'
config member '3g_m1_w2'
option interface '3g'
option metric '1'
option weight '3'
config member '3g_m2_w2'
option interface '3g'
option metric '2'
option weight '3'
config policy 'wan_pri_3g_sec'
list use_member 'wan_m1_w3'
list use_member '3g_m2_w2'
config policy 'wan_only'
list use_member 'wan_m1_w3'
config policy '3g_only'
list use_member '3g_m1_w2'
Output of "cat /etc/config/network" :
config switch 'eth0'
option enable '1'
config switch_vlan 'eth0_1'
option device 'eth0'
option vlan '1'
option ports '0 1 2 3 4'
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'
option type 'bridge'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
config interface 'mng'
option proto 'dhcp'
option ifname 'eth1.242'
config interface 'wan'
option _orig_ifname 'eth1.100'
option _orig_bridge 'false'
option ifname 'eth1'
option proto 'static'
option ipaddr '192.168.30.103'
option netmask '255.255.255.0'
option gateway '192.168.30.1'
option metric '10'
config route
option interface 'mng'
option target '172.28.2.49'
option gateway '192.168.242.1'
config route
option interface 'mng'
option target '172.18.48.19'
option gateway '192.168.242.1'
config interface '3g'
option ifname '3gg'
option device '/dev/ttyUSB2'
option service 'umts'
option proto '3g'
option apn 'AGD'
option pincode '1234'
option username 'user'
option password 'user'
option ctrldev '/dev/ttyUSB1'
option metric '30'