Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-06-2013, 11:19 AM
|
#1
|
Senior Member
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,849
|
Questions about "ifconfig" and "ip"
Knowing that "ifconfig" has been lurching toward being deprecated (for a while now), I was going into some old scripts and modifying them to use "ip". During testing, though, I noticed some odd things:
* An alias created with "ifconfig" can be seen/listed using "ip" but the reverse is not true. "ip" aliases are not visible using "ifconfig".
* If I create an alias with "ip", say:
Code:
ip addr add 192.168.13.215/24 dev eth0:tst
and then list the configuration, the ":tst" portion of the alias is not shown.
* Also, if I create a couple of aliases using "ifconfig" and "ip":
Code:
# ifconfig eth0:tst1 192.168.13.210 netmask 255.255.255.0
# ip addr add 192.168.13.211/24 dev eth0:tst2
# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:11:2F:56:5E:7C
inet addr:192.168.13.7 Bcast:192.168.13.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:57040 errors:0 dropped:0 overruns:0 frame:0
TX packets:53843 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:70051161 (66.8 Mb) TX bytes:5303240 (5.0 Mb)
eth0:tst1 Link encap:Ethernet HWaddr 00:11:2F:56:5E:7C
inet addr:192.168.13.210 Bcast:192.168.13.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:132 errors:0 dropped:0 overruns:0 frame:0
TX packets:132 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:9708 (9.4 Kb) TX bytes:9708 (9.4 Kb)
# ip addr list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:11:2f:56:5e:7c brd ff:ff:ff:ff:ff:ff
inet 192.168.13.7/24 brd 192.168.13.255 scope global eth0
inet 192.168.13.210/24 brd 192.168.13.255 scope global secondary eth0:tst1
inet 192.168.13.211/24 scope global secondary eth0
Note that ifconfig is unable to display the existence of the alias created with "ip". Also, ":tst2" is not shown although it was specified on the "ip" command line.
If I try and delete the "tst2" alias using "ip" it doesn't seem to matter if I specify the ":tst2" portion in the "dev" argument or not. Older aliases that I have created using the "ethN:string" syntax in YaST are shown in full when I list them with "ip" (on other systems; not the one I used for the above example). It's just the ones that I specified on the "ip" command line that are not. Also, I am able to use "ip" to delete an alias created with "ifconfig" that used the "ethN:string" syntax.
This feels all loosey-goosey to me.
Q:
* How does one specify the device for an alias using "ip" and have it listed correctly with "ip addr show/list"?
* Or should I just abandon any use of ":string" in the device names to identify aliases? (Yeah... you could only specify a few characters but they were better than nothing.)
TIA...
--
Rick
|
|
|
07-07-2013, 08:08 PM
|
#2
|
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 3,349
Rep: 
|
Aliases != multiple IP addresses.
The ifconfig command can work with interfaces or aliases, but can only assign a single IP address to an interface or alias.
The ip command works exclusively with interfaces, and does not handle aliases. It can, however, add multiple IP addresses to a single interface, thereby removing the need for aliases.
|
|
|
07-08-2013, 12:09 AM
|
#3
|
Senior Member
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,849
Original Poster
|
Quote:
Originally Posted by Ser Olmy
Aliases != multiple IP addresses.
The ifconfig command can work with interfaces or aliases, but can only assign a single IP address to an interface or alias.
|
Huh?
Those secondary (tertiary, etc.) addresses are referred to as aliases. At least they are on the commercial UNIXes I've worked on. Some of those "ifconfig"s even include switches that allow you to specify a range or list of addresses to be assigned/removed. (One wonders why an entirely new command had to be added to Linux as opposed to adding the alias list functionality to "ifconfig". Were there advantages other than "ifconfig" being old?)
And if "ip" can only work on interfaces, the why does:
Code:
ifconfig eth0:tst1 192.168.13.210 netmask 255.255.255.0
ip addr del 192.168.13.210/24 dev eth0:tst1
work? There's definitely not a physical interface called "eth0:tst1" on my system. I will concede that "ip" seems to be unable to understand the concept of "alias" in that I cannot specify such a "device" when adding an extra IP address like I can using "ifconfig". I do find it odd, though, that "ip" seems to understand what I'm talking about when I refer to the alias when I'm deleting an alias address. ("ip" silently ignores the colon and everything to its right.)
Like I said: the way these commands are working (especially "ip") seems too loosey-goosey (i.e., sloppy) to me. I'll eventually get used to the way "ip" works although I think it's not documented well enough.
--
Rick
|
|
|
07-08-2013, 01:59 AM
|
#4
|
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 3,349
Rep: 
|
Quote:
Originally Posted by rnturn
Huh?
Those secondary (tertiary, etc.) addresses are referred to as aliases. At least they are on the commercial UNIXes I've worked on.
|
Indeed they are, but on Linux they are deprecated.
Quote:
Originally Posted by rnturn
And if "ip" can only work on interfaces, the why does:
Code:
ifconfig eth0:tst1 192.168.13.210 netmask 255.255.255.0
ip addr del 192.168.13.210/24 dev eth0:tst1
work?
|
This works as well:
Code:
ifconfig eth0:tst1 192.168.13.210 netmask 255.255.255.0
ip addr del 192.168.13.210/24 dev eth0
And so does this:
Code:
ip addr add dev eth0:dummy 192.168.13.210/24
ip addr del dev eth0 192.168.13.210/24
If you stick an ifconfig command between the two ip commands directly above, you won't see an "eth0:dummy" alias.
The ip command ignores aliases, but does treat addresses assigned to existing aliases as if they were assigned to the interface itself.
Last edited by Ser Olmy; 07-08-2013 at 02:00 AM.
|
|
|
07-08-2013, 05:06 PM
|
#5
|
Senior Member
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,849
Original Poster
|
Quote:
Originally Posted by Ser Olmy
Indeed they are, but on Linux they are deprecated.
|
Yet YaST still seems to allow one to specify that ":string" portion of the alias/device. I notice that the network startup scripts in SUSE/OpenSUSE appear to be using "ip" even though I can see aliases when I issue "ip addr list". On one system where I have multiple "aliases" (defined in the "if-eth-id-blah-blah" file), "ip" does show the alias name when I list them. Also, "netstat -ain" shows a row for every "alias" that's defined but, depending on the version of Linux, it only shows the ":" and, regardless of Linux version, only shows "no statistics available" for those rows. (When I access a web server via one of the aliases only the statistics for the base interface are increasing.)
Quote:
Code:
ip addr add dev eth0:dummy 192.168.13.210/24
ip addr del dev eth0 192.168.13.210/24
If you stick an ifconfig command between the two ip commands directly above, you won't see an "eth0:dummy" alias.
|
You won't see it with "ip addr list" either at least not as being associated with "eth0:dummy". "ip" is silently tossing away that information (":dummy"). A warning for using that syntax would be nice. At least you'd know that something might not be working as you expected.
Quote:
The ip command ignores aliases, but does treat addresses assigned to existing aliases as if they were assigned to the interface itself.
|
I noticed last night that the iproute-doc package had not been installed so I installed that. One of the PDFs that were installed ("ip-cref.pdf") showed that one actually can assign ifconfig-style names to addresses. The syntax is not mentioned in the ip(8) manpage. Your example would be entered as:
Code:
ip addr add dev eth0 192.168.13.210/24 label eth0:dummy
ip addr del dev eth0 192.168.13.210/24
Then, when you issue an ifconfig command after the "add", you will see the eth0:dummy "alias". I'm guessing that when I go back and re-examine those network startup scripts that I'll find that they're using the "label" option as they parse the ifcfg-eth* script(s) and set up the IP addresses. I also noticed that the manpage shows a command line option "addrlabel" which is not mentioned in the PDF. (I'm not sure what that is all about but it makes me wonder how accurate the rest of the documentation is.)
Thanks for your feedback. This has been very interesting. And a little sad as I found that several older, classic texts that I have about Linux are outdated.
--
Rick
|
|
|
07-09-2013, 12:52 PM
|
#6
|
Member
Registered: Apr 2013
Location: Arlington, WA
Distribution: Slackware
Posts: 96
Rep:
|
Do you have the same problem if you use an integer after the colon?
Never mind. Just tried it with the same result.
Last edited by MikeDeltaBrown; 07-09-2013 at 01:05 PM.
|
|
|
07-09-2013, 01:03 PM
|
#7
|
Senior Member
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,849
Original Poster
|
Heh heh... responding to the email alert...
Quote:
Originally Posted by MikeDeltaBrown
Let's see... how to delete a post....
|
In response to the question you posed and deleted (or tried to delete before changing your mind): No. I've always used alphabetic (or alphanumeric) names. If older (pre-ip) Linuxes restricted you to numeric I never had occasion to use them (aliases) that long ago.
(BTW: I'm guessing you'd need to reach out to a moderator to completely whack a post.)
Later...
--
Rick
Last edited by rnturn; 07-09-2013 at 01:05 PM.
|
|
|
All times are GMT -5. The time now is 06:30 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|