Linux 網絡卡配置eth1修改為eth0

2021-09-02 22:31:23 字數 3800 閱讀 6389

在測試或生產環境中,經常會遇到轉殖的伺服器(虛擬機器),網絡卡配置經常也會轉殖為eth1,下面講如何將網絡卡配置修改為eth0(eth1網絡卡也可以正常使用,但是有些強逼症的同學看不習慣);

配置環境:rhel6

目錄

步驟一:更改伺服器的網絡卡名,將轉殖的伺服器網絡卡配置修改為eth0;

步驟二:修改網絡卡名(ifcfg-eth1修改為ifcfg-eth0)

步驟三:修改網絡卡配置(device=eth1修改為device=eth0)

[root@localhost ~]# ip a

1: lo: mtu 16436 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: eth1:

mtu 1500 qdisc pfifo_fast state up qlen 1000

link/ether 00:0c:29:bc:7a:aa brd ff:ff:ff:ff:ff:ff

inet 192.168.50.44/27 brd 192.168.50.63 scope global eth1

inet6 fe80::20c:29ff:febc:7aaa/64 scope link

valid_lft forever preferred_lft forever

3: pan0:

mtu 1500 qdisc noop state down

link/ether 9e:62:69:38:2f:f0 brd ff:ff:ff:ff:ff:ff

[root@localhost ~]# cat /etc/udev/rules.d/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:7d:e0:e9", attr=="1", kernel=="eth*", name="eth0"

# pci device 0x8086:0x100f (e1000)

subsystem=="net", action=="add", drivers=="?*", attr=="00:0c:29:bc:7a:aa", attr=="1", kernel=="eth*", name="eth1"

[root@localhost ~]# vim /etc/udev/rules.d/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:7d:e0:e9", attr=="1", kernel=="eth*", name="eth0"

# pci device 0x8086:0x100f (e1000)

subsystem=="net", action=="add", drivers=="?*", attr=="00:0c:29:bc:7a:aa", attr=="1", kernel=="eth*", name="eth0"

mv /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

device=eth0

onboot=yes

bootproto=dhcp

#ipaddr=192.168.2.30

#netmast=255.255.255.0

#gateway=192.168.2.254

[root@localhost ~]# /etc/init.d/network restart

關閉環迴介面: [確定]

彈出環迴介面: [確定]

彈出介面 eth0: 活躍連線狀態:啟用中

活躍連線路徑:/org/freedesktop/networkmanager/activeconnection/3

狀態:啟用中

狀態:啟用的

連線被啟用

[確定]

[root@localhost ~]# reboot

重啟完成後觀察已經修改為eth0,恭喜完成修改-z-

[root@localhost ~]# ip a

1: lo: mtu 16436 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:bc:7a:aa brd ff:ff:ff:ff:ff:ff

inet 192.168.50.44/27 brd 192.168.50.63 scope global eth0

inet6 fe80::20c:29ff:febc:7aaa/64 scope link

valid_lft forever preferred_lft forever

3: pan0:

mtu 1500 qdisc noop state down

link/ether 32:ac:93:52:29:2f brd ff:ff:ff:ff:ff:ff

Linux下網絡卡eth1如何修改為eth0

正常來說,linux在識別網絡卡時第一張會是eth0,第二張才是eth1。有時候我們使用虛擬機器轉殖技術後網絡卡的資訊就會改變,新轉殖出來的虛擬主機網絡卡名字可能變為eth1.無論我們怎麼修改都無法改變,這就對我們使用n臺虛擬機器進行ha heartbeat實驗時造成了困擾。在這裡成這樣是因為複製系...

linux 網絡卡的eth0變為eth1的解決方法

1.出現的問題如下 user hadoopmain ifconfig eth1 link encap ethernet hwaddr 00 0c 29 a9 32 3d 以上情況多發生在虛擬機器轉殖新系統時!原因如下 大多數linux版本使用udev動態管理裝置檔案,udev會在系統引導的過程中識別...

Linux的網絡卡由eth0變成了eth1,如何修復

使用wmware安裝了linux,安裝成功後,使用的網絡卡是eth0,沒有eth1。但是用過一段時間後,不知道為什麼eth0無法使用,系統卻自動生成了eth1網絡卡,這可以使用ifconfig命令看的到。user localhost ifconfig eth1 link encap ethernet...