0

I am running ubuntu server 19.10 on a raspberry pi. My pi is connected to a wifi router and to an ethernet switch, with interface names wlan0 and eth0 respectively.

I want to create a static ip address for my wlan0 connection. I'm used to raspbian and this is my first serious foray into ubuntu server.

When I look into /etc/netplan/, there is a single yml file with the contents:

network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2

Since there's no mention of wlan0 in here, I assumed that ubuntu is not operating a dhcp client for wlan0. I therefore installed dhcpcd5 and configured it to ask for a static ip address (192.168.1.202). However, the wifi router now seems to be giving my device two ip addresses; one is the one I asked for in /etc/dhcpcd.conf, the other must be (I think) via netplan. Both work when I try ssh-ing to the device.

I want to figure out why I am getting two addresses and how to prevent it. When I print-out dhcp-relevant lines from /var/log/syslog, I get the following:

... dhcpcd[1173]: wlan0: carrier acquired
... dhcpcd[1173]: wlan0: IAID eb:25:ec:d9
... dhcpcd[1173]: wlan0: adding address XXX
... dhcpcd[1173]: wlan0: IAID eb:25:ec:d9
... dhcpcd[1173]: wlan0: adding address XXX
... NetworkManager[1162]: <info>  [1573233133.0889] dhcp4 (wlan0): activation: beginning transaction (timeout in 45 seconds)
... dhcpcd[1173]: wlan0: probing address 192.168.1.202/24
... dhcpcd[1173]: wlan0: probing address 192.168.1.202/24
... NetworkManager[1162]: <info>  [1573233133.1426] dhcp4 (wlan0): state changed unknown -> bound
... dhcpcd[1473]: wlan0: using static address 192.168.1.202/24
... dhcpcd[1473]: wlan0: adding route to 192.168.1.0/24
... dhcpcd[1473]: wlan0: no IPv6 Routers available

So it looks like dhcpcd5 is functioning as normal, but then there is this surprise entry from NetworkManager with dhcp4. Furthermore, when I try ifconfig wlan0, I find that my device thinks its wlan0 ip address is NOT the one I requested via dhcpcd5, which is surprising, since my most recent logs suggested that it was adding that route to my wifi router, but then it doesn't seem to write the result to my device locally.

I'd greatly appreciate clarity here, namely:

1a. Why doesn't netplan show info for wlan0 in /etc/netplan/*?

1b. How can I disable netplan's dhcp4 service?

  1. General recommendations are welcome as to how best to set up static ip addresses. Is it a bad idea to install dhcpcd5 on ubuntu in place of its native set up? etc.
  • An easy alternative is to make no changes to your Pi, but instead to set your router to issue the same IP address every time to the Pi's MAC address. – user535733 Nov 9 at 15:16
  • Even so, I most interesting in understanding what's going on and how to control/disable netplan's dhcp – Magnus Nov 9 at 15:33
0

NetworkManager is not part of the server images, including the 19.10 raspi preinstalled server images. So it looks like you have installed that yourself, and that's why it's getting addresses for you on the wlan interface.

As for ifconfig wlan0 not showing the address, ifconfig is a deprecated tool that does not show multiple addresses on interfaces, only the first one assigned. If you run ip addr show instead, you will probably see that both addresses are on the interface.

It is possible to use netplan alone to manage your wlan0 interface; see https://netplan.io/examples for details. However, if you have a requirement to request a specific IP address from the DHCP server (your "static IP address"), that is not supported. I would suggest either using an actual static IP address (by using an address assigned locally in a range outside of your DHCP server's pool), or letting the DHCP server assign the address. Most DHCP server implementations are stateful and will give the same IP address back to the client each time it asks anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.