Is there a way to name a VLAN interface arbitrarily like eth72
or ext19
instead of the four standard nameing schemes eth0.72
, vlan19
(and the padded variations)?
Don't have no clue. Perhaps udev?
Is there a way to name a VLAN interface arbitrarily like eth72
or ext19
instead of the four standard nameing schemes eth0.72
, vlan19
(and the padded variations)?
Don't have no clue. Perhaps udev?
OMG - it's that easy:
Rename vlan 42 on eth0 to ext2:
ip link set dev eth0.42 name ext2
I didn't have luck with "ip link set dev bond0.10 name ext0". If the interface is up, it gets a BUSY error. If the interface is down, it gets a NOT FOUND error.
What I did have luck with is this: in my base interface definition for bond0,
and
Now I find that "ifup bond0" not only creates the VLAN as seen in /proc/net/vlan/config and creates the ext0 device, but it even ifup's the ext0 device. bond0.10 never comes into existence.
In OpenBSD (and presumably other BSDs) you can set a description of an interface with ifconfig using the aptly named
description
argument, see ifconfig(8). This is very handy for distinguishing between a bunch of interfaces. But that doesn't help you.Unfortunately there's no great way to do this in Linux.
In Linux, interfaces are named dynamically with each interface being assigned the first available name. This means that if you pull a NIC and then add another one (say to replace it or upgrade it) there is no guarantee that its interface will remain the same.
Try a program like ifrename which will allow you to manually specify the interface names. It looks primarily designed to assure that
NIC0
is always associated witheth0
but I believe you can use it assign names likeexternal
anddmz
to interfaces instead ofeth0
and so on. Udev will also allow you to change interface names using the network.rules file (see here for an examples).You should be careful to document this as it is not typically done but unlike @MichealHampton I don't see any particular problem with it. I personally make great use of the description field for interfaces in my BSD installs.
In debian you use
/etc/network/interfaces
to configure your network interfaces.Be aware that you should install the
vlan
package:From
man 5 interfaces
:For more information check
man 5 vlan-interfaces
. Basically, you can give your vlan interface any name, and usevlan-raw-device
to associate the vlan with your NIC. For instance, vlan10 on eth0 would be:On non-debian distros, you can do this same thing with
iproute2
as follows:So this works well.
in /etc/network/interfaces:
then ifup lxdHost
pre-up and post-down and the others in intefaces man are the magic hooks to do things your own way.
Not sure if this also applies to Debian, but in Ubuntu (and Red Hat), this is easily done by editing /etc/udev/rules.d/persistent-net.rules (or similar; I'm not in a position to check)
Renaming interfaces has some useful advantages:
You do need to make sure that your team knows to expect this. That's not a problem, it's generally very welcome, particularly when you have many interfaces in a system (eth8 is not unreasonable in an host with redundant bonded links to SAN storage)
Having discussed this recently, if you wanted to rename based on VLAN ID, I would suggest that you consider the following:
Using nmcli on RedHat/CentOS/SL 7 you have system-supported persistent arbitrary namig for VLAN interfaces, just:
$ nmcli con add type vlan ifname outside dev eno1 id 10