Using ifrename is the easiest way to make sure your network cards keep the correct configurations on Linux systems. Usually, interfaces will come up in the same order, and the kernel will assign them the same names, but sometimes this can change (e.g., after a kernel upgrade or adding another network card). Your nice Linux firewall won’t work with the network interfaces mixed up, so it is best to nail them down. An additional bonus is you can easily name your interfaces anything you want with ifrename. You might give them descriptive names like “lan” and “wan,” instead of eth0 and eth1.
If you encounter below error:
ifrename: command not found
you may try installing below package as per your choice of distribution.
Distribution | Command |
---|---|
Debian | apt-get install ifrename |
Arch Linux | pacman -S ifrename |
Kali Linux | apt-get install ifrename |
CentOS | yum install ifrename |
Fedora | dnf install wireless-tools-1 |
Raspbian | apt-get install ifrename |
To get more help on the ifrename command, refer to the man page:
$ man ifrename
The ifrename utility can be used to rename a network interface. The -i option specifies the old interface name, and -n sets the new name. To rename wlan0 to eth1, for example:
# ifrename -i wlan0 -n eth1
ifrename Command Examples
1. To set the configuration file:
# ifrename -c /path/config
2. To probe kernel modules before renaming interface:
# ifrename -p
3. To rename specific interface:
# ifrename -i eth1
4. To specify the new name:
# ifrename -i eth1 -n eth8
5. To enable takeover support:
# ifrename -t
6. To enable udev output mode:
# ifrename -u
7. To dry-run mode:
# ifrename -D
8. To set to verbose mode:
# ifrename -V