Score:1

Ubuntu 20.04 - NIC naming and match MAC with Netplan

cn flag

I did my research before asking here; tried so many different things but I'm already lost about it.

I'm running 20.04 (Modified version, GNS3 VM on ESXi) with 10 NICs. From time to time if I make a change in the settings or topology, NICs naming change, so I need them to be persistent.

The main application that I'm running is expecting the old naming convention, in my case from Eth0 to Eth9. Thats ok.

Here's the content of the file the application is using within /etc/netplan:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      match:
        macaddress: 00:50:56:00:0a:01
      dhcp4: no
      addresses:
        - 192.168.100.3/24
      gateway4: 192.168.100.1
      nameservers:
        addresses: [1.1.1.1, 8.8.8.8]
    eth1:
      match:
        macaddress: 00:50:56:00:0a:04
      dhcp4: yes
    eth2:
      match:
        macaddress: 00:50:56:00:0b:01
      dhcp4: yes
    eth3:
      match:
        macaddress: 00:50:56:00:0b:02
      dhcp4: yes
    eth4:
      match:
        macaddress: 00:50:56:00:0b:03
      dhcp4: yes
    eth5:
      match:
        macaddress: 00:50:56:00:0b:04
      dhcp4: yes
    eth6:
      match:
        macaddress: 00:50:56:00:0c:01
      dhcp4: yes
    eth7:
      match:
        macaddress: 00:50:56:00:0c:02
      dhcp4: yes
    eth8:
      match:
        macaddress: 00:50:56:00:0c:03
      dhcp4: yes
    eth9:
      match:
        macaddress: 00:50:56:00:0c:04
      dhcp4: yes

When I run netplan apply there seems to be no problem; but the actual output of sudo netplan --debug generate lets me think otherwise:

** (generate:1473): DEBUG: 14:22:26.352: Processing input file /etc/netplan/01-netcfg.yaml..
** (generate:1473): DEBUG: 14:22:26.353: Processing input file /etc/netplan/90_gns3vm_static_netcfg.yaml..
** (generate:1473): DEBUG: 14:22:26.353: starting new processing pass
** (generate:1473): DEBUG: 14:22:26.353: We have some netdefs, pass them through a final round of validation
** (generate:1473): DEBUG: 14:22:26.354: eth5: setting default backend to 1
** (generate:1473): DEBUG: 14:22:26.354: Configuration is valid
** (generate:1473): DEBUG: 14:22:26.354: eth4: setting default backend to 1
** (generate:1473): DEBUG: 14:22:26.354: Configuration is valid
** (generate:1473): DEBUG: 14:22:26.354: eth3: setting default backend to 1
** (generate:1473): DEBUG: 14:22:26.354: Configuration is valid
** (generate:1473): DEBUG: 14:22:26.354: eth9: setting default backend to 1
** (generate:1473): DEBUG: 14:22:26.354: Configuration is valid
** (generate:1473): DEBUG: 14:22:26.354: eth2: setting default backend to 1
** (generate:1473): DEBUG: 14:22:26.354: Configuration is valid
** (generate:1473): DEBUG: 14:22:26.354: eth8: setting default backend to 1
** (generate:1473): DEBUG: 14:22:26.354: Configuration is valid
** (generate:1473): DEBUG: 14:22:26.354: eth1: setting default backend to 1
** (generate:1473): DEBUG: 14:22:26.354: Configuration is valid
** (generate:1473): DEBUG: 14:22:26.354: eth7: setting default backend to 1
** (generate:1473): DEBUG: 14:22:26.354: Configuration is valid
** (generate:1473): DEBUG: 14:22:26.354: eth0: setting default backend to 1
** (generate:1473): DEBUG: 14:22:26.354: Configuration is valid
** (generate:1473): DEBUG: 14:22:26.354: eth6: setting default backend to 1
** (generate:1473): DEBUG: 14:22:26.354: Configuration is valid
** (generate:1473): DEBUG: 14:22:26.355: Generating output files..
** (generate:1473): DEBUG: 14:22:26.355: openvswitch: definition eth0 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.355: NetworkManager: definition eth0 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.355: openvswitch: definition eth1 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.355: NetworkManager: definition eth1 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.356: openvswitch: definition eth2 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.356: NetworkManager: definition eth2 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.356: openvswitch: definition eth3 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.356: NetworkManager: definition eth3 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.356: openvswitch: definition eth4 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.356: NetworkManager: definition eth4 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.356: openvswitch: definition eth5 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.356: NetworkManager: definition eth5 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.356: openvswitch: definition eth6 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.356: NetworkManager: definition eth6 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.357: openvswitch: definition eth7 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.357: NetworkManager: definition eth7 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.357: openvswitch: definition eth8 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.357: NetworkManager: definition eth8 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.357: openvswitch: definition eth9 is not for us (backend 1)
** (generate:1473): DEBUG: 14:22:26.357: NetworkManager: definition eth9 is not for us (backend 1)
(generate:1473): GLib-DEBUG: 14:22:26.357: posix_spawn avoided (fd close requested) 
(generate:1473): GLib-DEBUG: 14:22:26.365: posix_spawn avoided (fd close requested) 

Output of dmesg | grep eth

[    4.621720] e1000e 0000:03:00.0 eth0: (PCI Express:2.5GT/s:Width x1) 00:50:56:00:0a:01
[    4.621723] e1000e 0000:03:00.0 eth0: Intel(R) PRO/1000 Network Connection
[    4.621865] e1000e 0000:03:00.0 eth0: MAC: 3, PHY: 8, PBA No: 000000-000
[    4.733469] e1000e 0000:04:00.0 eth1: (PCI Express:2.5GT/s:Width x1) 00:50:56:00:0b:03
[    4.733472] e1000e 0000:04:00.0 eth1: Intel(R) PRO/1000 Network Connection
[    4.733577] e1000e 0000:04:00.0 eth1: MAC: 3, PHY: 8, PBA No: 000000-000
[    4.845864] e1000e 0000:05:00.0 eth2: (PCI Express:2.5GT/s:Width x1) 00:50:56:00:0c:03
[    4.845868] e1000e 0000:05:00.0 eth2: Intel(R) PRO/1000 Network Connection
[    4.845977] e1000e 0000:05:00.0 eth2: MAC: 3, PHY: 8, PBA No: 000000-000
[    4.956955] e1000e 0000:0b:00.0 eth3: (PCI Express:2.5GT/s:Width x1) 00:50:56:00:0a:04
[    4.956959] e1000e 0000:0b:00.0 eth3: Intel(R) PRO/1000 Network Connection
[    4.957087] e1000e 0000:0b:00.0 eth3: MAC: 3, PHY: 8, PBA No: 000000-000
[    5.070404] e1000e 0000:0c:00.0 eth4: (PCI Express:2.5GT/s:Width x1) 00:50:56:00:0b:04
[    5.070407] e1000e 0000:0c:00.0 eth4: Intel(R) PRO/1000 Network Connection
[    5.070531] e1000e 0000:0c:00.0 eth4: MAC: 3, PHY: 8, PBA No: 000000-000
[    5.182248] e1000e 0000:0d:00.0 eth5: (PCI Express:2.5GT/s:Width x1) 00:50:56:00:0c:04
[    5.182251] e1000e 0000:0d:00.0 eth5: Intel(R) PRO/1000 Network Connection
[    5.182374] e1000e 0000:0d:00.0 eth5: MAC: 3, PHY: 8, PBA No: 000000-000
[    5.294284] e1000e 0000:13:00.0 eth6: (PCI Express:2.5GT/s:Width x1) 00:50:56:00:0b:01
[    5.294287] e1000e 0000:13:00.0 eth6: Intel(R) PRO/1000 Network Connection
[    5.294410] e1000e 0000:13:00.0 eth6: MAC: 3, PHY: 8, PBA No: 000000-000
[    5.406343] e1000e 0000:14:00.0 eth7: (PCI Express:2.5GT/s:Width x1) 00:50:56:00:0c:01
[    5.406346] e1000e 0000:14:00.0 eth7: Intel(R) PRO/1000 Network Connection
[    5.406471] e1000e 0000:14:00.0 eth7: MAC: 3, PHY: 8, PBA No: 000000-000
[    5.518208] e1000e 0000:1b:00.0 eth8: (PCI Express:2.5GT/s:Width x1) 00:50:56:00:0b:02
[    5.518211] e1000e 0000:1b:00.0 eth8: Intel(R) PRO/1000 Network Connection
[    5.518335] e1000e 0000:1b:00.0 eth8: MAC: 3, PHY: 8, PBA No: 000000-000
[    5.631213] e1000e 0000:1c:00.0 eth9: (PCI Express:2.5GT/s:Width x1) 00:50:56:00:0c:02
[    5.631216] e1000e 0000:1c:00.0 eth9: Intel(R) PRO/1000 Network Connection
[    5.631408] e1000e 0000:1c:00.0 eth9: MAC: 3, PHY: 8, PBA No: 000000-000
[    9.627269] e1000e 0000:1c:00.0 eth9: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[    9.628754] IPv6: ADDRCONF(NETDEV_CHANGE): eth9: link becomes ready
[    9.729352] e1000e 0000:1b:00.0 eth8: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[    9.813525] IPv6: ADDRCONF(NETDEV_CHANGE): eth8: link becomes ready
[    9.817031] e1000e 0000:14:00.0 eth7: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[    9.913124] e1000e 0000:13:00.0 eth6: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[   10.001200] IPv6: ADDRCONF(NETDEV_CHANGE): eth7: link becomes ready
[   10.002240] IPv6: ADDRCONF(NETDEV_CHANGE): eth6: link becomes ready
[   10.004976] e1000e 0000:0d:00.0 eth5: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[   10.096982] e1000e 0000:0c:00.0 eth4: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[   10.099025] IPv6: ADDRCONF(NETDEV_CHANGE): eth5: link becomes ready
[   10.100038] IPv6: ADDRCONF(NETDEV_CHANGE): eth4: link becomes ready
[   10.204745] e1000e 0000:0b:00.0 eth3: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[   10.296669] e1000e 0000:05:00.0 eth2: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[   10.416662] e1000e 0000:04:00.0 eth1: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[   10.509219] e1000e 0000:03:00.0 eth0: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[   10.511526] IPv6: ADDRCONF(NETDEV_CHANGE): eth3: link becomes ready
[   10.512287] IPv6: ADDRCONF(NETDEV_CHANGE): eth2: link becomes ready
[   10.512964] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
[   10.513602] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

Output of ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:00:0a:01 brd ff:ff:ff:ff:ff:ff
    altname enp3s0
    altname ens160
    inet 192.168.100.3/24 brd 192.168.100.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe00:a01/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:00:0b:03 brd ff:ff:ff:ff:ff:ff
    altname enp4s0
    altname ens161
    inet6 fe80::250:56ff:fe00:b03/64 scope link 
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:00:0c:03 brd ff:ff:ff:ff:ff:ff
    altname enp5s0
    altname ens162
    inet6 fe80::250:56ff:fe00:c03/64 scope link 
       valid_lft forever preferred_lft forever
5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:00:0a:04 brd ff:ff:ff:ff:ff:ff
    altname enp11s0
    altname ens192
    inet6 fe80::250:56ff:fe00:a04/64 scope link 
       valid_lft forever preferred_lft forever
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:00:0b:04 brd ff:ff:ff:ff:ff:ff
    altname enp12s0
    altname ens193
    inet6 fe80::250:56ff:fe00:b04/64 scope link 
       valid_lft forever preferred_lft forever
7: eth5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:00:0c:04 brd ff:ff:ff:ff:ff:ff
    altname enp13s0
    altname ens194
    inet6 fe80::250:56ff:fe00:c04/64 scope link 
       valid_lft forever preferred_lft forever
8: eth6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:00:0b:01 brd ff:ff:ff:ff:ff:ff
    altname enp19s0
    altname ens224
    inet6 fe80::250:56ff:fe00:b01/64 scope link 
       valid_lft forever preferred_lft forever
9: eth7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:00:0c:01 brd ff:ff:ff:ff:ff:ff
    altname enp20s0
    altname ens225
    inet6 fe80::250:56ff:fe00:c01/64 scope link 
       valid_lft forever preferred_lft forever
10: eth8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:00:0b:02 brd ff:ff:ff:ff:ff:ff
    altname enp27s0
    altname ens256
    inet6 fe80::250:56ff:fe00:b02/64 scope link 
       valid_lft forever preferred_lft forever
11: eth9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:00:0c:02 brd ff:ff:ff:ff:ff:ff
    altname enp28s0
    altname ens257
    inet6 fe80::250:56ff:fe00:c02/64 scope link 
       valid_lft forever preferred_lft forever
12: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:6f:81:c9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
13: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:6f:81:c9 brd ff:ff:ff:ff:ff:ff
14: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:02:d0:f1:69 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever

When I started trying things I realized there was no network-manager, cloud-init installed nor anything within /etc/network/interfaces (Empty).

Any ideas or solutions would be appreciated.

Score:0
jp flag

Are you using an option like net.ifnames=0 biosdevname=0 to disable the predictable network interface names?

In your netplan config, the IDs you use does not mean the interfaces will be named to match that ID. From the netplan reference

The key names below the per-device-type definition maps (like ethernets:) are called "ID"s.

If there are match: rules, then the ID field is a purely opaque name which is only being used for references

You might have better luck with a config that uses set-name like this

network:
  version: 2
  renderer: networkd
  ethernets:
    nic0:
      match:
        macaddress: 00:50:56:00:0a:01
      dhcp4: no
      addresses:
        - 192.168.100.3/24
      gateway4: 192.168.100.1
      nameservers:
        addresses: [1.1.1.1, 8.8.8.8]
      set-name: eth0
    nic1:
      match:
        macaddress: 00:50:56:00:0a:04
      dhcp4: yes
      set-name: eth1
...

I'm not sure how the config will interact with your current settings because your interfaces already seem to be named ethX. Which is why I am wondering if you disabled the predictable network interface naming.

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.