有時候新增網路卡後,看系統預設的名稱會不知道哪一張網路卡是做什麼用的
又或者是網路卡會跳號,龜毛人如我看了就會不舒服
就像這樣:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
$ ifconfig -a
enp0s3 Link encap:Ethernet HWaddr 08:00:27:51:3c:5b
inet addr:192.168.56.101 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe51:3c5b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:51 errors:0 dropped:0 overruns:0 frame:0
TX packets:69 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7787 (7.7 KB) TX bytes:9395 (9.3 KB)
enp0s8 Link encap:Ethernet HWaddr 08:00:27:f4:06:a1
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
enp0s9 Link encap:Ethernet HWaddr 08:00:27:7d:4c:81
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
|
我們可以藉由 Linux udev 將網路卡名稱更改成自己喜歡的名稱
首先,使用 sudo vim /etc/udev/rules.d/75-persistent-net-generator.rules
指令建立一個規則檔案,將新名稱與網路卡 MAC 位址寫入 (MAC 在前面的 ifconfig -a
指令有列出 )
1
2
3
4
|
# 格式: SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="網路卡MAC位址", NAME="網路卡新名稱"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="08:00:27:51:3c:5b", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="08:00:27:f4:06:a1", NAME="eth1"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="08:00:27:7d:4c:81", NAME="eth2"
|
存檔後重新啟動系統,就可以將新的網路卡名稱套用至系統了
References: