CentOS 7 - Rename network interface without rebooting

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
17
down vote

favorite
9












I'm renaming network interfaces by modifying the files in /etc/sysconfig/network-scripts.



  • eth0 -> nic0

  • eth1 -> nic1

The content of the network scripts looks like this, after modification:



# cat /etc/sysconfig/network-scripts/ifcfg-nic0
DEVICE=nic0
BOOTPROTO=static
ONBOOT=yes
HWADDR=xx:xx:xx:xx:xx:xx
USERCTL=no
IPV6INIT=no
MASTER=bond0
SLAVE=yes


A reboot activates the new config. But how do I activate this configuration without rebooting?



A systemctl restart network doesn't do the trick.



I can shut down one interface by its old name (ifdown eth0) but ifup results in below message no matter if the old or new name was provided:




ERROR : [/etc/sysconfig/network-scripts/ifup-eth] Device nic0 does not seem to be present, delaying initialization.




/etc/init.d/network status shows this output:



Configured devices:
lo bond0 nic0 nic1
Currently active devices:
lo eth0 eth1 bond0


Both, ifconfig and ip a show the old interface names.










share|improve this question



















  • 1




    You might try removing and reloading the network device drivers, if they're compiled as kernel modules.
    – Tom Hunt
    May 27 '15 at 1:39














up vote
17
down vote

favorite
9












I'm renaming network interfaces by modifying the files in /etc/sysconfig/network-scripts.



  • eth0 -> nic0

  • eth1 -> nic1

The content of the network scripts looks like this, after modification:



# cat /etc/sysconfig/network-scripts/ifcfg-nic0
DEVICE=nic0
BOOTPROTO=static
ONBOOT=yes
HWADDR=xx:xx:xx:xx:xx:xx
USERCTL=no
IPV6INIT=no
MASTER=bond0
SLAVE=yes


A reboot activates the new config. But how do I activate this configuration without rebooting?



A systemctl restart network doesn't do the trick.



I can shut down one interface by its old name (ifdown eth0) but ifup results in below message no matter if the old or new name was provided:




ERROR : [/etc/sysconfig/network-scripts/ifup-eth] Device nic0 does not seem to be present, delaying initialization.




/etc/init.d/network status shows this output:



Configured devices:
lo bond0 nic0 nic1
Currently active devices:
lo eth0 eth1 bond0


Both, ifconfig and ip a show the old interface names.










share|improve this question



















  • 1




    You might try removing and reloading the network device drivers, if they're compiled as kernel modules.
    – Tom Hunt
    May 27 '15 at 1:39












up vote
17
down vote

favorite
9









up vote
17
down vote

favorite
9






9





I'm renaming network interfaces by modifying the files in /etc/sysconfig/network-scripts.



  • eth0 -> nic0

  • eth1 -> nic1

The content of the network scripts looks like this, after modification:



# cat /etc/sysconfig/network-scripts/ifcfg-nic0
DEVICE=nic0
BOOTPROTO=static
ONBOOT=yes
HWADDR=xx:xx:xx:xx:xx:xx
USERCTL=no
IPV6INIT=no
MASTER=bond0
SLAVE=yes


A reboot activates the new config. But how do I activate this configuration without rebooting?



A systemctl restart network doesn't do the trick.



I can shut down one interface by its old name (ifdown eth0) but ifup results in below message no matter if the old or new name was provided:




ERROR : [/etc/sysconfig/network-scripts/ifup-eth] Device nic0 does not seem to be present, delaying initialization.




/etc/init.d/network status shows this output:



Configured devices:
lo bond0 nic0 nic1
Currently active devices:
lo eth0 eth1 bond0


Both, ifconfig and ip a show the old interface names.










share|improve this question















I'm renaming network interfaces by modifying the files in /etc/sysconfig/network-scripts.



  • eth0 -> nic0

  • eth1 -> nic1

The content of the network scripts looks like this, after modification:



# cat /etc/sysconfig/network-scripts/ifcfg-nic0
DEVICE=nic0
BOOTPROTO=static
ONBOOT=yes
HWADDR=xx:xx:xx:xx:xx:xx
USERCTL=no
IPV6INIT=no
MASTER=bond0
SLAVE=yes


