LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-06-2013, 11:19 AM   #1
rnturn
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,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
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
 
Old 07-07-2013, 08:08 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
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.
 
Old 07-08-2013, 12:09 AM   #3
rnturn
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,803

Original Poster
Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by Ser Olmy View Post
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
 
Old 07-08-2013, 01:59 AM   #4
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
Quote:
Originally Posted by rnturn View Post
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 View Post
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.
 
Old 07-08-2013, 05:06 PM   #5
rnturn
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,803

Original Poster
Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by Ser Olmy View Post
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
 
Old 07-09-2013, 12:52 PM   #6
MikeDeltaBrown
Member
 
Registered: Apr 2013
Location: Arlington, WA
Distribution: Slackware
Posts: 96

Rep: Reputation: 10
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.
 
Old 07-09-2013, 01:03 PM   #7
rnturn
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,803

Original Poster
Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Heh heh... responding to the email alert...

Quote:
Originally Posted by MikeDeltaBrown View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why "-bash: ifconfig : command not found" when typing "$ifconfig" dangdtvn Linux - Server 9 09-20-2013 06:01 AM
[SOLVED] "ifconfig eth0 up" doesn't work, cause of "no such file or directory" Sebi94 Linux - Networking 6 08-21-2012 10:39 PM
unpredictable "delete" "move to trash" or "cut" file menu option dorianrenato Linux - General 3 11-28-2011 06:41 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration