Hopefully this is an easy one to answer, might be harder to change
I have wlan0 (client mode) and eth0.2 both connected to the same network
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.50.1 0.0.0.0 UG 0 0 0 wlan0
10.244.0.0 * 255.255.0.0 U 0 0 0 zt0
192.168.8.0 * 255.255.255.0 U 0 0 0 br-lan
192.168.50.0 * 255.255.255.0 U 0 0 0 eth0.2
192.168.50.0 * 255.255.255.0 U 0 0 0 wlan0
192.168.50.1 * 255.255.255.255 UH 0 0 0 wlan0
On bootup, wlan0 always becomes the default gateway route-even if eth0.2 is connected.I would have thought that good old Ethernet would always be default (because wired is better than wireless?) Is this a design thing ?
I ask as I would like the eth0.2 to be the default route at boot-I have been playing about with
ip route del and add -but just wanted to ask if there is a "deep" command that will always prefer Ethernet as the default route.
There is no logic which decides default route based on medium. There's two possibilities:
set option defaultroute 0 on the wlan interface to suppress installing a defaultroute while still doing dhcp
set option metric 10 to assign a higher metric to the wifi default route which should cause the ethernet default route to be preferred
I tried the higher metric, which works-will try the other one. Just wanted to see if I could save myself some work
I managed to find a way-might be a bit cack-handed but works for me:
#change default route on boot up (using /etc/init.d/rc.local)
ip route change default via 192.168.50.1 dev eth0.2
(change 192.168.50.1 to your default gateway)
Use the following script to sense if the WAN connection has gone down (will be eth0.2 by default because of step 1-put it in as a cronjob/under scheduled tasks in Luci)
root@Nexx-LEDE:~# cat /etc/check_internet.sh
# Checks if the connection to the Internet is up. If not, it tries to restart all interfaces. If that fails, then reboot.
if ping -c 3 bbc.co.uk > /dev/null
echo check WAN is a sucesss > /dev/null
#Moves onto 2nd part, to try for a 2nd time!
if ping -c 3 www.google.com > /dev/null
echo nothing > /dev/null
date >> /etc/reboot.log
There seems to be a bonus point in that when the eth0.2 comes back up/is reconnected, the default route swaps back to eth0.2. It does for me when you disconnected it physically anyway.