# NetworkManager overriding static IP...

## The_Great_Sephiroth

I have a strange issue in Gentoo that does not exist in Debian. If I set a static address on an interface in Gentoo, NM takes over once a user logs into the system and gets a new address from DHCP. How can I prevent this? We use NM for VPN so we do need it, but we do not want it overriding the system defaults.

----------

## charles17

 *The_Great_Sephiroth wrote:*   

> If I set a static address on an interface in Gentoo, 

 Has it been set manually or via dhcpcd-ui?

What does the /etc/dhcpcd.conf entry look like?

----------

## The_Great_Sephiroth

I set it in /etc/conf.d/net per the Gentoo guide. I then symlink /etc/init.d/net.lo to /etc/init.d/net.enp0s25. Upon boot, I have the correct address. Once I log into K, NM takes over and over-writes it.

----------

## charles17

For usage of NM in parallel with another network managers see the leading note in https://wiki.gentoo.org/wiki/Networkmanager.  Guess that might also refer to netifrc.

Have you tried using ip route?

----------

## The_Great_Sephiroth

Back again with this problem. I disabled everything else and made a system connection in NM, but I do not know how to tell NM to use the connection on boot. It seems dead set on using DHCP. There are no networking items in my runlevels EXCEPT NM. How do I tell NM to use said connection when it starts instead of using DHCP? This is driving me crazy! I cannot believe how hard it is to do such a trivial task here! We use NM for VPN connections so we NEED it, but it has zero support for anything but DHCP on boot? That is insane!

Also, if you can recommend something as simple to use as NM for the brainless ones that work here and do not understand the CLI, I may be open to change, but I cannot fathom how such a feature-rich app falls on its face when it comes to a static address on boot.

----------

## Fitzcarraldo

In the NetworkManager GUI front-end (plasma-nm or nm-applet, or whatever you are using), did you tick 'Automatically connect to this network when it is available' for the connection with a static IP address and also make sure no other connection has that option ticked? You can edit NetworkManager's system connections configuration file directly (it is in the directory /etc/NetworkManager/system-connections/) rather than doing it via the GUI, and change 'autoconnect=false' to 'autoconnect=true' (or add 'autoconnect=true' if the autoconnect option is not listed already in the file). Here is an example (addresses anonymised):

```
# cat /etc/NetworkManager/system-connections/Office\ Wired\ Network 

[connection]

id=Office Wired Network

uuid=xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxx

type=ethernet

autoconnect=true

permissions=user:fitzcarraldo:;

secondaries=

[ethernet]

mac-address=xx:xx:xx:xx:xx:xx

mac-address-blacklist=

[ipv4]

address1=xx.xx.xx.xxx/24,xx.xx.xx.x

dns=xxx.xx.xx.xx;xxx.xx.xx.xx;xxx.xx.xx.xx;xxx.xx.x.xx;

dns-search=

may-fail=false

method=manual

[ipv6]

dns-search=

method=ignore
```

----------

## The_Great_Sephiroth

I did, but when I edited the connections I do not remember seeing the "autoconnect" line. That is PROBABLY the issue. I will report back.

----------

## Fitzcarraldo

While you're at it, as NetworkManager manages everything it would be worth you double checking a few other things to make sure your installation is configured correctly to use NetworkManager.

You should not have any netifrc and DHCP services configured to run independently of NetworkManager (NetworkManager takes care of everything itself, launching the DHCP client you chose* as and when it needs to):

```
# rc-update show -v | grep dhcp

               dhcpcd |

                dhcpd |

# rc-update show -v | grep net

           net-online |

         net.enp4s0f1 |

               net.lo |

             netmount |      default
```

* In my case, I merged NetworkManager with the DHCP client USE flags "dhclient" and "-dhcpcd", i.e. I chose to make NetworkManager use dhclient rather than dhcpcd. I used to make NetworkManager use dhcpcd instead of dhclient ("-dhclient" and "dhcpcd"), but in the last few releases of NetworkManager I found that my laptop was not obtaining a lease, so I switched to dhclient. Actually, the NetworkManager developers favour dhclient over dhcpcd:

 *Dan Williams wrote:*   

> If NetworkManager was built with support for dhclient or dhcpcd, you can use either of these clients by setting this option to the client’s name.  Note that if you enable both dhclient and dhcpcd, dhclient will be preferred for maximum compatibility.

 

https://blogs.gnome.org/dcbw/2015/02/16/networkmanager-for-administrators-part-1/

I have specified the DHCP client explicitly in /etc/NetworkManager/NetworkManager.conf:

```
[main]

plugins=keyfile

rc-manager=none

dhcp=dhclient

no-auto-default=*

[keyfile]

hostname=clevow230s
```

(See man NetworkManager.conf for all the possible settings.)

Additionally, if, like me, you want to use the netmount service to mount network file systems, then check that NetworkManager is specified in /etc/conf.d/netmount:

```
# grep "^rc_need" /etc/conf.d/netmount

rc_need="NetworkManager"
```

If you don't use the netmount service, then stop it from being launched at start-up:

```
# rc-update del netmount default
```

By default, NetworkManager manages /etc/resolv.conf itself ("-resolvconf" USE flag when you merge net-misc/networkmanager) instead of it launching resolvconf to do it, but you can optionally declare 'rc-manager=none' in /etc/NetworkManager/NetworkManager.conf to tell NetworkManager explicitly to manage /etc/resolv.conf itself instead of running resolvconf (as I have done in NetworkManager.conf -- see above). Here is what /etc/resolv.conf contains at the moment on my  laptop (I'm using an office Wi-Fi network at this precise moment) and, as you can see, it is generated by NetworkManager (IP addresses anonymised):

```
$ cat /etc/resolv.conf

# Generated by NetworkManager

nameserver xx.xxx.xxx.xx

nameserver xxx.xx.xxx.xx

nameserver xxx.xx.xxx.xx

# NOTE: the libc resolver may not support more than 3 nameservers.

# The nameservers listed below may not be recognised.

nameserver 8.8.8.8
```

Here are the USE flags I am currently using in the latest version of NetworkManager available in Gentoo:

```
# eix -I networkmanager

[I] net-misc/networkmanager

     Available versions:  1.0.6-r1 1.0.10-r1 1.0.12 1.0.12-r1 {bluetooth connection-sharing consolekit +dhclient dhcpcd gnutls +introspection +modemmanager ncurses +nss +ppp resolvconf selinux systemd teamd test vala +wext +wifi zeroconf ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32" KERNEL="linux"}

     Installed versions:  1.0.12-r1(10:55:59 18/04/16)(bluetooth consolekit dhclient introspection modemmanager ncurses nss ppp wext wifi zeroconf -connection-sharing -dhcpcd -gnutls -resolvconf -selinux -systemd -teamd -test -vala ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="64 -32 -x32" KERNEL="linux")

     Homepage:            https://wiki.gnome.org/Projects/NetworkManager

     Description:         A set of co-operative tools that make networking simple and straightforward
```

----------

## The_Great_Sephiroth

Thank you, but the autoconnect entry seems to be the missing variable here.

```

officemgr ~ # rc-update show -v | grep dhcp

                dhcpd |                              

officemgr ~ # rc-update show -v | grep net

           net-online |                              

          net.enp0s25 |                              

               net.lo |                              

             netmount |      default

```

As you can see, nothing is starting. NM is set to run in default. It works great now, so thank you VERY much for the help. I cannot figure out why the autoconnect entry was not added despite being set to connect automatically, but it works now. This means I can still use NM for VPN (users can simply click the icon in KDE, click the VPN which is needed, then enter their password to connect) and I don't have to confuse normal users!

----------

