TL;DR: I'm aiming at configuring my own Ubuntu 22.04LTS-based router for my home network, using isc-dhcp-server, nftables & NetworkManager. I'm experiencing weird DHCP behaviors.
I'm using a Nano Pi R6S which has 3 ethernet interfaces :
- enP3p49s0:- WAN(connected to my ISP router - duh) - router is attributed an IP- 192.168.0.22via DHCP MAC address reservation configured on the ISP router
- enP4p65s0:- LAN1(will be connected to a managed switch down the road) -- 10.42.0.1/24
- eth0:- LAN2(reserved for administrating the router via SSH and DHCP MAC address reservation) -- 10.42.42.1/30
As a consequence, I'll have two local networks, defined as such:
# /etc/netplan/01-netcfg.yaml
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enP3p49s0:
      dhcp4: true
    enP4p65s0:
      addresses:
      - 10.42.0.1/24
      dhcp4: false
    eth0:
      addresses:
      - 10.42.42.1/30
      dhcp4: false
DHCP is configured as followed:
# /etc/dhcp/dhcpd.conf
default-lease-time 86400;
max-lease-time 604800;
authoritative;
# Configuration for LAN1 (Home network)
subnet 10.42.0.0 netmask 255.255.255.0 {
  option routers          10.42.0.1;
  option subnet-mask      255.255.255.0;
  option domain-name-servers 8.8.8.8, 8.8.4.4;
  range 10.42.0.100 10.42.0.200;
}
# Configuration for LAN2 (Router Management)
subnet 10.42.42.0 netmask 255.255.255.252 {
  host novoo_adapter {
      hardware ethernet XX:XX:XX:XX:XX:XX;
      fixed-address 10.42.42.2;
  }
  option routers 10.42.42.1;
  option domain-name-servers 8.8.8.8, 8.8.4.4;
}
I'm experiencing a strange behavior: it seems the DHCP will behave as expected only if I plug something on the associated ethernet port and I restart the isc-dhcp-server.
For example, at the moment, if I plug to LAN2, I won't get the 10.42.42.2 address as expected despite using the right ethernet card with the right MAC address.
I have to:
- Plug the cable to LAN2
- Set up the IP as fixed on the client (my laptop)
- Restart DHCP via systemctl restart isc-dhcp-serveron the server
- Set back up IP to DHCP on the client
- And then I finally have a DHCP-attributed IP
I've noticed the following before 1.:
$ sudo journalctl -u isc-dhcp-server
...
Jul 17 19:06:15 nanopi-r6s dhcpd[18158]: No subnet declaration for eth0 (no IPv4 addresses).
Jul 17 19:06:15 nanopi-r6s dhcpd[18158]: ** Ignoring requests on eth0.  If this is not what
Jul 17 19:06:15 nanopi-r6s dhcpd[18158]:    you want, please write a subnet declaration
Jul 17 19:06:15 nanopi-r6s dhcpd[18158]:    in your dhcpd.conf file for the network segment
Jul 17 19:06:15 nanopi-r6s dhcpd[18158]:    to which interface eth0 is attached. **
...
This mention disappears after step 3. (and I then have the same warning regarding eth0):
$ sudo journalctl -u isc-dhcp-server
...
Jul 17 19:15:28 nanopi-r6s dhcpd[18602]: No subnet declaration for enP4p65s0 (no IPv4 add>
Jul 17 19:15:28 nanopi-r6s dhcpd[18602]: ** Ignoring requests on enP4p65s0.  If this is n>
Jul 17 19:15:28 nanopi-r6s dhcpd[18602]:    you want, please write a subnet declaration
Jul 17 19:15:28 nanopi-r6s dhcpd[18602]:    in your dhcpd.conf file for the network segme>
Jul 17 19:15:28 nanopi-r6s dhcpd[18602]:    to which interface enP4p65s0 is attached. **
Jul 17 19:06:15 nanopi-r6s dhcpd[18158]:
Jul 17 19:06:15 nanopi-r6s dhcpd[18158]: Sending on   Socket/fallback/fallback-net
Jul 17 19:06:15 nanopi-r6s dhcpd[18158]: Server starting service.
Jul 17 18:45:59 nanopi-r6s dhcpd[13237]: DHCPDISCOVER from XX:XX:XX:XX:XX:XX via eth0
Jul 17 18:45:59 nanopi-r6s dhcpd[13237]: DHCPOFFER on 10.42.42.2 to XX:XX:XX:XX:XX:XX via eth0
Jul 17 18:46:00 nanopi-r6s dhcpd[13237]: DHCPREQUEST for 10.42.42.2 (10.42.42.1) from 94:05:bb:11:ae:49 via eth0
Jul 17 18:46:00 nanopi-r6s dhcpd[13237]: DHCPACK on 10.42.42.2 to XX:XX:XX:XX:XX:XX via eth0
...
And moreover, it seems that NetworkManager only assigns an IP to the interface IF a cable is plugged in (which is he expected behavior?):
# here with a cable plugged in eth0
$ ip addr
...
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    inet 10.42.42.1/30 brd 10.42.42.3 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
3: enP4p65s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff permaddr XX:XX:XX:XX:XX:XX
...
It seems like:
- isc-dhcp-serverneeds an interface with an assigned IP to work with
- the IP is only assign when a cable is plugged in the associated port
- that plugging a cable in will indeed lead to IP assignation
- but that the DHCP service won't recognized that an IP (and therefore a subnet declaration) is assigned
- this is corrected only with a DHCP service restart
I'm expecting to be able to hot-plug my laptop to LAN2 for administration without having to fixed-assign an IP (that defeats the whole purpose of DHCP MAC address reservation), and likewise for LAN1 for my future home network.
Any ideas please ?
Note: MAC Addresses have been scrambled