Default gateway not added

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
Code:
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
Code:
route add default 104.248.80.1

My /etc/rc.conf file contains the line
Code:
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?
Code:
ifconfig_vtnet0="DHCP"
 
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.

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.
 
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.
 
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).
 
  • Like
Reactions: a6h
Back
Top