It seems that lately all that I’ve written have been docs on how to do stuff at work. Mostly because I’ve been busy ( scuba, girlfriend, work, soccer, friends, etc. ) unlike some people I know ( hi pierre ). Anyways, recently while at work, we found that we wanted to switch the names of some of the network adapters on an AIX machine. However, this turns out to be a very complicated thing to do. You cannot just rename them. I also didn’t want to mess around with moving the cards around in the machine, rebooting, testing, etc. I just wanted to fix the damn names.

So I did. Here’s how.

First, get all the information about the adapters.

for i in ent0 ent1 ent2
do
odmget -q name="$i" CuDv >> /tmp/$i
odmget -q name="$i" CuAt >> /tmp/$i
odmget -q name="$i" CuVPD >> /tmp/$i
done 

Next, down the interfaces and detach them.

for i in en0 en1 en2 et0 et1 et2
do
ifconfig $i down
ifconfig $i detach
done 

Now, remove all the references to the devices from the ODM

for i in ent0 ent1 ent2 en0 en1 en2 et0 et1 et2
do
odmdelete -q name="$i" -o CuAt
odmdelete -q name="$i" -o CuDv
odmdelete -q name="$i" -o CuVPD
odmdelete -q value3="$i" -o CuDvDr
done 

We can verify that no adapters and no interfaces exist now by issuing the lsdev commands again. All we should see is the loopback interface.

lsdev -Cc adapter -l ent*
lsdev -Cc if
lo0 Available       Loopback Network Interface

Edit the files we created the first step and replace every instance of the adapter name with the new adapter name. For instance, I would edit /tmp/ent0 and replace all instances of “ent0″ with “ent2″. We can do this with a sed script.

sed -e "s/ent0/ent1/g" /tmp/ent0 > /tmp/ent1.new
sed -e "s/ent1/ent2/g" /tmp/ent1 > /tmp/ent2.new
sed -e "s/ent2/ent0/g" /tmp/ent2 > /tmp/ent0.new

Then add the files back to the ODM.

odmadd /tmp/ent0.new
odmadd /tmp/ent1.new
odmadd /tmp/ent2.new

At this point, our adapters will now be redefined. Issue another lsdev command to check:

lsdev -Cc adapter -l ent*
ent0 Available 05-08 10/100/1000 Base-TX PCI-X Adapter (14106902)
ent1 Available 07-08 2-Port 10/100/1000 Base-TX PCI-X Adapter (14108902)
ent2 Available 07-09 2-Port 10/100/1000 Base-TX PCI-X Adapter (14108902)

You can see now that ent0 is now the external PCI-X adapter and ent1 and ent2 are the two onboard adapters. But, we still have no interfaces for the adapters. You can verify this by issuing the usual lsdev command again. You should only see the loopback interface.

lsdev -Cc if
lo0 Available       Loopback Network Interface

To fix this ( and to make sure our changes stick upon a reboot… ), run a cfgmgr, then check for our interfaces.

cfgmgr
lsdev -Cc if
en0 Defined   05-08 Standard Ethernet Network Interface
en1 Defined   07-08 Standard Ethernet Network Interface
en2 Defined   07-09 Standard Ethernet Network Interface
et0 Defined   05-08 IEEE 802.3 Ethernet Network Interface
et1 Defined   07-08 IEEE 802.3 Ethernet Network Interface
et2 Defined   07-09 IEEE 802.3 Ethernet Network Interface
lo0 Available       Loopback Network Interface

As you can see, we have successfully gotten our interfaces back. We’re almost done! All you need to do now is reboot the system.

shutdown -Fr

Once the reboot has completed, issue one last check to verify that the adapters have changed:

entstat -d ent0 | grep "Device Type"
Device Type: 10/100/1000 Base-TX PCI-X Adapter (14106902)

Looks good!

This entry was posted in Unix, Work and tagged , . Bookmark the permalink.

2 Responses to How to rename network adapters in AIX

  1. Frank Monien says:

    Thank’s a lot! Wonderful. YOUR script was very helpful.

  2. Joathan Adams says:

    Clever!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Browse by Topic