# Network interface aliasing in /etc/conf.d/net

## Darknight

Is it possible? I found this tip from 5 years ago but it doesn't seem to work.

I'd like to use iproute2 (ip link...) to create an alias before the interfaces are started but I can't find documentation about this bit. Any other tool would do, iproute2 is just my fave.

Thanks in advance.

----------

## elmar283

I'm not sure, but this might help:

https://forums.gentoo.org/viewtopic-t-402654-view-previous.html?sid=cea489a4310e30600d9de491e338b30c

or

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&chap=2

----------

## Hu

As I understand the Wiki page cited by the OP, the advice on the Wiki does not create an alias for the interface, but instead changes the interface name.  In the latter case, only the new name is valid.  An alias implies both names are valid and refer to the same interface.

OP: interface renaming is often the domain of udev, if you have that installed.  If you are using a special system without udev, then there are other ways to do it, including the ip link command you referenced.

----------

## Darknight

I think a little explanation is in order.

I need the old names for my interfaces instead of the new names as many config files (including some non trivial ones) refer them, I'd rather not spend much time to check and debug everything to use the new names.

To me aliasing a as b, as long as every action I do on a is reflected on b and vice-versa, is as good as renaming and then using just the new name.

Currently I have setup a workaround with this initscript, which works:

```
#!/sbin/runscript

description="Creates interface aliases."

depend()

{

        after dbus

        before net

}

start()

{

        echo    Creating interface aliases...

        ip link set enp1s0 name eth0

        ip link set enp4s0 name eth1

        return 0

}

stop()

{

        echo    Nothing to do.

        return 0

}
```

Why? Because reading around it seems that using udev to rename the interfaces to kernel names at boot time is highly discouraged.

Since most of the interface "manipulation" is performed in /etc/conf.d/net it would have been tidier to put the renaming there, rather than creating a separate initscript.

I'm nitpicking... I know, but it bugged me that I couldn't make it the "my" way so I asked to see if I was missing some critical bit of information, it seems there's no conf.d/net magic that can solve this specific need.

Thank you anyway!   :Smile: 

----------

## Hu

The solution is not in /etc/conf.d/net because the problem is not in /etc/conf.d/net.  The problem is that udev defaults to mangling the names of your network cards.  On any system which predates this mangling, this is usually the wrong thing to do, but the udev maintainers defaulted the feature to enabled anyway.  The solution is that you need to read news item Upgrading udev to version >=200 and follow its advice.  The simplest workaround is to override the stupid udev defaults by creating an empty file named /etc/udev/rules.d/80-net-name-slot.rules.

----------

## Gentree

to get the news item pre-supposes the update has already been done. 

eselect news read

The bottom line, for those wishing to understand and pre-empt the problem is here:

http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

----------

## Hu

I received that news item well before I installed the bad udev version.  However, I have seen some people asserting that systems installed after the bad udev was released will never see that news item.

----------

## Gentree

"I have seen some people asserting that systems installed after the bad udev was released will never see that news item."

From what I've read, they may not see a login prompt either  :Wink: 

udev is one of those packages that I've learnt to mistrust. I often lock it using a mask until there is a need to update it, then I avoid latest version or two and have a quick scan of the formum before moving. 

The developers of udev have little regard for the principal of backwards compatibility and seem to take the attitude that everyone else should "develop" around the changes they impose.

----------

## Darknight

Thank you, I'll look at the links and act accordingly.

I'm always nervous when the time comes for an udev update, too.   :Wink: 

----------

