问题原文
原帖链接 · user1707414 · CC BY-SA 4.0
Based on: http://kernelpanik.net/rename-a-linux-network-interface-without-udev/
We can easily change the name of an interface using:
ifconfig peth0 down
ip link set peth0 name eth0
ifconfig eth0 up
How do we do it at startup using the above way ?
In /etc/network/interfaces or any other file ?
已采纳解答
原帖链接 · user1707414 · CC BY-SA 4.0
Thanks to netplan (default in ubuntu 18.04) this is now particularly easy. You can set the interface name based on macaddress or driver:
Edit an existing .yaml configuration file in /etc/netplan/ or create a new one:
sudo nano /etc/netplan/config.yaml
Here is an example with MAC address matching. Names are set with 'set-name' and matched by the MAC address of the interface:
network:
ethernets:
wan:
match:
macaddress: 00:ab:cd:ef:12:34
addresses:
- 10.5.1.2/16
dhcp4: true
optional: true
set-name: wan0
lan:
match:
macaddress: 00:ab:cd:ef:12:45
addresses:
- 10.6.1.1/16
optional: true
set-name: eth0
version: 2
Save the .yaml file and apply the configuration with:
sudo netplan apply
A reboot may be required to apply the name change.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
