In Red Hat and CentOS, Ethernet aliases are usually configured using the ifcfg-ethX:Y
format, where X
is the number of the physical Ethernet interface and Y
is the alias number. Here’s how you can swap or change Ethernet aliases:
- Edit the appropriate interface configuration file
The interface configuration files are located in the
/etc/sysconfig/network-scripts
directory. Find the configuration file for the Ethernet interface that you want to modify. For example, if you want to modify the aliaseth0:1
, you would edit the file/etc/sysconfig/network-scripts/ifcfg-eth0:1
. - Change the configuration as needed
Depending on what you want to do, you may need to change one or more of the following parameters in the configuration file:
DEVICE
: The name of the Ethernet device. This should match the name of the physical Ethernet interface, e.g.eth0
.NAME
: The name of the Ethernet alias. This should match the alias number, e.g.eth0:1
.HWADDR
: The MAC address of the Ethernet interface.IPADDR
,NETMASK
,GATEWAY
,DNS1
,DNS2
: The IP address, netmask, default gateway, and DNS server addresses for the Ethernet interface.ONBOOT
: Whether the Ethernet alias should be brought up at boot time.BOOTPROTO
: The method used to obtain IP addresses. Set tonone
if you want to manually configure the IP address.
- Restart the network service
Once you have made your changes, you will need to restart the network service in order for them to take effect. You can do this using the following command:
sudo systemctl restart network
Note that restarting the network service may cause your SSH connection to be terminated. If this happens, you can simply reconnect to the server once the network service has restarted. (https://www.santaritalandscaping.com/)
By modifying the parameters in the configuration file, you can change the IP address, netmask, default gateway, and other settings for the Ethernet alias. If you want to swap the Ethernet aliases, you can simply modify the configuration files for the appropriate interfaces and restart the network service.