How to change a network interface name on CentOS/RHEL 7
โดยทั่วไปแล้ว network interface ของ Linux จะมีชื่อว่า eth0 eth1 … ethx แต่เนื่องจากชื่อของ network interface ไม่ได้สื่อถึง hardware ของ network interface นั้น ทำให้เราไม่สามารถรู้ได้ว่า eth0 eth1 … เป็น hardware แบบไหน จึงทำให้เกิด naming rule สำหรับ network interface ขึ้นมาโดยการตั้งชื่อจะอิงตาม firmware, topology, และ location information
ใน CentOS/RHEL 6 ได้มีการนำ naming rule เข้ามาใช้งานแต่ไม่ได้เปิดใช้งานเป็น default แต่สำหรับ CentOS/RHEL 7 ได้มีการเปิดใช้งาน naming rule เป็นค่า default ดังนั้นเราจะเห็นชื่อ network interface แปลกขึ้นมาแทน eth0 eth1 …
หลักการตั้งขื่อใหม่เป็นดังนี้
- 2 character หน้าจะหมายถึงชนิดของ interface
123456en -- ethernetsl -- serial line IP (slip)wl -- wlanww -- wwan - ส่วน character ที่เหลือมีความหมายดังนี้
123456789b<number> -- BCMA bus core numberccw<name> -- CCW bus group nameo<index> -- on-board device index numbers<slot>[f<function>][d<dev_port>] -- hotplug slot index numberx<MAC> -- MAC address[P<domain>]p<bus>s<slot>[f<function>][d<dev_port>] -- PCI geographical location[P<domain>]p<bus>s<slot>[f<function>][u<port>][..]1[i<interface>] -- USB port number chain
ตัวอย่างชื่อ network interface
eno16777736 หมายถึง ethernet on board ที่มี index ของ device ที่ provided โดย firmware (BIOS/EFI) เป็น 16777736
ดูข้อมูลเพิ่มเติมของ network interface
1 2 3 |
udevadm info --name=/dev/eno16777736 --attribute-walk |
การแก้ไข network interface name ให้กลับเป็น ethx สามารถทำได้ดังนี้
วิธีที่ 1
แก้ไขไฟล์ /etc/default/grub โดยเพิ่ม
1 2 3 |
net.ifnames=0 |
วิธีที่ 2
ปิดการใช้งาน naming rule โดยการทำ symbolic link ไปยัง /dev/null
1 2 3 |
ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules |