eth0
has a static IP set in /etc/interfaces
wlan0
gets it IP dynamically
How can I change my routing table and where would I put the command to always make wlan0 the default route so internet access will work? Right now I can ssh into the box using either eth0 or wlan0 but internet access gets routed through eth0 always which does not work.
Also, are auto and allow-hotplug contradictory options?
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.20.1 0.0.0.0 UG 0 0 0 eth0
192.168.10.0 * 255.255.255.0 U 0 0 0 wlan0
192.168.20.0 * 255.255.255.0 U 0 0 0 eth0
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.20.2
netmask 255.255.255.0
gateway 192.168.20.1
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Best Answer
To defined a preferred interface, use the metric directive in the interfaces. The higher the value, the lower the priority.
Then restart the networking service with:
From Debian Reference - Chapter 5. Network setup