Back to TILs

The network ip command

Date: 2022-09-19Last modified: 2023-02-17

Route

$ ip route
default via 192.168.15.1 dev wlp3s0 proto dhcp metric 600 

10.181.29.0/24   dev lxdbr0  proto kernel scope link src 10.181.29.1   linkdown 
172.17.0.0/16    dev docker0 proto kernel scope link src 172.17.0.1    linkdown 
192.168.15.0/24  dev wlp3s0  proto kernel scope link src 192.168.15.19 metric 600 
192.168.122.0/24 dev virbr0  proto kernel scope link src 192.168.122.1 linkdown 
DESTINATION     |INTERFACE  |PROTOCOL    |          |SOURCE           |

After launching 5 lxc containers we can realize that each one use an specific virtual interface.

$ ip route
default dev vethb1efb2e9 scope link 
default via 192.168.15.1 dev wlp3s0 proto dhcp metric 600 
10.181.29.0/24   dev lxdbr0 proto kernel scope link src 10.181.29.1 
169.254.0.0/16   dev vethb1efb2e9 proto kernel scope link src 169.254.249.217 
169.254.0.0/16   dev vetha30d7f12 proto kernel scope link src 169.254.153.8 
169.254.0.0/16   dev veth21ef1dfb proto kernel scope link src 169.254.28.175 
169.254.0.0/16   dev vethcfed8118 proto kernel scope link src 169.254.129.246 
169.254.0.0/16   dev vethdf8caaa2 proto kernel scope link src 169.254.206.4 
172.17.0.0/16    dev docker0      proto kernel scope link src 172.17.0.1 linkdown 
192.168.15.0/24  dev wlp3s0       proto kernel scope link src 192.168.15.19 metric 600 
192.168.122.0/24 dev virbr0       proto kernel scope link src 192.168.122.1 linkdown

After reconfiguring lxc bridge lxdbr0 to use the address 10.11.12.254 we get and inconsistent routing table.

$ ip route 
default dev veth36479aca scope link 
default via 192.168.15.1 dev wlp3s0 proto dhcp metric 600 
10.11.12.0/24    dev lxdbr0 proto kernel scope link src 10.11.12.254 
169.254.0.0/16   dev veth36479aca proto kernel scope link src 169.254.129.244 
169.254.0.0/16   dev veth53f1f182 proto kernel scope link src 169.254.80.31 
169.254.0.0/16   dev vethe35f1309 proto kernel scope link src 169.254.67.125 
169.254.0.0/16   dev veth252db3c5 proto kernel scope link src 169.254.17.212 
169.254.0.0/16   dev vethd2deb052 proto kernel scope link src 169.254.199.118 
172.17.0.0/16    dev docker0      proto kernel scope link src 172.17.0.1 linkdown 
192.168.15.0/24  dev wlp3s0       proto kernel scope link src 192.168.15.19 metric 600 
192.168.122.0/24 dev virbr0       proto kernel scope link src 192.168.122.1 linkdown 

Another problem is the default gateway was replaced by a virtual interface and my host can’t resolve any internet address. To solve this issue I set the correct gateway again.

ip route del default
route add default gw 192.168.15.1 dev wlp3s0

Then setting the containers to use the bridge

$ ip route
default via 192.168.15.1 dev wlp3s0 
default via 192.168.15.1 dev wlp3s0 proto dhcp metric 600 
10.11.12.0/24 dev lxdbr0 proto kernel scope link src 10.11.12.254 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
192.168.15.0/24 dev wlp3s0 proto kernel scope link src 192.168.15.19 metric 600 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown 

References