A reboot activates the new config. But how do I activate this configuration without rebooting?



A systemctl restart network doesn't do the trick.



I can shut down one interface by its old name (ifdown eth0) but ifup results in below message no matter if the old or new name was provided:




ERROR : [/etc/sysconfig/network-scripts/ifup-eth] Device nic0 does not seem to be present, delaying initialization.




/etc/init.d/network status shows this output:



Configured devices:
lo bond0 nic0 nic1
Currently active devices:
lo eth0 eth1 bond0


Both, ifconfig and ip a show the old interface names.







centos configuration network-interface






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 6 '16 at 4:29

























asked May 22 '15 at 9:07









udondan

238128




238128







  • 1




    You might try removing and reloading the network device drivers, if they're compiled as kernel modules.
    – Tom Hunt
    May 27 '15 at 1:39












  • 1




    You might try removing and reloading the network device drivers, if they're compiled as kernel modules.
    – Tom Hunt
    May 27 '15 at 1:39







1




1




You might try removing and reloading the network device drivers, if they're compiled as kernel modules.
– Tom Hunt
May 27 '15 at 1:39




You might try removing and reloading the network device drivers, if they're compiled as kernel modules.
– Tom Hunt
May 27 '15 at 1:39










5 Answers
5






active

oldest

votes

















up vote
23
down vote



accepted










You can rename the device using the ip command:



/sbin/ip link set eth1 down
/sbin/ip link set eth1 name eth123
/sbin/ip link set eth123 up


Edit:




I am leaving the below for the sake of completeness and posterity (and for informational purposes,) but I have confirmed swill's comment and Marco Macuzzo's answer that simply changing the name and device of the interface /etc/sysconfig/network-scripts/ifcfg-eth0 (and renaming the file) will cause the device to be named correctly as long as the hwaddr= field is included in the configuration file. I recommend using this method instead after the referenced update.




You may also want to make sure that you configure a udev rule, so that this will work on the next reboot too. The path for udev moved in CentOS 7 to /usr/lib/udev/rules.d/60-net.rules but you are still able to manage it the same way. If you added "net.ifnames=0 biosdevname=0" to your kernel boot string to return to the old naming scheme for your nics, you can remove



ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTRtype=="1", PROGRAM="/lib/udev/rename_device", RESULT=="?*", NAME="$result"


And replace it with



ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTRaddress=="00:50:56:8e:3f:a7", NAME="eth123"


You need one entry per nic. Be sure to use the correct MAC address and update the NAME field. If you did not use "net.ifnames=0 biosdevname=0", be careful as there could be unintended consequences.






share|improve this answer


















  • 1




    Just a note on this. If you are using CentOS 7.3, then this does not work. This is because of this issue (access.redhat.com/solutions/2592561). You will have to override the file at /etc/udev/rules.d/90-eno-fix.rules because it overrides all previously working solutions to rename the network devices.
    – swill
    Mar 15 '17 at 17:47










  • Looking at the advisory you referenced, it notes "This issue can be avoided by updating installation repositories to include the systemd-219-30.el7_3.6 or later package. With this newer systemd release, affected interfaces are identified upon the package install and a udev rule is automatically generated so the renaming issue is entirely avoided."
    – James Shewey
    Mar 15 '17 at 19:46










  • That is a different rename issue they are referring to. They are talking about the name being shortened because it is too long (I think). The udev rule that is mentioned hard codes the interface name to an eno######## value which overrides all of these attempts to rename it to something like eth0. Does that make sense? I will have to verify on my machine which version I am using, but I upgraded to the latest CentOS 7.3 yesterday, so I think I will have the version mentioned.
    – swill
    Mar 16 '17 at 21:23

















up vote
7
down vote













Actually, the best answer I believe is the combination of the two answers already posted. In order to change the device name without restarting network services, use the ip link commands suggested by James Shewey (ip link set <old_device_name>; name <new_device_name>).



