Ubuntu – Network manager no default route

network-managernetworkingrouting

This problem started about three weeks ago, apparently after an update.

When I connect to a new wifi network, I reach local connectivity only; my laptop connects and receives an IP address successfully (verified via syslog) but ping 8.8.8.8 returns connect: Network is unreachable.

The routing table always looks something like this:

Table de routage IP du noyau
Destination     Passerelle      Genmask         Indic Metric Ref    Use Iface
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlp2s0
192.168.2.0     0.0.0.0         255.255.255.0   U     600    0        0 wlp2s0

In particular, there is no default route specified. I think this is the problem. If I run the command

sudo route add default gw 192.168.2.1 wlp2s0

Then everything works; I can ping google.com, but network-manager still thinks I have only local connectivity.

If I use a static IP instead and specify 8.8.8.8 as a nameserver, everything works. If I use a static IP and do not specify 8.8.8.8 as a nameserver, I can ping 8.8.8.8 but not google.com.

How can I get network-manager to properly automatically assign a default route?

Best Answer

The issues is most probably related to the route configurations not being set in the wireless device NM configs. try to edit the file for your connection manually, you will find it here, vim /etc/NetworkManager/system-connections/YOUR_WIFI_NAME

under the ipv4 section add (while this should be the default): never-default=false

You also have to edit /etc/NetworkManager/NetworkManager.conf

[ifupdown]
managed=true

Also if you found that managed=true in the first place then that could be the issue for not automatically adding the routes, try to change it to false, and don't do the previous ipv4 step and then:

service network-manager restart

Related Question