修改linux中的網絡卡名

2021-08-13 10:31:26 字數 3525 閱讀 5156

[root@centos6 ~]# ip add

1: lo: mtu 65536 qdisc noqueue state unknown

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eth0:

mtu 1500 qdisc pfifo_fast state up qlen 1000

link/ether 00:0c:29:3d:56:58 brd ff:ff:ff:ff:ff:ff

inet 192.168.27.128/24 brd 192.168.27.255 scope global eth0

inet6 fe80::20c:29ff:fe3d:5658/64 scope link

valid_lft forever preferred_lft forever

3: pan0:

mtu 1500 qdisc noop state down

link/ether 52:8f:9d:89:cb:a1 brd ff:ff:ff:ff:ff:ff

4: eth1:

mtu 1500 qdisc pfifo_fast state up qlen 1000

link/ether 00:0c:29:3d:56:62 brd ff:ff:ff:ff:ff:ff

inet 172.18.16.20/16 brd 172.18.255.255 scope global eth1

inet6 fe80::20c:29ff:fe3d:5662/64 scope link

valid_lft forever preferred_lft forever

操作

首先修改/etc/udev/rules./70-persistent-net.rules

# this file was automatically generated by the /lib/udev/write_net_rules

# program, run by the persistent-net-generator.rules rules file.

## you can modify it, as long as you keep each rule on a single

# line, and change only the value of the name= key.

# pci device 0x8086:0x100f (e1000)

subsystem=="net", action=="add", drivers=="?*", attr=="00:0c:29:3d:56:58", attr

=="1", kernel=="eth*", name="eth0"

# pci device 0x8086:0x100f (e1000)

subsystem=="net", action=="add", drivers=="?*", attr=="00:0c:29:3d:56:62", attr

=="1", kernel=="eth*", name="good"

# 找到剛剛eth1的對應的實體地址,修改這一段的name中的字段,變成自己想要的

由於修改後並不是立馬生效,需要重啟後生效,不想重啟要讓這個配置檔案生效的辦法就是解除安裝網絡卡驅動然後在重灌

如何檢視網絡卡驅動,用ethtool -i eth1

[root@centos6 ~]# ethtool -i eth1

driver: e1000 #這行顯示驅動為e1000

version: 7.3.21-k8-napi

firmware-version:

bus-info: 0000:02:05.0

supports-statistics: yes

supports-test: yes

supports-eeprom-access: yes

supports-register-dump: yes

supports-priv-flags: no

[root@centos6 ~]#

解除安裝網絡卡 modprobe -r e1000 ,

[root@centos6 ~]# modprobe -r e1000

這需要特別注意,由於我們的用的都是同一型號的網絡卡,所以驅動也一樣

雖然有兩個網絡卡,但是取得的都是一樣的,所以解除安裝之後不能上網,也遠端連線不了!!!!

由於把網絡卡驅動解除安裝了,所以們要在本地主機上操作,在把網絡卡驅動裝上 modprobe e1000

[root@centos6 ~]# modprobe -r e1000

[root@centos6 ~]# ip add

1: lo: mtu 65536 qdisc noqueue state unknown

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

3: pan0:

mtu 1500 qdisc noop state down

link/ether 52:8f:9d:89:cb:a1 brd ff:ff:ff:ff:ff:ff

5: eth0:

mtu 1500 qdisc pfifo_fast state up qlen 1000

link/ether 00:0c:29:3d:56:58 brd ff:ff:ff:ff:ff:ff

inet 192.168.27.128/24 brd 192.168.27.255 scope global eth0

inet6 fe80::20c:29ff:fe3d:5658/64 scope link

valid_lft forever preferred_lft forever

6: good:

mtu 1500 qdisc pfifo_fast state up qlen 1000

link/ether 00:0c:29:3d:56:62 brd ff:ff:ff:ff:ff:ff

inet 172.18.16.20/16 brd 172.18.255.255 scope global good

inet6 fe80::20c:29ff:fe3d:5662/64 scope link

valid_lft forever preferred_lft forever

[root@centos6 ~]#

這樣就不用重啟就可以生效了。

Redhat CentOS修改網絡卡名

使用起來較為不便,因此我們將圖中的網絡卡名稱改為熟悉的eth0。1.首先將網絡卡配置檔案名稱重新命名為eth0 cd etc sysconfig network scripts mv ifcfg eno1677736 ifcfg eth0 將name引數改為與網絡卡檔案相同的名稱 name eth0...

centos7修改網絡卡名

我實際測試中修改好像不管用,需要修改啟動項,警用biosdevname程式 具體操作是修改 etc default grub檔案 在grub cmdline linux一行中新增net.ifnames 0 biosdevname 0 儲存檔案後然後執行 plain view plain copy g...

Linux 下IP的配置和網絡卡介面名的修改

本文主要講如何把eth0修改為eth1,以及如何配置ip,其他同理。這個檔案是用來修改ip設定的,這裡我配置成靜態ip了,命令如下 cd etc sysconfig network scripts vim ifcfg eth1 配置內容如下,注意ip位址 子網掩碼 閘道器 dns伺服器 mac位址應...