1

I want to remove a default route from my Raspberry Pi running Raspbian.

This is what I get from route -n:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.178.1   0.0.0.0         UG    203    0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     204    0        0 docker0
169.254.0.0     0.0.0.0         255.255.0.0     U     206    0        0 veth07ba603
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.178.0   0.0.0.0         255.255.255.0   U     203    0        0 eth1

I tried the following commands to remove the gateway:

ip route del default via 192.168.178.1 dev eth1
route del default gw  192.168.178.1
route del default gw  192.168.178.1 dev eth1
route del -net 0.0.0.0 gw 192.168.178.1 netmask 0.0.0.0 dev eth1
ip route del 0.0.0.0/0

None of them works.

If I run route -n again the route is still there and I can still reach the internet.

Syslog looks fine too:

Dec  3 02:42:21 pi dhcpcd[474]: eth1: deleted default route via 192.168.178.1

Upadte:

I figured out that the issue only appears if I run a docker container, e.g:

docker run --name 'foo' -itd alpine /bin/sh

If the container is turned off, I can delete the gateway. But for some reason docker re-creates the default gateway if I start the container with docker start foo. If the container is running, I cannot delete the gateway at all (see above).

Does anyone know what's happening here? How can I run the container without the default gateway? The Pi should not have an internet connection.

11
  • It looks like you have the correct syntax. What output are you getting from these commands? And what other routes are in your route table? – igal Dec 2 '17 at 23:08
  • The commands return nothing, like as if they were successful. I updated the table. – Rotareti Dec 2 '17 at 23:13
  • Weird. How did you add the default route to begin with? – igal Dec 2 '17 at 23:16
  • route add default gw 192.178.168.1 – Rotareti Dec 2 '17 at 23:17
  • My next question was going to be if you have Network Manager running on this system or if this route was getting set in some configuration file, but if you're setting it manually then I'm pretty confused by this situation. – igal Dec 2 '17 at 23:25
1

The solution was to assign a static ip to the Pi by adding the following lines to /etc/dhcpcd.conf:

interface eth1
static ip_address=192.168.178.10

I can now add and del the default gateway like expected, no matter if the docker container is running or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.