Ethernet Device Configuration

From WilliamsNet Wiki
Jump to navigation Jump to search

Temporary (no reboot required)[edit]

Change the name of the device realtime -- no reboot required

  • NOTE: this is optional, as it will reset on the next boot.
  • This can be done remotely on the active interface by putting the commands all on one line separated with ';'
/sbin/ip link set <oldname> down
/sbin/ip link set <oldname> name <newname>
/sbin/ip link set <newname> up

CentOS 7[edit]

This process was extracted from a stackexchange article: https://unix.stackexchange.com/questions/205010/centos-7-rename-network-interface-without-rebooting

From the article:

"I have confirmed ... that simply changing the name and device of the interface [in] /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."

So ... at this point, edit the /etc/sysconfig/network-scripts/ifcfg-<oldname> file:

  • change DEVICE to <newname>
  • change NAME to <newname>
  • add HWADDR with the MAC address of the interface
  • rename the file to ifcfg-<newname>

At this point it is cleanest if you reboot -- and then make sure everything is connected properly. If you can't reboot, at least restart the network with systemctl. Don't forget to update any other config files that contain interface names to reflect the new names.

Debian 10[edit]

There are 2 files that need to be changed to make changes permanent.

Append something like this to /etc/udev/rules.d/70-persistent-net.rules

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="xx:xx:xx:xx:xx:xx", NAME="eth0"

Use the 'ip a' command to identify all the devices currently detected on the system.

Then, add/modify entries in /etc/network/interfaces. For DHCP devices:

enable hotplug eth0
iface eth0 inet dhcp

For static IP assignments:

auto eth0
iface eth0 inet static
           address 10.0.0.x
           netmask 255.255.255.0
           dns-nameservers 10.0.0.254
           gateway 10.0.0.254

Reboot to make the changes permanent.