In English (para português, olhe abaixo)
To rename a network interface in Linux, switching from eth0 to eth1 and from eth1 to eth0, you should follow some steps.
1. Edit the /etc/udev/rules.d/70-persistent-net.rules file.
See bellow an example of the file:
# 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. # USB device 0x:0x (dm9601) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:4c:53:44:58", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # USB device 0x:0x (rt73usb) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1d:0f:df:59:c6", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0" # PCI device 0x10ec:0x8139 (8139too) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:08:54:6a:3a:cd", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
2. Change eth0 and eth1 names at end of lines.
See bellow the final situation (showing the relevant parts only):
[...] # USB device 0x:0x (dm9601) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:4c:53:44:58", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" [...] # PCI device 0x10ec:0x8139 (8139too) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:08:54:6a:3a:cd", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
3. Look at lines and search the kernel modules used by each network interface. We have dm9601 for eth1 and 8139too for eth0.
4. Remove and reload the kernel modules. You can use these commands:
# modprobe -r dm9601 8139too # modprobe -a dm9601 8139too
5. When you load a kernel module, udev reads the associated config file and loads the rules.
See the results:
root@canopus:~# ifconfig eth0 Link encap:Ethernet Endereço de HW 00:08:54:6a:3a:cd inet end.: 192.168.1.180 Bcast:192.168.1.255 Masc:255.255.255.0 endereço inet6: fe80::208:54ff:fe6a:3acd/64 Escopo:Link UP BROADCASTRUNNING MULTICAST MTU:1500 Métrica:1 RX packets:994 errors:0 dropped:0 overruns:0 frame:0 TX packets:1151 errors:0 dropped:0 overruns:0 carrier:0 colisões:0 txqueuelen:1000 RX bytes:663937 (648.3 KiB) TX bytes:290276 (283.4 KiB) IRQ:22 eth1 Link encap:Ethernet Endereço de HW 00:e0:4c:53:44:58 endereço inet6: fe80::2e0:4cff:fe53:4458/64 Escopo:Link UP BROADCASTMULTICAST MTU:1500 Métrica:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 colisões:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) lo Link encap:Loopback Local inet end.: 127.0.0.1 Masc:255.0.0.0 endereço inet6: ::1/128 Escopo:Máquina UP LOOPBACKRUNNING MTU:16436 Métrica:1 RX packets:26345 errors:0 dropped:0 overruns:0 frame:0 TX packets:26345 errors:0 dropped:0 overruns:0 carrier:0 colisões:0 txqueuelen:0 RX bytes:16608459 (15.8 MiB) TX bytes:16608459 (15.8 MiB)
Hope that helps.
In Portuguese
Para renomear uma interface de rede no Linux, alterando de eth0 para eth1 e de eth1 para eth0, você deve serguir alguns passos.
1. Edite o arquivo /etc/udev/rules.d/70-persistent-net.rules file.
Veja abaixo um exemplo do arquivo:
# 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. # USB device 0x:0x (dm9601) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:4c:53:44:58", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # USB device 0x:0x (rt73usb) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1d:0f:df:59:c6", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0" # PCI device 0x10ec:0x8139 (8139too) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:08:54:6a:3a:cd", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
2. Altere os nomes eth0 e eth1 no fim das linhas.
Veja abaixo a situação final (apenas as partes relevantes):
[...] # USB device 0x:0x (dm9601) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:4c:53:44:58", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" [...] # PCI device 0x10ec:0x8139 (8139too) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:08:54:6a:3a:cd", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
3. Olhe as linhas e procure pelos módulos de kernel utilizados por cada interface de rede. No caso, temos dm9601 para eth1 e 8139too para eth0.
4. Remova e recarregue os módulos de kernel. Você poderá utilizar estes comandos:
# modprobe -r dm9601 8139too # modprobe -a dm9601 8139too
5. Quando você carrega um módulo de kernel, o udev lê o arquivo de configuração relacionado e carrega as regras.
Veja os resultados:
root@canopus:~# ifconfig eth0 Link encap:Ethernet Endereço de HW 00:08:54:6a:3a:cd inet end.: 192.168.1.180 Bcast:192.168.1.255 Masc:255.255.255.0 endereço inet6: fe80::208:54ff:fe6a:3acd/64 Escopo:Link UP BROADCASTRUNNING MULTICAST MTU:1500 Métrica:1 RX packets:994 errors:0 dropped:0 overruns:0 frame:0 TX packets:1151 errors:0 dropped:0 overruns:0 carrier:0 colisões:0 txqueuelen:1000 RX bytes:663937 (648.3 KiB) TX bytes:290276 (283.4 KiB) IRQ:22 eth1 Link encap:Ethernet Endereço de HW 00:e0:4c:53:44:58 endereço inet6: fe80::2e0:4cff:fe53:4458/64 Escopo:Link UP BROADCASTMULTICAST MTU:1500 Métrica:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 colisões:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) lo Link encap:Loopback Local inet end.: 127.0.0.1 Masc:255.0.0.0 endereço inet6: ::1/128 Escopo:Máquina UP LOOPBACKRUNNING MTU:16436 Métrica:1 RX packets:26345 errors:0 dropped:0 overruns:0 frame:0 TX packets:26345 errors:0 dropped:0 overruns:0 carrier:0 colisões:0 txqueuelen:0 RX bytes:16608459 (15.8 MiB) TX bytes:16608459 (15.8 MiB)
Espero que isso ajude.
Em outros casos, criando um alias diretamente em /etc/network/interfaces, caso a necessidade seja chamar a eth0 de int(interna) e a eth1 de ext(externa) por exemplo
As possibilidades são várias 😉
Ironmaniaco, essa é uma possibilidade para outro caso. Não resolve o problema em questão.
[]s
What about change wlan (wireless interface) logical name? Any tips? Thanks!
Leo, you can use the same process. Write new name and reload the kernel module.
Please, try it and tell us the results!
Regards.