Score:3

Unwanted DHCP setting on server

us flag

I'm configuring a new Debian 11 server running on a private network. It is determinedly taking a DHCP address in addition to the static IP I am manually configuring. I don't understand where it gets the DHCP address and how I can turn that off.

Out of the box it grabs a DHCP address (I guess it has an auto-configure for the network?); since I want it running on a manually assigned static IP, I modified /etc/network/interfaces to configure the static IP (in addition to the lo lines):

auto enp0s25
allow-hotplug enp0s25
iface enp0s25 inet static
    address 10.0.0.16/24
    gateway 10.0.0.1
    dns-nameservers 10.0.0.1

and I am rewarded for my effort by having two IPs configured for this device

user@server:~$ ip a
1: lo: ...
2: enp0s25: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether d0:50:99:5a:08:98 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.16/24 brd 10.0.0.255 scope global enp0s25
       valid_lft forever preferred_lft forever
    inet 10.0.0.190/24 brd 10.0.0.255 scope global secondary enp0s25
       valid_lft forever preferred_lft forever
    inet6 fe80::d250:99ff:fe5a:898/64 scope link 
       valid_lft forever preferred_lft forever

(note this configuration is stably reproducible on reboot)

As I understand it there should be three ways of configuring the network:

  • networking - I'm using that, because that's what I'm most used to
  • NetworkManager - it's not installed, and the service isn't running
  • systemd - systemd-networkd claims to be disabled

So what other config(s) am I not finding? And how do I make sense of this mess?

There are other screwy things about the networking (ifdown/ifup not working properly, restarting networking throwing errors), but I'm guessing/hoping its related to unclear control of the interface.

EDIT: This is the syslog output relevant to enp0s25:

Dec 16 19:37:57 angelo systemd[1]: Started ifup for enp0s25.
Dec 16 19:37:57 angelo kernel: [    1.222564] e1000e 0000:00:19.0 enp0s25: renamed from eth0
Dec 16 19:37:57 angelo kernel: [    2.613911] e1000e 0000:00:19.0 enp0s25: NIC Link is Down
Dec 16 19:37:57 angelo sh[413]: ifup: failed to bring up enp0s25
Dec 16 19:37:57 angelo systemd[1]: [email protected]: Main process exited, code=exited, status=1/FAILURE
Dec 16 19:37:57 angelo systemd[1]: [email protected]: Failed with result 'exit-code'.
Dec 16 19:37:57 angelo connmand[467]: enp0s25 {create} index 2 type 1 <ETHER>
Dec 16 19:37:57 angelo connmand[467]: enp0s25 {update} flags 36866 <DOWN>
Dec 16 19:37:57 angelo connmand[467]: enp0s25 {newlink} index 2 address D0:50:99:5A:08:98 mtu 1500
Dec 16 19:37:57 angelo connmand[467]: enp0s25 {newlink} index 2 operstate 2 <DOWN>
Dec 16 19:37:57 angelo connmand[467]: Adding interface enp0s25 [ ethernet ]
Dec 16 19:37:57 angelo connmand[467]: enp0s25 {update} flags 36867 <UP>
Dec 16 19:37:57 angelo connmand[467]: enp0s25 {newlink} index 2 address D0:50:99:5A:08:98 mtu 1500
Dec 16 19:37:57 angelo connmand[467]: enp0s25 {newlink} index 2 operstate 2 <DOWN>
Dec 16 19:37:58 angelo avahi-daemon[464]: Joining mDNS multicast group on interface enp0s25.IPv4 with address 10.0.0.16.
Dec 16 19:37:58 angelo connmand[467]: enp0s25 {add} address 10.0.0.16/24 label enp0s25 family 2
Dec 16 19:37:58 angelo avahi-daemon[464]: New relevant interface enp0s25.IPv4 for mDNS.
Dec 16 19:37:58 angelo connmand[467]: enp0s25 {add} route 10.0.0.0 gw 0.0.0.0 scope 253 <LINK>
Dec 16 19:37:58 angelo avahi-daemon[464]: Registering new address record for 10.0.0.16 on enp0s25.IPv4.
Dec 16 19:37:58 angelo connmand[467]: enp0s25 {add} route 0.0.0.0 gw 10.0.0.1 scope 0 <UNIVERSE>
Dec 16 19:38:00 angelo connmand[467]: enp0s25 {add} route fe80:: gw :: scope 0 <UNIVERSE>
Dec 16 19:38:00 angelo connmand[467]: enp0s25 {update} flags 102467 <UP,RUNNING,LOWER_UP>
Dec 16 19:38:00 angelo connmand[467]: enp0s25 {newlink} index 2 address D0:50:99:5A:08:98 mtu 1500
Dec 16 19:38:00 angelo connmand[467]: enp0s25 {newlink} index 2 operstate 6 <UP>
Dec 16 19:38:00 angelo kernel: [    5.902126] e1000e 0000:00:19.0 enp0s25: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx
Dec 16 19:38:00 angelo kernel: [    5.902187] IPv6: ADDRCONF(NETDEV_CHANGE): enp0s25: link becomes ready
Dec 16 19:38:01 angelo avahi-daemon[464]: Joining mDNS multicast group on interface enp0s25.IPv6 with address fe80::d250:99ff:fe5a:898.
Dec 16 19:38:01 angelo avahi-daemon[464]: New relevant interface enp0s25.IPv6 for mDNS.
Dec 16 19:38:01 angelo avahi-daemon[464]: Registering new address record for fe80::d250:99ff:fe5a:898 on enp0s25.*.
Dec 16 19:38:05 angelo avahi-daemon[464]: Registering new address record for 10.0.0.190 on enp0s25.IPv4.
Dec 16 19:38:05 angelo connmand[467]: enp0s25 {add} address 10.0.0.190/24 label enp0s25 family 2
Dec 16 19:38:05 angelo connmand[467]: enp0s25 {add} route 10.0.0.1 gw 0.0.0.0 scope 253 <LINK>
Dec 16 19:38:05 angelo connmand[467]: enp0s25 {add} route 82.165.8.211 gw 10.0.0.1 scope 0 <UNIVERSE>
Dec 16 19:38:09 angelo connmand[467]: enp0s25 {del} route 82.165.8.211 gw 10.0.0.1 scope 0 <UNIVERSE>
Dec 16 19:38:42 angelo connmand[467]: enp0s25 {del} route 0.0.0.0 gw 10.0.0.1 scope 0 <UNIVERSE>
djdomi avatar
za flag
did you reboot afterwards?
pettus avatar
us flag
yes - it reliably comes up this way, edited to reflect this detail
jp flag
`grep -ri dhcp /etc/network/`
pettus avatar
us flag
returns nothing @AlexD
jp flag
Anything interesting in ‘grep -r enp0s25 /var/log/‘?
pettus avatar
us flag
nothing that I can parse out of it - I've added the syslog output related to the device into the bottom of the above post
Score:0
cn flag

You said it was a private network so I'm going to assume you have access to your router. Changing the DHCP settings on your router to give it a static IP address will not result in needless IP associations.

  1. Type ifconfig and look for the gateway ip address
  2. Login to your router in a browser using the gateway address
  3. In DHCP settings on your router, you can assign a static IP association there. It should not give you an additonal IP address.
pettus avatar
us flag
This feels like an awkward workaround for the fundamental problem (although I certainly control the entire network) - something is different about this server's network config which is allowing it to request a dhcp address, unlike every other server I have configured on this network.
nAZklX avatar
cn flag
I had the same problem until I manually configured it in the router and it makes more sense (to me at least) to have static IPs assigned all in one place in DHCP than separately configured on every device. This is my solution, you are welcome to find another.
Score:0
us flag

I uninstalled connman to resolve this. Not my preferred choice, but I couldn't find a better way by modifying config files to make it stop doing its auto-DHCP nonsense. Note: uninstalling connman does take down the network connections of the server, so reboot required

Some links that convinced me this was the best shot:

Would still welcome a less nuclear, more directed solution.

Score:0
in flag

I assume you correctly checked anything else such as network-manager not running as you mentioned. But even then, if you configure the /etc/network/interfaces file as I show below the system should automatically use that instead of things like network-manager.

I have always found that the following consistently provides me with a static ip address even on networks with a dhcp server running. Of course you want to make sure the ip address is outside of the block the dhcp server hands out, otherwise you get conflicts. I used a https://www.rfc-editor.org/rfc/rfc5737.html network block.

auto enp0s25
iface enp0s25 inet static
        address 192.0.2.10
        netmask 255.255.255.0
        broadcast 192.0.2.255
        network 192.0.2.0
        gateway 192.0.2.1

I prefer to not use allow-hotplug because (man interfaces):

Lines beginning with "allow-" are used to identify interfaces that should 
be brought up automatically by various subsystems. This may be done using    
a command  such as  "ifup  --allow=hotplug eth0 eth1", which will only 
bring up eth0 or eth1 if it is listed in an "allow-hotplug" line.

It is possible the interface had already a dhcp assigned ip address before you changed it to be static. In that case it may have 2 ip address until you reboot.

As an aside, this probably does not apply to debian systems, but just in case, on ubuntu 20.04 systems I find this when wanting to configure the interfaces file:

# ifupdown has been replaced by netplan(5) on this system.  See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
#    sudo apt install ifupdown
pettus avatar
us flag
The persistent irritating feature of this issue is that the 2 IP addresses persist despite numerous reboots. So clearly I continue to not have resolved the root issue.*** Removing allow-hotplug does remove all the ifup lines from the syslog on boot - not sure if that's a good thing or not because it also doesn't say it's trying to ifup the device, but it doesn't fail*** Didn't see that warning when editing the interfaces file using vi
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.