Dual WAN with WRT 1200AC V2

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.)
Author Message
tuxgasy
DD-WRT Novice


Joined: 21 Jun 2019
Posts: 7

PostPosted: Sat Jun 22, 2019 10:24    Post subject: Dual WAN with WRT 1200AC V2 Reply with quote
Hi all !

I try to have a dual wan with my router WTR 1200AC (V2), running with v3.0-r40048 build.

I followed the wiki Dual WAN with failover but I did not succeed.

When I run manually the script wan2up.startup, I have the message :

Quote:

ifconfig: ioctl 0x8913 failed: No such device


I followed also the wiki Dual WAN with one as standby backup, with the startup script, I have the same message :

Quote:

ifconfig: SIOCSIFADDR: No such device


With ifconfig, I have this result

Code:

root@home:~# ifconfig
ath0      Link encap:Ethernet  HWaddr 24:F5:A2:A1:33:A8 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:294938 errors:0 dropped:0 overruns:0 frame:0
          TX packets:987781 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:36915895 (35.2 MiB)  TX bytes:1333237106 (1.2 GiB)

ath1      Link encap:Ethernet  HWaddr 24:F5:A2:A1:33:A9 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:142745 errors:0 dropped:0 overruns:0 frame:0
          TX packets:478304 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:21944223 (20.9 MiB)  TX bytes:618897699 (590.2 MiB)

ath1.1    Link encap:Ethernet  HWaddr 26:F5:A2:A1:33:A9 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9362 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:1449662 (1.3 MiB)

br0       Link encap:Ethernet  HWaddr 24:F5:A2:A1:33:A7 
          inet addr:192.168.10.1  Bcast:192.168.10.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3141437 errors:0 dropped:626 overruns:0 frame:0
          TX packets:3254703 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2600313581 (2.4 GiB)  TX bytes:2118384589 (1.9 GiB)

eth0      Link encap:Ethernet  HWaddr 24:F5:A2:A1:33:A7 
          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3293814 errors:0 dropped:3543 overruns:0 frame:0
          TX packets:3064873 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:532
          RX bytes:2115370911 (1.9 GiB)  TX bytes:2637284119 (2.4 GiB)
          Interrupt:36

eth1      Link encap:Ethernet  HWaddr 24:F5:A2:A1:33:A7 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2876847 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1900972 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:532
          RX bytes:2595365933 (2.4 GiB)  TX bytes:204800469 (195.3 MiB)
          Interrupt:37

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING MULTICAST  MTU:65536  Metric:1
          RX packets:106 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:10386 (10.1 KiB)  TX bytes:10386 (10.1 KiB)


Thanks for all help.
(sorry for my bad english)
Sponsor
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 5171
Location: Akershus, Norway

PostPosted: Sat Jun 22, 2019 13:05    Post subject: Reply with quote
eth0 is your WAN.

VLAN have to be created with SWCONFIG.
tuxgasy
DD-WRT Novice


Joined: 21 Jun 2019
Posts: 7

PostPosted: Sat Jun 22, 2019 14:27    Post subject: Reply with quote
Per Yngve Berg wrote:
eth0 is your WAN.

VLAN have to be created with SWCONFIG.


I found this post. So I try all commands (I'm not sure I understand everything) :

Quote:

swconfig dev switch0 set reset 1
swconfig dev switch0 set enable_vlan 1
swconfig dev switch0 vlan 1 set ports "5t 0 1 2 3"
swconfig dev switch0 vlan 2 set ports "5t 4"
swconfig dev switch0 set apply
ifconfig eth0 up
ifconfig eth1 up
vconfig set_name_type VLAN_PLUS_VID_NO_PAD
vconfig add eth0 1
vconfig add eth0 2


After that, I add and run all scripts in https://wiki.dd-wrt.com/wiki/index.php/Dual_WAN_with_failover but I do not have any connection anymore.
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 5171
Location: Akershus, Norway

PostPosted: Sat Jun 22, 2019 15:04    Post subject: Reply with quote
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=317199
tuxgasy
DD-WRT Novice


Joined: 21 Jun 2019
Posts: 7

PostPosted: Mon Jul 01, 2019 13:46    Post subject: Reply with quote
Per Yngve Berg wrote:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=317199


Thanks for this link.

After several tests, I found a solution.

Here are my scripts based on the other scripts found on the wiki and the forum.

/jffs/etc/config/failover.startup
Code:

#!/bin/sh

INTERVAL=10
PACKETS=1
USINGWAN=0

WAN1_IFNAME=vlan1
WAN1_IPADDR=192.168.1.10
WAN1_GATEWAY=192.168.1.1
WAN1_NETMASK=255.255.255.0

WAN2_IFNAME=vlan2
WAN2_IPADDR=192.168.2.10
WAN2_GATEWAY=192.168.2.254
WAN2_NETMASK=255.255.255.0

LAN_IFNAME=vlan3
LAN_IPADDR=192.168.10.1
LAN_GATEWAY=192.168.10.1
LAN_NETMASK=255.255.255.0

# Set nvram values
nvram set wan_ifname=$WAN1_IFNAME
nvram set wan_ipaddr=$WAN1_IPADDR
nvram set wan_gateway=$WAN1_GATEWAY
nvram set wan_netmask=$WAN1_NETMASK
nvram set wan2_ifname=$WAN2_IFNAME
nvram set wan2_ipaddr=$WAN2_IPADDR
nvram set wan2_gateway=$WAN2_GATEWAY
nvram set wan2_netmask=$WAN2_NETMASK
nvram commit

# Source https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1003853#1003853
# and https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=317199
swconfig dev switch0 set reset 1
swconfig dev switch0 set enable_vlan 1
swconfig dev switch0 vlan 1 set ports "5t 4"
swconfig dev switch0 vlan 2 set ports "5t 3"
swconfig dev switch0 vlan 3 set ports "6t 0 1 2"
swconfig dev switch0 set apply
vconfig set_name_type VLAN_PLUS_VID_NO_PAD
vconfig add eth0 1
vconfig add eth0 2
vconfig add eth1 3

brctl addif br0 $LAN_IFNAME
brctl delif br0 eth1
#(stopservice wan;startservice wan) 2>&1 | logger -t startup[$$]
#brctl delif br0 eth1

ifconfig $WAN1_IFNAME up $WAN1_IPADDR netmask $WAN1_NETMASK
ifconfig $WAN2_IFNAME up $WAN2_IPADDR netmask $WAN2_NETMASK
ifconfig $LAN_IFNAME up $LAN_IPADDR netmask $LAN_NETMASK

iptables -t nat -A POSTROUTING -o $WAN1_IFNAME -j MASQUERADE
iptables -t nat -A POSTROUTING -o $WAN2_IFNAME -j MASQUERADE

# Failover
logger "failover : active WAN1"
/jffs/etc/config/wan1.up

while sleep $INTERVAL
do
    # Try to figure out the current route
    TARGET=`ip route | awk '/default via/ {print $3}'`

    # Set the variable, so let the script now which connection is it dealing with
    if [ "$WAN1_GATEWAY" = "$TARGET" ]; then
        USINGWAN=1
    elif [ "$WAN2_GATEWAY" = "$TARGET" ]; then
        USINGWAN=2
    fi

    # We'll ping as many times the $PACKETS variable tells, and test if we have connection:
    RET=`ping -c $PACKETS $TARGET 2>/dev/null | awk '/packets received/ {print $4}'`

    # If we don't have connection, change the active WAN port (If there is any loss with multiple packets, it should change either)
    if [ "$RET" -ne "$PACKETS" ]; then
        if [ "$USINGWAN" = "1" ]; then
            logger "failover : change active WAN port to 2"
            /jffs/etc/config/wan2.up
        else
            logger "failover : change active WAN port to 1"
            /jffs/etc/config/wan1.up
        fi
    fi

    # Automatic switching back to WAN1 once it becomes available
    if [ "$USINGWAN" = "2" ]; then
        RET=`ping -c $PACKETS $WAN1_GATEWAY 2>/dev/null | awk '/packets received/ {print $4}'`

        if [ "$RET" -eq "$PACKETS" ]; then
            logger "failover : switch back to WAN1"
            /jffs/etc/config/wan1.up
        fi
    fi
done


/jffs/etc/config/wan1.up
Code:

#!/bin/sh

# WAN1
DEV=`nvram get wan_ifname`
GATEWAY=`nvram get wan_gateway`
DNS1=192.168.1.1

ip route delete default
ip route add default via $GATEWAY dev $DEV

echo "nameserver $DNS1" >/tmp/resolv.dnsmasq

pr="$(ps|grep dnsmasq|grep -v grep|awk '{print $1}')"
kill -9 $pr

dnsmasq --conf-file=/tmp/dnsmasq.conf

# https://wiki.dd-wrt.com/wiki/index.php/Linksys_WRT1900AC#LEDs_and_GPIO_pins
# LED white internet
gpio disable 7
gpio enable 6


/jffs/etc/config/wan2.up
Code:

#!/bin/sh

# WAN2
DEV=`nvram get wan2_ifname`
GATEWAY=`nvram get wan2_gateway`
DNS1=212.27.40.241
DNS2=212.27.40.240

ip route delete default
ip route add default via $GATEWAY dev $DEV

echo "nameserver $DNS1" >/tmp/resolv.dnsmasq
echo "nameserver $DNS2" >>/tmp/resolv.dnsmasq

pr="$(ps|grep dnsmasq|grep -v grep|awk '{print $1}')"
kill -9 $pr

dnsmasq --conf-file=/tmp/dnsmasq.conf

# https://wiki.dd-wrt.com/wiki/index.php/Linksys_WRT1900AC#LEDs_and_GPIO_pins
# LED amber internet
gpio disable 6
gpio enable 7


I can not explain everything but it works.

My problem now is that Port Forwarding does not work. An idea ?
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.) All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum