One consequence of Linux's dynamic network device naming

July 18, 2008

I knew that Linux did dynamic network device naming, but one consequence of that only really sunk in recently. Dynamic naming is relatively predictable for interfaces that are always on (especially when various distributions work hard to make them very persistent), but where it can really surprise you (and your software) is when the interfaces are dynamic. Like, say, PPP interfaces.

Just like Ethernet interfaces, the first active PPP connection gets ppp0, the second one gets ppp1, and so on. But unlike Ethernets, PPP connections can routinely come and go, and as a result it may not be clear to you (or your software) what PPP device is what connection. Also, it is easier to commit the old mistake of trying to bring up a connection that's configured as ppp1 when you don't have a ppp0.

(Scripts run by pppd itself get told the right network device, which can be both useful and potentially confusing.)

Unfortunately it looks like you cannot rename PPP devices, because it seems that you can only rename network devices that aren't active and when a PPP device isn't active, it doesn't exist at all. So I can't have pppdialup0 and pppdsl0 instead of, well, whatever pppN name they get right now.

One can half-fix this with software; pppd has a concept of a logical link name, and contrary to what the manual page appears to claim, it does pass this information to the ip-up script as the environment variable $LINKNAME. So your local link-up script can save the mapping between actual PPP device (the first argument) and the logical link name somewhere, and then other things can read it.

Comments on this page:

From at 2008-07-19 05:29:52:

Even the upstream pppd version has the unit num option, which sets a fixed pppnum interface number instead of assigning it dynamically.

In some distributions (e.g., ALT Linux) pppd is patched to add the ifname string option.

-- Sergey Vlasov

By cks at 2008-07-19 13:32:31:

You're right; I totally missed that option in the manual page. So one can actually completely fix this with software, although outside of some distributions you have to assign purposes to various pppN names ahead of time and then keep track of them.

Written on 18 July 2008.
« The advantage of blog comments
Why I'm mostly out of the email (anti-)spam game »

Page tools: View Source, View Normal, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Fri Jul 18 23:57:33 2008
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.