To make the changes survive a reboot in Red Hat Linux, modify the relevant file in /etc/sysconfig/network-scripts/. Rename the file ifcfg_<old_device_name> to ifcfg_<new_device_name> and change the DEVICE variable inside to <new_device_name>. Also, make sure the HWADDR variable is set and is correct. There is no need to touch udev rules, since 60-net.rules is actually there to read the ifcfg configuration files in /etc/sysconfig/network-scripts.






share|improve this answer




















  • The ip link set ... name ... command shouldn't contain a semicolon.
    – Alexander Gonchiy
    Jan 23 '17 at 8:17

















up vote
2
down vote













The Answer given by @James Shewey seems to be the right way to do it.



If you want to just work with the config files in /etc/sysconfig/network-scripts and then trigger a reload, unloading and loading the kernel module as mentioned by @Tom Hunt in the comments also works:



service network stop
modprobe -r igb
modprobe igb
service network start


If you access the machine remotely, make sure you run all commands in a nohup or you will lock yourself out:



nohup sh -c "service network stop && modprobe -r igb && modprobe igb ; service network start"


The driver to reload of course depends on your interface.






share|improve this answer



























    up vote
    2
    down vote













    To restore the old naming convention, you need to edit the /etc/default/grub file and add the following



    net.ifnames=0 biosdevname=0 


    at the end of the GRUB_CMDLINE_LINUX variable






    share|improve this answer






















    • Or simply removing the biosdevname package if it's installed
      – GAD3R
      Nov 18 '16 at 13:06


















    up vote
    0
    down vote













    ip link set ens33 down
    ip link set ens33 name eth0
    ip link set eth0 up

    mv /etc/sysconfig/network-scripts/ifcfg-ens33,eth0

    sed -ire "s/NAME="ens33"/NAME="eth0"/" /etc/sysconfig/network-scripts/ifcfg-eth0

    sed -ire "s/DEVICE="ens33"/NAME="eth0"/" /etc/sysconfig/network-scripts/ifcfg-eth0

    MAC=$(cat /sys/class/net/eth0/address)

    echo -n 'HWADDR="'$MAC" >> /etc/sysconfig/network-scripts/ifcfg-eth0





    share|improve this answer




















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f205010%2fcentos-7-rename-network-interface-without-rebooting%23new-answer', 'question_page');

      );

      Post as a guest






























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      23
      down vote



      accepted










      You can rename the device using the ip command:



      /sbin/ip link set eth1 down
      /sbin/ip link set eth1 name eth123
      /sbin/ip link set eth123 up


      Edit:




      I am leaving the below for the sake of completeness and posterity (and for informational purposes,) but I have confirmed swill's comment and Marco Macuzzo's answer that simply changing the name and device of the interface /etc/sysconfig/network-scripts/ifcfg-eth0 (and renaming the file) will cause the device to be named correctly as long as the hwaddr= field is included in the configuration file. I recommend using this method instead after the referenced update.




      You may also want to make sure that you configure a udev rule, so that this will work on the next reboot too. The path for udev moved in CentOS 7 to /usr/lib/udev/rules.d/60-net.rules but you are still able to manage it the same way. If you added "net.ifnames=0 biosdevname=0" to your kernel boot string to return to the old naming scheme for your nics, you can remove



      ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTRtype=="1", PROGRAM="/lib/udev/rename_device", RESULT=="?*", NAME="$result"


      And replace it with



      ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTRaddress=="00:50:56:8e:3f:a7", NAME="eth123"


      You need one entry per nic. Be sure to use the correct MAC address and update the NAME field. If you did not use "net.ifnames=0 biosdevname=0", be careful as there could be unintended consequences.






      share|improve this answer


















      • 1




        Just a note on this. If you are using CentOS 7.3, then this does not work. This is because of this issue (access.redhat.com/solutions/2592561). You will have to override the file at /etc/udev/rules.d/90-eno-fix.rules because it overrides all previously working solutions to rename the network devices.
        – swill
        Mar 15 '17 at 17:47










      • Looking at the advisory you referenced, it notes "This issue can be avoided by updating installation repositories to include the systemd-219-30.el7_3.6 or later package. With this newer systemd release, affected interfaces are identified upon the package install and a udev rule is automatically generated so the renaming issue is entirely avoided."
        – James Shewey
        Mar 15 '17 at 19:46










      • That is a different rename issue they are referring to. They are talking about the name being shortened because it is too long (I think). The udev rule that is mentioned hard codes the interface name to an eno######## value which overrides all of these attempts to rename it to something like eth0. Does that make sense? I will have to verify on my machine which version I am using, but I upgraded to the latest CentOS 7.3 yesterday, so I think I will have the version mentioned.
        – swill
        Mar 16 '17 at 21:23














      up vote
      23
      down vote



      accepted










      You can rename the device using the ip command:



      /sbin/ip link set eth1 down
      /sbin/ip link set eth1 name eth123
      /sbin/ip link set eth123 up


      Edit:




      I am leaving the below for the sake of completeness and posterity (and for informational purposes,) but I have confirmed swill's comment and Marco Macuzzo's answer that simply changing the name and device of the interface /etc/sysconfig/network-scripts/ifcfg-eth0 (and renaming the file) will cause the device to be named correctly as long as the hwaddr= field is included in the configuration file. I recommend using this method instead after the referenced update.




      You may also want to make sure that you configure a udev rule, so that this will work on the next reboot too. The path for udev moved in CentOS 7 to /usr/lib/udev/rules.d/60-net.rules but you are still able to manage it the same way. If you added "net.ifnames=0 biosdevname=0" to your kernel boot string to return to the old naming scheme for your nics, you can remove



      ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTRtype=="1", PROGRAM="/lib/udev/rename_device", RESULT=="?*", NAME="$result"


      And replace it with



      ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTRaddress=="00:50:56:8e:3f:a7", NAME="eth123"


      You need one entry per nic. Be sure to use the correct MAC address and update the NAME field. If you did not use "net.ifnames=0 biosdevname=0", be careful as there could be unintended consequences.






      share|improve this answer


















      • 1




        Just a note on this. If you are using CentOS 7.3, then this does not work. This is because of this issue (access.redhat.com/solutions/2592561). You will have to override the file at /etc/udev/rules.d/90-eno-fix.rules because it overrides all previously working solutions to rename the network devices.
        – swill
        Mar 15 '17 at 17:47










      • Looking at the advisory you referenced, it notes "This issue can be avoided by updating installation repositories to include the systemd-219-30.el7_3.6 or later package. With this newer systemd release, affected interfaces are identified upon the package install and a udev rule is automatically generated so the renaming issue is entirely avoided."
        – James Shewey
        Mar 15 '17 at 19:46










      • That is a different rename issue they are referring to. They are talking about the name being shortened because it is too long (I think). The udev rule that is mentioned hard codes the interface name to an eno######## value which overrides all of these attempts to rename it to something like eth0. Does that make sense? I will have to verify on my machine which version I am using, but I upgraded to the latest CentOS 7.3 yesterday, so I think I will have the version mentioned.
        – swill
        Mar 16 '17 at 21:23












      up vote
      23
      down vote



      accepted







      up vote
      23
      down vote



      accepted






      You can rename the device using the ip command:



      /sbin/ip link set eth1 down
      /sbin/ip link set eth1 name eth123
      /sbin/ip link set eth123 up


      Edit:




      I am leaving the below for the sake of completeness and posterity (and for informational purposes,) but I have confirmed swill's comment and Marco Macuzzo's answer that simply changing the name and device of the interface /etc/sysconfig/network-scripts/ifcfg-eth0 (and renaming the file) will cause the device to be named correctly as long as the hwaddr= field is included in the configuration file. I recommend using this method instead after the referenced update.




      You may also want to make sure that you configure a udev rule, so that this will work on the next reboot too. The path for udev moved in CentOS 7 to /usr/lib/udev/rules.d/60-net.rules but you are still able to manage it the same way. If you added "net.ifnames=0 biosdevname=0" to your kernel boot string to return to the old naming scheme for your nics, you can remove



      ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTRtype=="1", PROGRAM="/lib/udev/rename_device", RESULT=="?*", NAME="$result"


      And replace it with



      ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTRaddress=="00:50:56:8e:3f:a7", NAME="eth123"


      You need one entry per nic. Be sure to use the correct MAC address and update the NAME field. If you did not use "net.ifnames=0 biosdevname=0", be careful as there could be unintended consequences.






      share|improve this answer














      You can rename the device using the ip command:



      /sbin/ip link set eth1 down
      /sbin/ip link set eth1 name eth123
      /sbin/ip link set eth123 up


      Edit:




      I am leaving the below for the sake of completeness and posterity (and for informational purposes,) but I have confirmed swill's comment and Marco Macuzzo's answer that simply changing the name and device of the interface /etc/sysconfig/network-scripts/ifcfg-eth0 (and renaming the file) will cause the device to be named correctly as long as the hwaddr= field is included in the configuration file. I recommend using this method instead after the referenced update.




      You may also want to make sure that you configure a udev rule, so that this will work on the next reboot too. The path for udev moved in CentOS 7 to /usr/lib/udev/rules.d/60-net.rules but you are still able to manage it the same way. If you added "net.ifnames=0 biosdevname=0" to your kernel boot string to return to the old naming scheme for your nics, you can remove



      ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTRtype=="1", PROGRAM="/lib/udev/rename_device", RESULT=="?*", NAME="$result"


      And replace it with



      ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTRaddress=="00:50:56:8e:3f:a7", NAME="eth123"


      You need one entry per nic. Be sure to use the correct MAC address and update the NAME field. If you did not use "net.ifnames=0 biosdevname=0", be careful as there could be unintended consequences.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited May 29 '17 at 3:03

























      answered Jul 30 '15 at 15:26









      James Shewey

      4581512




      4581512







      • 1




        Just a note on this. If you are using CentOS 7.3, then this does not work. This is because of this issue (access.redhat.com/solutions/2592561). You will have to override the file at /etc/udev/rules.d/90-eno-fix.rules because it overrides all previously working solutions to rename the network devices.
        – swill
        Mar 15 '17 at 17:47










      • Looking at the advisory you referenced, it notes "This issue can be avoided by updating installation repositories to include the systemd-219-30.el7_3.6 or later package. With this newer systemd release, affected interfaces are identified upon the package install and a udev rule is automatically generated so the renaming issue is entirely avoided."
        – James Shewey
        Mar 15 '17 at 19:46










      • That is a different rename issue they are referring to. They are talking about the name being shortened because it is too long (I think). The udev rule that is mentioned hard codes the interface name to an eno######## value which overrides all of these attempts to rename it to something like eth0. Does that make sense? I will have to verify on my machine which version I am using, but I upgraded to the latest CentOS 7.3 yesterday, so I think I will have the version mentioned.
        – swill
        Mar 16 '17 at 21:23












      • 1




        Just a note on this. If you are using CentOS 7.3, then this does not work. This is because of this issue (access.redhat.com/solutions/2592561). You will have to override the file at /etc/udev/rules.d/90-eno-fix.rules because it overrides all previously working solutions to rename the network devices.
        – swill
        Mar 15 '17 at 17:47










      • Looking at the advisory you referenced, it notes "This issue can be avoided by updating installation repositories to include the systemd-219-30.el7_3.6 or later package. With this newer systemd release, affected interfaces are identified upon the package install and a udev rule is automatically generated so the renaming issue is entirely avoided."
        – James Shewey
        Mar 15 '17 at 19:46










      • That is a different rename issue they are referring to. They are talking about the name being shortened because it is too long (I think). The udev rule that is mentioned hard codes the interface name to an eno######## value which overrides all of these attempts to rename it to something like eth0. Does that make sense? I will have to verify on my machine which version I am using, but I upgraded to the latest CentOS 7.3 yesterday, so I think I will have the version mentioned.
        – swill
        Mar 16 '17 at 21:23







      1




      1




      Just a note on this. If you are using CentOS 7.3, then this does not work. This is because of this issue (access.redhat.com/solutions/2592561). You will have to override the file at /etc/udev/rules.d/90-eno-fix.rules because it overrides all previously working solutions to rename the network devices.
      – swill
      Mar 15 '17 at 17:47




      Just a note on this. If you are using CentOS 7.3, then this does not work. This is because of this issue (access.redhat.com/solutions/2592561). You will have to override the file at /etc/udev/rules.d/90-eno-fix.rules because it overrides all previously working solutions to rename the network devices.
      – swill
      Mar 15 '17 at 17:47












      Looking at the advisory you referenced, it notes "This issue can be avoided by updating installation repositories to include the systemd-219-30.el7_3.6 or later package. With this newer systemd release, affected interfaces are identified upon the package install and a udev rule is automatically generated so the renaming issue is entirely avoided."
      – James Shewey
      Mar 15 '17 at 19:46




      Looking at the advisory you referenced, it notes "This issue can be avoided by updating installation repositories to include the systemd-219-30.el7_3.6 or later package. With this newer systemd release, affected interfaces are identified upon the package install and a udev rule is automatically generated so the renaming issue is entirely avoided."
      – James Shewey
      Mar 15 '17 at 19:46












      That is a different rename issue they are referring to. They are talking about the name being shortened because it is too long (I think). The udev rule that is mentioned hard codes the interface name to an eno######## value which overrides all of these attempts to rename it to something like eth0. Does that make sense? I will have to verify on my machine which version I am using, but I upgraded to the latest CentOS 7.3 yesterday, so I think I will have the version mentioned.
      – swill
      Mar 16 '17 at 21:23




      That is a different rename issue they are referring to. They are talking about the name being shortened because it is too long (I think). The udev rule that is mentioned hard codes the interface name to an eno######## value which overrides all of these attempts to rename it to something like eth0. Does that make sense? I will have to verify on my machine which version I am using, but I upgraded to the latest CentOS 7.3 yesterday, so I think I will have the version mentioned.
      – swill
      Mar 16 '17 at 21:23












      up vote
      7
      down vote













      Actually, the best answer I believe is the combination of the two answers already posted. In order to change the device name without restarting network services, use the ip link commands suggested by James Shewey (ip link set <old_device_name>; name <new_device_name>).



      To make the changes survive a reboot in Red Hat Linux, modify the relevant file in /etc/sysconfig/network-scripts/. Rename the file ifcfg_<old_device_name> to ifcfg_<new_device_name> and change the DEVICE variable inside to <new_device_name>. Also, make sure the HWADDR variable is set and is correct. There is no need to touch udev rules, since 60-net.rules is actually there to read the ifcfg configuration files in /etc/sysconfig/network-scripts.






      share|improve this answer




















      • The ip link set ... name ... command shouldn't contain a semicolon.
        – Alexander Gonchiy
        Jan 23 '17 at 8:17














      up vote
      7
      down vote













      Actually, the best answer I believe is the combination of the two answers already posted. In order to change the device name without restarting network services, use the ip link commands suggested by James Shewey (ip link set <old_device_name>; name <new_device_name>).



      To make the changes survive a reboot in Red Hat Linux, modify the relevant file in /etc/sysconfig/network-scripts/. Rename the file ifcfg_<old_device_name> to ifcfg_<new_device_name> and change the DEVICE variable inside to <new_device_name>. Also, make sure the HWADDR variable is set and is correct. There is no need to touch udev rules, since 60-net.rules is actually there to read the ifcfg configuration files in /etc/sysconfig/network-scripts.






      share|improve this answer




















      • The ip link set ... name ... command shouldn't contain a semicolon.
        – Alexander Gonchiy
        Jan 23 '17 at 8:17












      up vote
      7
      down vote










      up vote
      7
      down vote









      Actually, the best answer I believe is the combination of the two answers already posted. In order to change the device name without restarting network services, use the ip link commands suggested by James Shewey (ip link set <old_device_name>; name <new_device_name>).



      To make the changes survive a reboot in Red Hat Linux, modify the relevant file in /etc/sysconfig/network-scripts/. Rename the file ifcfg_<old_device_name> to ifcfg_<new_device_name> and change the DEVICE variable inside to <new_device_name>. Also, make sure the HWADDR variable is set and is correct. There is no need to touch udev rules, since 60-net.rules is actually there to read the ifcfg configuration files in /etc/sysconfig/network-scripts.






      share|improve this answer












      Actually, the best answer I believe is the combination of the two answers already posted. In order to change the device name without restarting network services, use the ip link commands suggested by James Shewey (ip link set <old_device_name>; name <new_device_name>).



      To make the changes survive a reboot in Red Hat Linux, modify the relevant file in /etc/sysconfig/network-scripts/. Rename the file ifcfg_<old_device_name> to ifcfg_<new_device_name> and change the DEVICE variable inside to <new_device_name>. Also, make sure the HWADDR variable is set and is correct. There is no need to touch udev rules, since 60-net.rules is actually there to read the ifcfg configuration files in /etc/sysconfig/network-scripts.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Jun 20 '16 at 8:16









      Marco Mazzucco

      7111




      7111











      • The ip link set ... name ... command shouldn't contain a semicolon.
        – Alexander Gonchiy
        Jan 23 '17 at 8:17
















      • The ip link set ... name ... command shouldn't contain a semicolon.
        – Alexander Gonchiy
        Jan 23 '17 at 8:17















      The ip link set ... name ... command shouldn't contain a semicolon.
      – Alexander Gonchiy
      Jan 23 '17 at 8:17




      The ip link set ... name ... command shouldn't contain a semicolon.
      – Alexander Gonchiy
      Jan 23 '17 at 8:17










      up vote
      2
      down vote













      The Answer given by @James Shewey seems to be the right way to do it.



      If you want to just work with the config files in /etc/sysconfig/network-scripts and then trigger a reload, unloading and loading the kernel module as mentioned by @Tom Hunt in the comments also works:



      service network stop
      modprobe -r igb
      modprobe igb
      service network start


      If you access the machine remotely, make sure you run all commands in a nohup or you will lock yourself out:



      nohup sh -c "service network stop && modprobe -r igb && modprobe igb ; service network start"


      The driver to reload of course depends on your interface.






      share|improve this answer
























        up vote
        2
        down vote













        The Answer given by @James Shewey seems to be the right way to do it.



        If you want to just work with the config files in /etc/sysconfig/network-scripts and then trigger a reload, unloading and loading the kernel module as mentioned by @Tom Hunt in the comments also works:



        service network stop
        modprobe -r igb
        modprobe igb
        service network start


        If you access the machine remotely, make sure you run all commands in a nohup or you will lock yourself out:



        nohup sh -c "service network stop && modprobe -r igb && modprobe igb ; service network start"


        The driver to reload of course depends on your interface.






        share|improve this answer






















          up vote
          2
          down vote










          up vote
          2
          down vote









          The Answer given by @James Shewey seems to be the right way to do it.



          If you want to just work with the config files in /etc/sysconfig/network-scripts and then trigger a reload, unloading and loading the kernel module as mentioned by @Tom Hunt in the comments also works:



          service network stop
          modprobe -r igb
          modprobe igb
          service network start


          If you access the machine remotely, make sure you run all commands in a nohup or you will lock yourself out:



          nohup sh -c "service network stop && modprobe -r igb && modprobe igb ; service network start"


          The driver to reload of course depends on your interface.






          share|improve this answer












          The Answer given by @James Shewey seems to be the right way to do it.



          If you want to just work with the config files in /etc/sysconfig/network-scripts and then trigger a reload, unloading and loading the kernel module as mentioned by @Tom Hunt in the comments also works:



          service network stop
          modprobe -r igb
          modprobe igb
          service network start


          If you access the machine remotely, make sure you run all commands in a nohup or you will lock yourself out:



          nohup sh -c "service network stop && modprobe -r igb && modprobe igb ; service network start"


          The driver to reload of course depends on your interface.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 1 '16 at 13:13









          udondan

          238128




          238128




















              up vote
              2
              down vote













              To restore the old naming convention, you need to edit the /etc/default/grub file and add the following



              net.ifnames=0 biosdevname=0 


              at the end of the GRUB_CMDLINE_LINUX variable






              share|improve this answer






















              • Or simply removing the biosdevname package if it's installed
                – GAD3R
                Nov 18 '16 at 13:06















              up vote
              2
              down vote













              To restore the old naming convention, you need to edit the /etc/default/grub file and add the following



              net.ifnames=0 biosdevname=0 


              at the end of the GRUB_CMDLINE_LINUX variable






              share|improve this answer






















              • Or simply removing the biosdevname package if it's installed
                – GAD3R
                Nov 18 '16 at 13:06













              up vote
              2
              down vote










              up vote
              2
              down vote









              To restore the old naming convention, you need to edit the /etc/default/grub file and add the following



              net.ifnames=0 biosdevname=0 


              at the end of the GRUB_CMDLINE_LINUX variable






              share|improve this answer














              To restore the old naming convention, you need to edit the /etc/default/grub file and add the following



              net.ifnames=0 biosdevname=0 


              at the end of the GRUB_CMDLINE_LINUX variable







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 18 '16 at 13:03









              Thomas

              3,64141225




              3,64141225










              answered Nov 18 '16 at 12:44









              Mark

              211




              211











              • Or simply removing the biosdevname package if it's installed
                – GAD3R
                Nov 18 '16 at 13:06

















              • Or simply removing the biosdevname package if it's installed
                – GAD3R
                Nov 18 '16 at 13:06
















              Or simply removing the biosdevname package if it's installed
              – GAD3R
              Nov 18 '16 at 13:06





              Or simply removing the biosdevname package if it's installed
              – GAD3R
              Nov 18 '16 at 13:06











              up vote
              0
              down vote













              ip link set ens33 down
              ip link set ens33 name eth0
              ip link set eth0 up

              mv /etc/sysconfig/network-scripts/ifcfg-ens33,eth0

              sed -ire "s/NAME="ens33"/NAME="eth0"/" /etc/sysconfig/network-scripts/ifcfg-eth0

              sed -ire "s/DEVICE="ens33"/NAME="eth0"/" /etc/sysconfig/network-scripts/ifcfg-eth0

              MAC=$(cat /sys/class/net/eth0/address)

              echo -n 'HWADDR="'$MAC" >> /etc/sysconfig/network-scripts/ifcfg-eth0





              share|improve this answer
























                up vote
                0
                down vote













                ip link set ens33 down
                ip link set ens33 name eth0
                ip link set eth0 up

                mv /etc/sysconfig/network-scripts/ifcfg-ens33,eth0

                sed -ire "s/NAME="ens33"/NAME="eth0"/" /etc/sysconfig/network-scripts/ifcfg-eth0

                sed -ire "s/DEVICE="ens33"/NAME="eth0"/" /etc/sysconfig/network-scripts/ifcfg-eth0

                MAC=$(cat /sys/class/net/eth0/address)

                echo -n 'HWADDR="'$MAC" >> /etc/sysconfig/network-scripts/ifcfg-eth0





                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  ip link set ens33 down
                  ip link set ens33 name eth0
                  ip link set eth0 up

                  mv /etc/sysconfig/network-scripts/ifcfg-ens33,eth0

                  sed -ire "s/NAME="ens33"/NAME="eth0"/" /etc/sysconfig/network-scripts/ifcfg-eth0

                  sed -ire "s/DEVICE="ens33"/NAME="eth0"/" /etc/sysconfig/network-scripts/ifcfg-eth0

                  MAC=$(cat /sys/class/net/eth0/address)

                  echo -n 'HWADDR="'$MAC" >> /etc/sysconfig/network-scripts/ifcfg-eth0





                  share|improve this answer












                  ip link set ens33 down
                  ip link set ens33 name eth0
                  ip link set eth0 up

                  mv /etc/sysconfig/network-scripts/ifcfg-ens33,eth0

                  sed -ire "s/NAME="ens33"/NAME="eth0"/" /etc/sysconfig/network-scripts/ifcfg-eth0

                  sed -ire "s/DEVICE="ens33"/NAME="eth0"/" /etc/sysconfig/network-scripts/ifcfg-eth0

                  MAC=$(cat /sys/class/net/eth0/address)

                  echo -n 'HWADDR="'$MAC" >> /etc/sysconfig/network-scripts/ifcfg-eth0






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Sep 13 at 18:10









                  TJ Zimmerman

                  113




                  113



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f205010%2fcentos-7-rename-network-interface-without-rebooting%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay