anúncios

sábado, 21 de março de 2015

Como trocar nome da interface de rede eth1 por eth0 no Linux?

Quando precisamos adicionar uma nova interface de rede, podemos notar que é atribuída eth1 ou ethN [2,...,N], mas não queriamos que alterasse a interface eth0 por eth1.
Motivos:
-Se for um Firewall, normalmente a interface eth0 recebe a conexão da internet e a eth1 é a interface da rede interna.
-Reconfiguração do sistema.
-Ferramentas que utilizam seguir a placa de rede

Como alterar a interface de rede eth1 por eth0 OU eth2 por eth0 ?
No Debian, edite o arquivo /etc/udev/rules.d/70-persistent-net.rules
#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:/sys/devices/pci0000:00/0000:00:1e.0/0000:02:08.0 (e100)
SUBSYSTEM=="net", ACTION=="addi", DRIVERS=="?*", ATTR{address}=="00:0e:a6:46:10:8f", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1904:/sys/devices/pci0000:00/0000:00:1e.0/0000:02:09.0 (sc92031)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:02:2a:e4:2f:96", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x10ec:/sys/devices/pci0000:00/0000:00:1e.0/0000:02:0a.0 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="e8:de:27:06:a7:a4", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

Observe que nesse arquivo existem 3 interfaces de redes, uma onboard e duas offboard, só alterar a interface ethX pelo índice que deseja, depois reiniciei o serviço de rede e pronto.
#/etc/init.d/networking stop
# /etc/init.d/networking start


No CentOS, o arquivo é o mesmo do Debian, /etc/udev/rules.d/70-persistent-net.rules

#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:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:2b:f5:19", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"


Basta alterar a interface ethX pelo índice desejado e reiniciar o serviço de rede.
#service network stop
# service network start

Feito!

Nenhum comentário:

Postar um comentário