I built a new firewall under Debian 12. The machine has eight network ports, and during configuration I accidentally used the same name for a couple of the ports in the files under /etc/systemd/network/*.link. I ended up with two link files referencing two different MAC addresses but naming each of them as WAN0, and once systemd got that configuration it wouldn’t let it go.

From what I could find online, normally I would just issue systemctl daemon-reload followed by a update-initramfs -u and after a reboot systemd should have had the updated information… but no dice this time. The way I finally discovered the problem was when I noticed under ifconfig that my wan0 port was pointing to the wrong MAC address (even though the link files had been corrected).

After several hours of fighting with it, I finally managed to get it to work by renumbering all of my link files, and now the information for each port matches up correctly. But my real question here is WHY did systemd refuse to read updated link files? Is there another step I should have taken which was mysteriously never mentioned in any of the dozens of web pages I looked at trying to fix this? I really need to understand the proper process for getting it to correctly use these files so I can maintain the machine in the future.

(God I miss the reliability of udev already)

  • waldek@lemmy.86thumbs.net
    link
    fedilink
    arrow-up
    2
    ·
    20 days ago

    I assume you’re using systemd-networkd so did you try using networkctl to reload and reconfigure your networks? By using status you can see which files are being used by your interface. I hope this points you to an explanation.

    ➜  ~ sudo networkctl
    delete       -- Delete virtual netdevs
    down         -- Bring devices down
    forcerenew   -- Trigger DHCP reconfiguration of all connected clients
    label        -- Show address labels
    list         -- List existing links
    lldp         -- Show Link Layer Discovery Protocol status
    reconfigure  -- Reconfigure interfaces
    reload       -- Reload .network and .netdev files
    renew        -- Renew dynamic configurations
    status       -- Show information about the specified links
    up           -- Bring devices up
    
    • Shdwdrgn@mander.xyzOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      20 days ago

      I did run across it and tried doing a reload, but it looks like according to the help file that doesn’t do anything with the link files? I tried networkctl status but that doesn’t show any info about what files are being used so I’m not sure what you’re seeing? It only gives me a list of the IPs used by each interface, plus some log info at the end of ppp0 going up and down while I was setting it up. If it helps, this is what one of my link files looks like…

      [Match]
      MACAddress=24:6e:96:4e:21:73
      
      [Link]
      NamePolicy=
      Name=wan0
      
      • waldek@lemmy.86thumbs.net
        link
        fedilink
        arrow-up
        1
        ·
        19 days ago

        sudo networkctl status gives you a general overview of all your network settings but indeed, it doesn’t show the files used. You can do sudo networkctl to see a list of all your network devices and whether they are managed by systemd-networkd or not. For example, the 3rd device is the one I’m using to connect to the internet. The 7th device is a VPN I’m using.

        ➜  ~ sudo networkctl
        IDX LINK            TYPE     OPERATIONAL SETUP      
          1 lo              loopback carrier     configured 
          2 enp0s31f6       ether    off         configuring
          3 enxc84bd63372d4 ether    routable    configured 
          4 br0             bridge   no-carrier  configuring
          5 wlp0s20f3       wlan     off         configuring
          6 virbr0          bridge   no-carrier  unmanaged
          7 tun0            none     routable    configured 
        
        7 links listed.
        

        Just using status gives you the overview of all your IP addresses and DNS settings.

          ~ sudo networkctl status
                  State: routable                                    
            Online state: partial                                     
                 Address: 10.161.10.39 on enxc84bd63372d4
                          192.168.122.1 on virbr0
                          172.28.241.21 on tun0
                          fe80::ca4b:d6ff:fe33:72d4 on enxc84bd63372d4
                 Gateway: 10.161.10.254 on enxc84bd63372d4
                     DNS: 172.16.1.132
                          172.23.12.100
                          172.23.13.100
          Search Domains: <REDACTED>.tld
                          <REDACTED>.domain.tld
        
        Apr 08 09:45:31 debian systemd-networkd[1083]: enp0s31f6: Link DOWN
        Apr 08 09:45:48 debian systemd-networkd[1083]: wlp0s20f3: Link DOWN
        

        What you probably want is the following sudo networkctl status $INTERFACE. Here you see the Link file and Network file used by the interface.

          ~ sudo networkctl status enxc84bd63372d4 
         3: enxc84bd63372d4                                                                              
                             Link File: /usr/lib/systemd/network/73-usb-net-by-mac.link
                          Network File: /etc/systemd/network/05-dock.network
                                 State: routable (configured)
                          Online state: online                                                            
                                  Type: ether
                                  Path: pci-0000:05:00.0-usb-0:2.4:1.0
                                Driver: r8152
                                Vendor: Realtek Semiconductor Corp.
                                 Model: RTL8153 Gigabit Ethernet Adapter
                      Hardware Address: c8:4b:d6:33:72:d4 (Dell Inc.)
                                   MTU: 1500 (min: 68, max: 9194)
                                 QDisc: fq_codel
          IPv6 Address Generation Mode: eui64
              Number of Queues (Tx/Rx): 1/1
                      Auto negotiation: yes
                                 Speed: 1Gbps
                                Duplex: full
                                  Port: mii
                               Address: 10.161.10.39 (DHCP4 via 172.27.129.1)
                                        fe80::ca4b:d6ff:fe33:72d4
                               Gateway: 10.161.10.254
                                   DNS: 172.23.12.100
                                        172.23.13.100
                     Activation Policy: up
                   Required For Online: yes
                       DHCP4 Client ID: IAID:0xf40aaca/DUID
                     DHCP6 Client DUID: DUID-EN/Vendor:0000ab113b3d3a1477342315
                          Connected To: <REDACTED>.tld on port Gi2/0/19 (== USERS + VoIP ==)
        
        Apr 08 08:55:17 debian systemd-networkd[1083]: enxc84bd63372d4: Configuring with /etc/systemd/network/05-dock.network.
        Apr 08 08:55:17 debian systemd-networkd[1083]: enxc84bd63372d4: Link UP
        Apr 08 08:55:17 debian systemd-networkd[1083]: enxc84bd63372d4: Gained carrier
        Apr 08 08:55:18 debian systemd-networkd[1083]: enxc84bd63372d4: DHCPv4 address 10.161.10.39/24, gateway 10.161.10.254 acquired from 172.27.129.1
        Apr 08 08:55:19 debian systemd-networkd[1083]: enxc84bd63372d4: Gained IPv6LL
        

        You probably have the same .link files as me because they are the default ones. The .network files I use are custom though, for example:

        ➜  ~ cat /etc/systemd/network/05-dock.network
        [Match]
        Name=enxc84bd63372d4
        
        [Network]
        DHCP=yes
        

        I hope this helps you a bit.

        • Shdwdrgn@mander.xyzOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          19 days ago

          Ah that’s handy to know the status can show more detail for individual interfaces! I still use /etc/network/interfaces to set up each port so systemd shows them all unmanaged. Maybe some day I’ll try switching to that kind of setup.

          Where do you find default link files at? There’s nothing relevant under /usr/share/doc/systemd/. I had to do a lot of online reading to find an example of selecting them by the MAC address, and the NamePolicy= line was critical to making it actually work.

          I don’t suppose you happen to know of a way for systemd to manage a DSL connection (CenturyLink)? The old pppd setup seems to be getting hammered by systemd for some reason even though there’s no service file for it, but ppp0 refuses to try connecting on the new server until I can log in, stop it, and restart it again. It’s like it is trying to connect way too early in the boot and gets locked up.

  • notabot@lemm.ee
    link
    fedilink
    arrow-up
    3
    arrow-down
    2
    ·
    21 days ago

    Debian can install without systemd, you can use SysV init and udev instead. So far I’ve had no particular problems with it, and the more people who do it, the better support is likely to be.

    I can’t help you much with the systemd issue, frustrating issues like that drive me round the bend too.

    • Shdwdrgn@mander.xyzOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      20 days ago

      Yeah frustrating is definitely one word for it. I was up until 4am Saturday morning trying to get this one issue resolved, everything else worked almost perfectly on the new firewall setup except I couldn’t get out to the internet. I had already tried renaming the files earlier and that didn’t do the trick so I’m not sure why it finally decided to start working, but all eight ports are correctly configured now. (Not that I have much faith in what will happen down the road if one of the network adapters needs replaced.)

      And the only reason I had to fight with giving all the network ports new names is because “predictable naming” is NOT… Turns out if you cold boot the machine the interfaces get named one way, and if you do a reboot they get a different set of names, so I had no choice about renaming them by MAC address.

      Oh well, maybe someone else will see the post and offer some suggestions. I can’t imagine having to do this again on my other servers when I upgrade them from Buster.