How to change interface name linux

Linux Rename Eth0 Network Interface Card Name [ Udev ]

A wireless NIC is showing as wlan0 but I need to be appear as eth1. How can I rename wlan0 devices through udev as eth1? How do I change or rename eth0 as wan0 under Linux operating systems?

The best way to rename Ethernet devices is through udev. It is the device manager for the Linux kernel. Primarily, it manages device nodes in /dev. It is the successor of devfs and hotplug, which means that it handles /dev directory and all user space actions when adding/removing devices, including firmware load.

Tutorial details
Difficulty level Intermediate
Root privileges Yes
Requirements Linux + udev
Reboot required
Est. reading time N/A

The order of the network interfaces may be unpredictable under certain configurations. Between reboots it usually stays the same, but often after an upgrade to a new kernel or the addition or replacement of a network card (NIC) the order of all network interfaces changes. For example, what used to be rl0 now becomes wlan0 or what used to be eth0 now becoems eth2 or visa versa.

Step #1: Find out the MAC address of the Ethernet device

Type the following command:
# ifconfig -a | grep -i —color hwaddr
Sample outputs:

Note down the MAC address.

Step #2: Rename eth0 as wan0

To rename eth0 as wan0, edit a file called 70-persistent-net.rules in /etc/udev/rules.d/ directory, enter:
# vi /etc/udev/rules.d/70-persistent-net.rules
The names of the Ethernet devices are listed in this file as follows:

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Locate and identify the line with the NIC from step 1 (look for the MAC address). It may look like above. In this example, the interface eth0 will be renamed to wan0 (change NAME=» eth0 » to NAME=» wan0 » ):

Save and close the file. Reboot the system to test changes:
# reboot
Verify new settings:
# ifconfig -a
# ifconfig wan0
# ifconfig -a | less
# ip addr show

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

Can i change the MAC address of a using udev rule. Actually i am getting random MAC for a Ethernet interface on my device. So i can’t rename that interface as in this rule MAC address is comparing.

Try using “macchanger”

Hi Rahul,
Probably you are looking for this. On my ubuntu (10.04-LTS) system. Its like.

root@ubuntu:/etc/udev/rules.d#cat 70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x10ec:0x8139 (8139cp)
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR

==”64:63:62:61:10:02″, ATTR==”0x0″, ATTR==”1″, KERNEL==”eth*”, NAME=”eth0″

Change here what you want.

Thanks for your reply. 🙂
In my case ATTR

==”xx:xx:xx:xx:xx:xx″ is random, it changed on every reboot, so i can’t compare this.
I need to make it static first, is there any way to do this?

looks like you’re using some virtualization software, In that case, its the Virtualization software whether its Xen, KVM, Hyper-V, VMWare or any other, has the option to put the static MAC address. You’ll have to look out for the options..

Thanks Balvinder,
I am working on a embedded self designed card and i have only one option to put the static MAC by using kernel. But i don’t want to change the kernel again. So looking for udev alternate, if it is possible. Like i can change the device name, can i change the MAC as well?

Add this entry into your rc.local file

ifconfig eth0 down hw ether 00:C1:26:10:30:C5 up

Источник

How to Rename Linux Interfaces

If you are unfamiliar with renaming interfaces, this article can help. The default RedHat ifrename utility is a very useful tool for renaming the interfaces but sometimes it doesn’t always work. We will explain in detail the process of renaming interfaces correctly.

The file /etc/iftab contains descriptive information about the various network interfaces. iftab is only used by the program ifrename to assign a consistent network interface name to each network interface.

/etc/iftab defines a set of mappings. Each mapping contains an interface name and a set of selectors. The selectors allow ifrename to identify each network interface on the system. If a network interface matches all descriptors of a mapping, ifrename attempt to change the name of the interface to the interface name given by the mapping.

Finding MAC address on all interfaces can be done by:

# ifconfig -a | grep -i hwaddr

Once you have the script and created the iftab you can test it

You can blink the interface lights on the card to make sure you have the correct card configured.

Script below «ifrename» :

#!/bin/sh
#
# chkconfig: 2345 09 60
# description: /sbin/ifrename
# processname: ifrename
#

# Source function library.
. /etc/rc.d/init.d/functions

[ -x /sbin/ifrename ] || exit 0

# Define where ifrename is installed.
DAEMON=»/sbin/ifrename»

start() <
if status $DAEMON > /dev/null; then
echo -n $»$DAEMON: already running «
failure
echo
return 1
fi

# Start daemons.
echo -n $»Starting ifrename: «
daemon $DAEMON $OPTIONS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ifrename
echo
return $RETVAL
>

stop() <
# Stop daemons.
echo -n $»Shutting down ifrename: «
echo OK
return 0
>

Once you add the /etc/init.d/ifrename script we can make it executable :

# chmod +x /etc/init.d/ifrename

Starting the ifrename service:

Then test again, and the cards should have changed assignments, if not continue reading:

Once that works simply add ifrename to your startup:

# chkconfig ifrename on

/etc/iftab example:

eth0 mac 00:50:56:c0:00:02
eth1 mac 00:50:56:c0:00:03
. . .
ethN mac 00:50:56:c0:00:03

If you get an error message like below during ifrename example:

Simply means you have no entry in the 70-persistent-net.rules for eth5 or whatever interface your working on. Make sure you have modified the 70-persistent-net.rules in /etc/udev/rules.d/ like below examples .

How do you find out information on what driver is owned to interface p1p2? Below example from terminal will give you driver info.

driver: ixgbe
version: 3.19.1-k
firmware-version: 0x61bf0001
bus-info: 0000:41:00.1
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: no

Now you can remove the driver which in our case it’s the IXGBE by Intel.

# rmmod ixgbe;modprobe ixgbe

Note : Make sure system isn’t in production when running above command.
You can reload the interface at this point with three options

# reboot

Edit 70-persistent-net.rules

To rename eth4 as wan1, edit a file called 70-persistent-net.rules in /etc/udev/rules.d/ directory, enter:

If 70-persistent-net.rules doesn’t exist we have an example below: The names of the Ethernet devices are listed in this file as follows:

Locate and identify the line with the NIC from step 1 (look for the MAC address). It may look like above. In this example, the interface eth0 will be renamed to wan0 (change NAME=»eth0″ to NAME=»wan0″ ):

Источник

How to Change Network Interface name on Ubuntu

To change Network Interface name on Ubuntu

Generally, a Network interface is named as either eth0, eth1, eth2 and etc. The network interface name depends on ethernet connections available and its number should vary from eth0 to eth1. Once Ubuntu 16.04 is installed, the network interface name gets changed from eth0 to ens33. It is quite easy to change the Network Interface name on your Ubuntu machine and this article can help you with that.

Changing the Network Interface name

You can verify your network interface name using ‘ ifconfig’ command or ‘ ip a’ command.

Ubuntu has it network interface name as eth0 while in boot time it will automatically renamed to ens33 to verify this on use the below command.

In order to change Network Interface name we require to edit grub configuration file as shown below.

Add the following lines to it.

Next regenerate grub configuration file.

Now open the network interface file by running the following commnad.

Add the following content to it.

Now that’ s all just you need to reboot your system and check network interface name once again with ‘ ifconfig’ command

The network interface has been changed now. Changing the network interface was quite easy wasn’ t it? Having your network interface changed may help you a lot.

Comments ( 0 )

No comments available

Frequently asked questions ( 5 )

What is the future of the NIC port?

«There doesn’t appear to any doubt that the NIC standard has a very clear-cut advantage in transfer speeds and in how widely spread it is.

«How can I see what it does and control its activity?

On Windows, open your Windows Control Panel, then click the icon or link to the Akamai NetSession Interface Control Panel.

What is a NIC port and What does it do?

«A Port or Connector :
A Port or Connector on a Dell PC has either holes or a slot that matches the plug or device that you are connecting to the Port.
«

What are the Different categories of cable and what do the different categories mean?

Co-Axial — Co-Axial came in Thinnet and Thicknet, both standards are now defunct and no longer in use. Twisted Pair — Twisted Pair came in several combinations and categories (CAT3, 4, 5, etc.).

«How do I select the best cable for the job?

While Network Cables do look alike from the outside and they all have the same connectors, they can have significant differences on the inside. You can find out the type of cable you have by looking at the text printed on the side of the cable.

= 5 || postCtrl.tagPost[‘tutorials’].current_page» ng-bind-html=»postCtrl.showtype1[‘tutorials’] | unsafe»>

= 5 || postCtrl.tagPost[‘forums’].current_page» ng-bind-html=»postCtrl.showtype1[‘forums’] | unsafe»>

= 5 || postCtrl.tagPost[‘news’].current_page» ng-bind-html=»postCtrl.showtype1[‘news’] | unsafe»>

hello i am trying to install ubuntu 20.04 and i keep getting stuck on the following screen after many many hours of waiting:

wanting to boot it up from try without install first(safe mode) so i can manually set it to install the os to an external ssd. i want to do this because my laptop is originally a windows machine, and as you reading this are aware windows does not like to put hard drives into ext/4 format. ideally once i get it installed on ssd, i use that to install onto the hard drive because then i can do what im wanting to do.

used kernal boot settings: acpi=off noapic nolapic nodmraid nomodeset

i appreciate any help tried my best to solve problem on my own but i cant

Источник

Читайте также:  Mac os для чего предназначена
Оцените статью