{"id":1145,"date":"2012-04-07T13:27:57","date_gmt":"2012-04-07T16:27:57","guid":{"rendered":"http:\/\/eriberto.pro.br\/blog\/?p=1145"},"modified":"2017-06-20T12:02:52","modified_gmt":"2017-06-20T15:02:52","slug":"udev-renaming-an-ethernet-interface-without-reboot","status":"publish","type":"post","link":"https:\/\/eriberto.pro.br\/blog\/2012\/04\/07\/udev-renaming-an-ethernet-interface-without-reboot\/","title":{"rendered":"udev: renaming an ethernet interface without reboot"},"content":{"rendered":"<h2>In English (para portugu\u00eas, olhe abaixo)<\/h2>\n<p>To rename a network interface in Linux, switching from <em>eth0 to eth1<\/em> and from <em>eth1 to eth0<\/em>, you should follow some steps.<\/p>\n<p><strong>1. Edit the \/etc\/udev\/rules.d\/70-persistent-net.rules file.<\/strong><\/p>\n<p>See bellow an example of the file:<\/p>\n<pre>\r\n# This file was automatically generated by the \/lib\/udev\/write_net_rules\r\n# program, run by the persistent-net-generator.rules rules file.\r\n#\r\n# You can modify it, as long as you keep each rule on a single\r\n# line, and change only the value of the NAME= key.\r\n\r\n# USB device 0x:0x (dm9601)\r\nSUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"00:e0:4c:53:44:58\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"eth0\"\r\n\r\n# USB device 0x:0x (rt73usb)\r\nSUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"00:1d:0f:df:59:c6\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"wlan*\", NAME=\"wlan0\"\r\n\r\n# PCI device 0x10ec:0x8139 (8139too)\r\nSUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"00:08:54:6a:3a:cd\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"eth1\"<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>2. Change eth0 and eth1 names at end of lines.<\/strong><\/p>\n<p>See bellow the final situation (showing the relevant parts only):<\/p>\n<pre>[...]\r\n# USB device 0x:0x (dm9601)\r\nSUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"00:e0:4c:53:44:58\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"<strong>eth1<\/strong>\"\r\n\r\n[...]\r\n# PCI device 0x10ec:0x8139 (8139too)\r\nSUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"00:08:54:6a:3a:cd\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"<strong>eth0<\/strong>\"<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>3. Look at lines and search the kernel modules used by each network interface. We have <em>dm9601<\/em> for eth1 and <em>8139too<\/em> for eth0.<\/strong><\/p>\n<p><strong>4. Remove and reload the kernel modules. You can use these commands:<\/strong><\/p>\n<pre># modprobe -r dm9601 8139too\r\n# modprobe -a dm9601 8139too<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>5. When you load a kernel module, udev reads the associated config file and loads the rules.<\/strong><\/p>\n<p>See the results:<\/p>\n<pre>root@canopus:~# ifconfig\r\neth0\u00a0\u00a0\u00a0\u00a0\u00a0 Link encap:Ethernet\u00a0 Endere\u00e7o de HW 00:08:54:6a:3a:cd \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet end.: 192.168.1.180\u00a0 Bcast:192.168.1.255\u00a0 Masc:255.255.255.0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 endere\u00e7o inet6: fe80::208:54ff:fe6a:3acd\/64 Escopo:Link\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP BROADCASTRUNNING MULTICAST\u00a0 MTU:1500\u00a0 M\u00e9trica:1\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX packets:994 errors:0 dropped:0 overruns:0 frame:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TX packets:1151 errors:0 dropped:0 overruns:0 carrier:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 colis\u00f5es:0 txqueuelen:1000 \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX bytes:663937 (648.3 KiB)\u00a0 TX bytes:290276 (283.4 KiB)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 IRQ:22 \r\n\r\neth1\u00a0\u00a0\u00a0\u00a0\u00a0 Link encap:Ethernet\u00a0 Endere\u00e7o de HW 00:e0:4c:53:44:58 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 endere\u00e7o inet6: fe80::2e0:4cff:fe53:4458\/64 Escopo:Link\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP BROADCASTMULTICAST\u00a0 MTU:1500\u00a0 M\u00e9trica:1\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 colis\u00f5es:0 txqueuelen:1000 \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX bytes:0 (0.0 B)\u00a0 TX bytes:0 (0.0 B)\r\n\r\nlo\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Link encap:Loopback Local \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet end.: 127.0.0.1\u00a0 Masc:255.0.0.0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 endere\u00e7o inet6: ::1\/128 Escopo:M\u00e1quina\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP LOOPBACKRUNNING\u00a0 MTU:16436\u00a0 M\u00e9trica:1\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX packets:26345 errors:0 dropped:0 overruns:0 frame:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TX packets:26345 errors:0 dropped:0 overruns:0 carrier:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 colis\u00f5es:0 txqueuelen:0 \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX bytes:16608459 (15.8 MiB)\u00a0 TX bytes:16608459 (15.8 MiB)<\/pre>\n<p>&nbsp;<\/p>\n<p>Hope that helps.<\/p>\n<h2><\/h2>\n<h2><\/h2>\n<h2>In Portuguese<\/h2>\n<p>Para renomear uma interface de rede no Linux, alterando de <em>eth0 para eth1<\/em> e de <em>eth1 para eth0<\/em>, voc\u00ea deve serguir alguns passos.<\/p>\n<p><strong>1. Edite o arquivo \/etc\/udev\/rules.d\/70-persistent-net.rules file.<\/strong><\/p>\n<p>Veja abaixo um exemplo do arquivo:<\/p>\n<pre>\r\n# This file was automatically generated by the \/lib\/udev\/write_net_rules\r\n# program, run by the persistent-net-generator.rules rules file.\r\n#\r\n# You can modify it, as long as you keep each rule on a single\r\n# line, and change only the value of the NAME= key.\r\n\r\n# USB device 0x:0x (dm9601)\r\nSUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"00:e0:4c:53:44:58\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"eth0\"\r\n\r\n# USB device 0x:0x (rt73usb)\r\nSUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"00:1d:0f:df:59:c6\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"wlan*\", NAME=\"wlan0\"\r\n\r\n# PCI device 0x10ec:0x8139 (8139too)\r\nSUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"00:08:54:6a:3a:cd\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"eth1\"<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>2. Altere os nomes eth0 e eth1 no fim das linhas.<\/strong><\/p>\n<p>Veja abaixo a situa\u00e7\u00e3o final (apenas as partes relevantes):<\/p>\n<pre>[...]\r\n# USB device 0x:0x (dm9601)\r\nSUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"00:e0:4c:53:44:58\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"<strong>eth1<\/strong>\"\r\n\r\n[...]\r\n# PCI device 0x10ec:0x8139 (8139too)\r\nSUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"00:08:54:6a:3a:cd\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"<strong>eth0<\/strong>\"<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>3. Olhe as linhas e procure pelos m\u00f3dulos de kernel utilizados por cada interface de rede. No caso, temos <em>dm9601<\/em> para eth1 e <em>8139too<\/em> para eth0.<\/strong><\/p>\n<p><strong>4. Remova e recarregue os m\u00f3dulos de kernel. Voc\u00ea poder\u00e1 utilizar estes comandos:<\/strong><\/p>\n<pre># modprobe -r dm9601 8139too\r\n# modprobe -a dm9601 8139too<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>5. Quando voc\u00ea carrega um m\u00f3dulo de kernel, o udev l\u00ea o arquivo de configura\u00e7\u00e3o relacionado e carrega as regras.<\/strong><\/p>\n<p>Veja os resultados:<\/p>\n<pre>root@canopus:~# ifconfig\r\neth0\u00a0\u00a0\u00a0\u00a0\u00a0 Link encap:Ethernet\u00a0 Endere\u00e7o de HW 00:08:54:6a:3a:cd \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet end.: 192.168.1.180\u00a0 Bcast:192.168.1.255\u00a0 Masc:255.255.255.0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 endere\u00e7o inet6: fe80::208:54ff:fe6a:3acd\/64 Escopo:Link\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP BROADCASTRUNNING MULTICAST\u00a0 MTU:1500\u00a0 M\u00e9trica:1\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX packets:994 errors:0 dropped:0 overruns:0 frame:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TX packets:1151 errors:0 dropped:0 overruns:0 carrier:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 colis\u00f5es:0 txqueuelen:1000 \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX bytes:663937 (648.3 KiB)\u00a0 TX bytes:290276 (283.4 KiB)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 IRQ:22 \r\n\r\neth1\u00a0\u00a0\u00a0\u00a0\u00a0 Link encap:Ethernet\u00a0 Endere\u00e7o de HW 00:e0:4c:53:44:58 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 endere\u00e7o inet6: fe80::2e0:4cff:fe53:4458\/64 Escopo:Link\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP BROADCASTMULTICAST\u00a0 MTU:1500\u00a0 M\u00e9trica:1\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 colis\u00f5es:0 txqueuelen:1000 \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX bytes:0 (0.0 B)\u00a0 TX bytes:0 (0.0 B)\r\n\r\nlo\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Link encap:Loopback Local \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet end.: 127.0.0.1\u00a0 Masc:255.0.0.0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 endere\u00e7o inet6: ::1\/128 Escopo:M\u00e1quina\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP LOOPBACKRUNNING\u00a0 MTU:16436\u00a0 M\u00e9trica:1\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX packets:26345 errors:0 dropped:0 overruns:0 frame:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TX packets:26345 errors:0 dropped:0 overruns:0 carrier:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 colis\u00f5es:0 txqueuelen:0 \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX bytes:16608459 (15.8 MiB)\u00a0 TX bytes:16608459 (15.8 MiB)<\/pre>\n<p>&nbsp;<\/p>\n<p>Espero que isso ajude.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In English (para portugu\u00eas, 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&hellip;&nbsp;<a href=\"https:\/\/eriberto.pro.br\/blog\/2012\/04\/07\/udev-renaming-an-ethernet-interface-without-reboot\/\" rel=\"bookmark\">Continue a ler &raquo;<span class=\"screen-reader-text\">udev: renaming an ethernet interface without reboot<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"categories":[16,13,12,3,11],"tags":[624,500,501,502,478,494,498,493,621,499,667,495,622,497,496,131,492,214],"class_list":["post-1145","post","type-post","status-publish","format-standard","hentry","category-debian","category-hardware","category-kernel","category-linux","category-sistema-operacional","tag-debian","tag-eth0","tag-eth1","tag-eth2","tag-hardware-2","tag-hotplug","tag-interfaces","tag-kernel-2","tag-linux","tag-names","tag-planet-en","tag-plug-and-play","tag-rede","tag-reload","tag-restart","tag-squeeze","tag-udev","tag-wheezy"],"_links":{"self":[{"href":"https:\/\/eriberto.pro.br\/blog\/wp-json\/wp\/v2\/posts\/1145","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eriberto.pro.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eriberto.pro.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eriberto.pro.br\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/eriberto.pro.br\/blog\/wp-json\/wp\/v2\/comments?post=1145"}],"version-history":[{"count":1,"href":"https:\/\/eriberto.pro.br\/blog\/wp-json\/wp\/v2\/posts\/1145\/revisions"}],"predecessor-version":[{"id":2317,"href":"https:\/\/eriberto.pro.br\/blog\/wp-json\/wp\/v2\/posts\/1145\/revisions\/2317"}],"wp:attachment":[{"href":"https:\/\/eriberto.pro.br\/blog\/wp-json\/wp\/v2\/media?parent=1145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eriberto.pro.br\/blog\/wp-json\/wp\/v2\/categories?post=1145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eriberto.pro.br\/blog\/wp-json\/wp\/v2\/tags?post=1145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}