


This directive is used to assign a MAC address to an interface, overriding the one assigned to the physical NIC, This directive should not be used in conjunction with HWADDR. is the hardware address of the Ethernet device in the form AA:BB:CC:DD:EE:FF. This directive is useful for machines with multiple NICs to ensure that the interfaces are assigned to the correct device names regardless of the configured load order for each NIC's module, This directive should not be used in conjunction with MACADDR. Note: Red Hat does not support assigning a permanent MAC address to bond interfaces in active-backup mode with the fail_over_mac option set to follow or active.Īfter performing the necessary changes in the network configuration files make sure to reboot the system for the MAC address to take effect. # cat /etc/sysconfig/network-scripts/ifcfg-bond0īONDING_OPTS="mode=active-backup primary=eno1 miimon=100" # cat /etc/sysconfig/network-scripts/ifcfg-eno2 # cat /etc/sysconfig/network-scripts/ifcfg-eno1 Forcing a bond to get its MAC address from a specific slave, MACADDR directive has to be added with the MAC address of the required slave to /etc/sysconfig/network-scripts/ifcfg-bondX file.The HWADDR directive is changed with MACADDR : # cat /etc/sysconfig/network-scripts/ifcfg-eth1Īssigning permanent MAC address for a bonding network interface. # cat /etc/sysconfig/network-scripts/ifcfg-eth1

If HWADDR= directive is present in the network configuration file then make sure to replace it with MACADDR= directive and its corresponding value as follows: So that this value will be taken as the permanent MAC address of the network interface. Add MACADDR= directive and specify the required MAC address to the /etc/sysconfig/network-scripts/ifcfg-ethX network configuration.If you are not trying to rename your Rhel 7 network devices to ethX style, please see below resolution. Use ip route list to see which default router your machine have. Use the new command that replace them and can do more, ip (8). Please keep in mind that ethX style naming will not work on Rhel 7. 6 Answers Sorted by: 15 Dont use the obsoleted commands ifconfig (8), arp (8) or route (8). Resolution Assigning permanent MAC address for an Ethernet interface. Force the bond interface to take a MAC address of the slave.How to assign a permanent MAC address to the bonding interface in RHEL ?.The Network Interface MAC address is changing after each reboot.If (ioctl(sock, SIOCGIFCONF, &ifc) = -1) Ĭonst struct ifreq* const end = it + (ifc. Int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP) You also want to skip the loopback interface. The mac address will be obtained as a 6-octet binary array. You need to iterate over all the available interfaces on your machine, and use ioctl with SIOCGIFHWADDR flag to get the mac address.
