onemarcfifty / openvpn-bonding

bond multiple tap interfaces over openvpn
GNU General Public License v3.0
153 stars 52 forks source link

openwrt-client: one of the routing tables is not created #15

Open mafischer opened 2 years ago

mafischer commented 2 years ago

./startbond.sh:

2022-05-18 07:34:11 TUN/TAP device tap1 opened
2022-05-18 07:34:11 Persist state set to: ON
2022-05-18 07:34:11 TUN/TAP device tap2 opened
2022-05-18 07:34:11 Persist state set to: ON
###########################################
adding routing table vpn1
Tunnel Interface 1 is eth0.2
TunnelInterfaceIP 192.168.1.20
TunnelInterfaceGW 192.168.1.1
###########################################
adding routing table vpn2
Tunnel Interface 2 is eth3
TunnelInterfaceIP 172.20.10.5
TunnelInterfaceGW 
ip: an inet address is expected rather than "dev"
###########################################

In this case, TunnelInterfaceGW is an empty string.

digging into the script a bit, it seems as though there is only one default route prior to running the script: ip route:

default via 192.168.1.1 dev eth0.2  src 192.168.1.20 
172.20.10.0/28 dev eth3 scope link  src 172.20.10.5 
192.168.1.0/24 dev eth0.2 scope link  src 192.168.1.20 
192.168.5.0/24 dev br-lan scope link  src 192.168.5.1 

this causes ip route add default via $tunnelInterfaceGW dev ${tunnelInterface} table "vpn$i" to error out and one of the IP tables is not created:

ip: an inet address is expected rather than "dev"

even after manually running the IP route add command, the routes are not set up as expected.

RydjGit commented 1 year ago

I encoutered this problem and I modified the line in startbonding.sh : tunnelInterfaceGW=$(ip r | grep 'default.*'${tunnelInterface} | awk '{print $3}') to tunnelInterfaceGW=$(udhcpc -n -q -i ${tunnelInterface} | grep routers | awk '{print $5}') please note the following: 1- you need to keep only "bond0 " as the ONLY default interface #this will not work: default via 192.168.1.1 dev eth0.2 src 192.168.1.20 default via 10.8.0.253 dev bond0 metric 1 172.20.10.0/28 dev eth3 scope link src 172.20.10.5 192.168.1.0/24 dev eth0.2 scope link src 192.168.1.20 192.168.5.0/24 dev br-lan scope link src 192.168.5.1

2- add "bond0"to the firewall wan zone by editing the zone.