In my Linux server (4.9.9_1 kernel, x86_64) enp5s0
has a static ip 192.168.1.30
and enp9s0
is given an address via dhcpcd
.
# ip route ls
default via 192.168.1.1 dev enp5s0 src 192.168.1.30 metric 202
default via 39.53.131.254 dev enp9s0 src 39.53.131.237 metric 203
39.53.130.0/23 dev enp9s0 proto kernel scope link src 39.53.131.237 metric 203
192.168.1.0/24 dev enp5s0 proto kernel scope link src 192.168.1.30 metric 202
The first thing I don't understand is why does the system set two default routes, although preference is given to one based on metric
.
What I want to do is to delete the second default route via 39.53....
, to add another routing table, set ip rule
for that to add an identical default route but for the new routing table.
When:
# ip route del default via 39.53.131.254 dev enp9s0
# echo $?
0
The routing table doesn't seem to have changed, though:
# ip route l
default via 192.168.1.1 dev enp5s0 src 192.168.1.30 metric 202
default via 39.53.131.254 dev enp9s0 src 39.53.131.237 metric 203
39.53.130.0/23 dev enp9s0 proto kernel scope link src 39.53.131.237 metric 203
192.168.1.0/24 dev enp5s0 proto kernel scope link src 192.168.1.30 metric 202
After a ip route flush cache
:
# ip route show cache
shows nothing.
What should I do?
After help on Freenode IRC ##linux channel. As
dhcpcd
was responsible for the IP address ofenp9s0
, the way to clear the routes passing through the interface is to flush the device:ip addr flush dev enp9s0
.Interestingly, but many years after, I bumped into similar situation n Debian Buster.
There where constantly something messing up with my default routes, and the reason was systemd connman.service.
Finally I found logs:
and thats it, internet is gone.
Fixed by totally removing service: