4

Basically every time I change a video card or swap out a device my Ethernet connection name increments. It used to be enp0n0, then became enp09n0, and now last time it became enp13n0. Every time I need to plug a monitor and keyboard into my server and update my netplan. Is it possible to set a custom name that never changes?

Output of ip a (truncated):

2: enp13s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bridge0 state UP group default qlen 1000
    link/ether 00:9d:d8:aa:66:19 brd ff:ff:ff:ff:ff:ff
3: bridge0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 8a:11:b8:e9:3f:68 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.2/24 brd 192.168.0.255 scope global bridge0
       valid_lft forever preferred_lft forever
    inet 192.168.0.10/24 brd 192.168.0.255 scope global secondary bridge0
       valid_lft forever preferred_lft forever
    inet6 (redacted)/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 299sec preferred_lft 299sec
    inet6 (redacted)/64 scope link 
       valid_lft forever preferred_lft forever

My current netplan:

  GNU nano 7.2                                     /etc/netplan/01-netplan-bridge.yaml                                               
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
  version: 2
  renderer: networkd

  ethernets:
    enp13s0:
      dhcp4: no

  bridges:
    bridge0:
      dhcp4: no
#      dhcp6: no
      addresses:
        - 192.168.0.2/24
        - 192.168.0.10/24
#        - (redacted)::abcd/64
      routes:
        - to: default
          via: 192.168.0.1
#        - to: "::/0"
#          via: "(redacted)"
      mtu: 1500
      nameservers:
        addresses:
          - 1.1.1.1
          - 9.9.9.9
#          - 2620:fe::9
#          - (redacted)::15
      interfaces:
        - enp13s0

2 Answers 2

7

Yes, you can change how interfaces are named.

Have a look at /etc/udev/rules.d/70-persistent-net.rules. If it's blank, great, create it with something like:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="ab:cd:ef:12:34:56", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

This will give the device with MAC address ab:cd:ef:12:34:56 a fixed name eth0. In principle you can give it whatever name you want.

If 70-persistent-net.rules has content, you have to either add to it, or adapt whatever is there, or overwrite it.

3

Netplan can match interface by MAC address. Like

...
  ethernets:
    bridge-port:
      match:
        macaddress: 00:9d:d8:aa:66:19
      dhcp4: no
...
  bridges:
    bridge0:
...
      interfaces:
        - bridge-port

The interface ID (bridge-port in this case) must be unique in the configuration but otherwise can be anything. It is customery to use the interface name for the interface ID but it is not mandatory.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.