I have a USB wireless adapter which is eth1
. When it is plugged in it automatically gets an IP address of 192.168.8.100/24 and routes automatically added:
ip a
output:
39: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 0c:5b:8f:27:9a:64 brd ff:ff:ff:ff:ff:ff
inet 192.168.8.100/24 brd 192.168.8.255 scope global dynamic noprefixroute eth1
valid_lft 85920sec preferred_lft 85920sec
inet6 fe80::640:311a:de17:1163/64 scope link noprefixroute
valid_lft forever preferred_lft forever
ip route
output:
default via 192.168.8.1 dev eth1 proto dhcp metric 100
192.168.8.0/24 dev eth1 proto kernel scope link src 192.168.8.100 metric 100
The Internet is accessible, but if I change the IP address to 192.168.2.100/24 and add routes which are identical to the ones added, but with the new IP address and a higher metric, it doesn't work:
ip address del 192.168.8.100/24 dev eth1
ip address add 192.168.2.100/24 dev eth1
ip route add default via 192.168.2.1 dev eth1 proto static metric 99
So now the interface and routes look like this:
ip a
output:
39: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 0c:5b:8f:27:9a:64 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.100/24 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::640:311a:de17:1163/64 scope link noprefixroute
valid_lft forever preferred_lft forever
ip route
output:
default via 192.168.2.1 dev eth1 proto static metric 99
default via 192.168.8.1 dev eth1 proto dhcp metric 100
192.168.2.0/24 dev eth1 proto kernel scope link src 192.168.2.100
192.168.8.0/24 dev eth1 proto kernel scope link src 192.168.8.100 metric 100
Why does it not work?