Debian – NetworkManager changes default routing policy

debiannetworkmanagerrouting

I have a machine with a built-in NIC (eth0), which serves as a DHCP server for a Raspberry Pi. I also have a USB 3G modem, which shows up as ethernet device eth1. eth0 has the static ip 192.168.100.1 in /etc/network/interfaces.
When I connect the Pi to the server, /var/log/syslog shows

NetworkManager[2366]: <info> Policy set 'Ifupdown (eth0)' (eth0) as default for IPv4 routing and DNS.

and after, ip route show gives

default via 192.168.1.100 dev eth0  proto static

I then need to manually

ip route delete default
ip route add default via 192.168.1.1

to get it to connect to the internet via the 3G modem again.
I am using CrunchBang Linux, based on Debian 7 wheezy, on the server, and the latest Raspbian on the Pi.

How can I choose the default pathway for NetworkManager to prefer?

Edit: here's my /etc/network/interfaces:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

allow-hotplug eth0
auto eth0
iface eth0 inet static
    address 192.168.100.1
    netmask 255.255.255.0

allow-hotplug eth1
auto eth1
iface eth1 inet dhcp

Note that I've changed /etc/NetworkManager/NetworkManager.conf to have

[ifupdown]
managed=true

because I want to be able to disconnect eth1, the 3G Modem, using nm-applet.
Here's /etc/NetworkManager/NetworkManager.conf:

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=true

Best Answer

  • If using GUI, try checking the "Use only for resources on this connection" checkbox.
  • If using the config files (like you are :) ), in the [ipv4] section add never-default=true .
  • If using commandline tools, run sudo nmcli con mod "connection name" ipv4.never-default yes

This way you will be able to delete the default route going in the tunnel & add your own.

Related Question