5

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?

5 Answers 5

5

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

Or if you are using Debian 11+:

service NetworkManager restart

1
  • I had the same problem, just with my regular ethernet connection. I both had to set managed=true and add the corresponding entry never-default=false to /etc/NetworkManager/system-connections/eth0 to get a default route, I couldn't configure it with the GUI elements for some reason (I unchecked use connection only for resources on its network but to no avail).
    – hochl
    Commented Apr 3, 2020 at 9:49
1

I again ran into this problem. In the log files, I always could see that network manager only entered state CONNECTED_LOCAL. I tried fiddling with the never-default and managed settings, but nothing worked. I solved the problem after discovering what was missing with nmcli:

$ nmcli connection edit eth0
...
nmcli> print
...
ipv4.dns-options:                       --
ipv4.dns-priority:                      0
ipv4.addresses:                         192.168.223.9/24
ipv4.gateway:                           --
...

Obviously the gateway was missing. I added it like so:

nmcli> set ipv4.gateway 192.168.223.2
nmcli> save
Connection 'eth0' (...) successfully updated.

Now NetworkManager says it enters state CONNECTED_GLOBAL in the log files.

1

There were problems to connect to my WiFi network with Network Manager using postmarketOS on my Jolla smartphone but I found a solution that could help users of other Linux distributions also.

I had to install dhclient and replace dhcp=internal with dhcp=dhclient below [main] in /etc/NetworkManager/NetworkManager.conf. Then I had to restart Network Manager with the command sudo service networkmanager restart (solution based on https://bbs.archlinux.org/viewtopic.php?id=232833 / https://forum.salixos.org/viewtopic.php?f=30&t=7284).

Network Manager was then connected to the WiFi network but I could not ping an IP address like 1.1.1.1, there was no default route. To fix this issue, I had to execute this command: sudo dhclient wlan0.

1

Based on the answer from Waheed, I found that under

/etc/NetworkManager/system-connections/Wired\ connection\ 1.nmconnection

under [ipv4], there was an entry called ignore-auto-routes=true.

I found the meaning of ignore-auto-routes here and the text there seems to suggest that that probably is the cause.

While changing that file with an editor works, I in the end fixed it by opening the setting, Network, Wired, Settings, IPv4 and there under Routes 'Automatic' wasn't chosen. After I chose that the problem was solved. Unsure how it had gotten the wrong value. Wired network settings

0

You should have default route (0.0.0.0) information in your routing table or netstat -rn.

ip r output

netstat -rn output

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .