# Default gateway not added



## tommiie (Oct 20, 2020)

I have a Digital Ocean droplet running FreeBSD 12.1-p10 and I am experiencing slow responses to pkg(1) commands. In order to investigate I tried disabling IPv6 (without much success) and did a

```
service netif restart
```
after which my droplet was unavailable. Accessing it via the console showed me that the default gateway was missing, which I added back with

```
route add default 104.248.80.1
```

My /etc/rc.conf file contains the line

```
defaultrouter="104.248.80.1"
```

How can I troubleshoot why the default gateway is not added when I restart networking? Also, why should I define a default route in /etc/rc.conf when the interface is configured to use DHCP?

```
ifconfig_vtnet0="DHCP"
```


----------



## SirDice (Oct 20, 2020)

tommiie said:


> How can I troubleshoot why the default gateway is not added when I restart networking?


Because you need to restart routing (`service routing restart`) _after_ you restarted your network interfaces.



tommiie said:


> Also, why should I define a default route in /etc/rc.conf when the interface is configured to use DHCP?


Normally you don't, that's correct. But if I recall correctly some providers will give a default gateway that's _outside_ your network segment. And FreeBSD refuses to apply it if that's the case.


----------



## tommiie (Oct 20, 2020)

So I would have to do `service netif restart && service routing restart` to make sure I regain connectivity? If I remember correctly with Linux it is just one service: `service networking restart`. Of course BSD is not Linux but this might explain why I missed the second service.


----------



## SirDice (Oct 20, 2020)

tommiie said:


> So I would have to do  service netif restart && service routing restart to make sure I regain connectivity?


That is correct. The reason is that stopping `netif` causes all associated routes referring to those interfaces to be automatically removed too. That's why you need to restart the routing service (which applies all routing, the default and additional static routes if you have them).


----------

