[UPDATED:] Re: confusion on /sbin/ifconfig on F16

Bill Davidsen davidsen at tmr.com
Sun May 27 12:59:02 UTC 2012


Ed Greshko wrote:
> On 05/23/2012 11:22 AM, Paul Allen Newell wrote:
>> [updated, keeping original post and adding new info at bottom]
>>
>> On 5/22/2012 8:12 PM, Paul Allen Newell wrote:
>>> Hello:
>>>
>>> As I continue dealing with iptables, another issue has come up that I can't tell
>>> is a mis-understanding on my part or a potential problem
>>>
>>> I have three F16 machines, one x86_64 and two i383/686. If I run /sbin/ifconfig on
>>> them, I get (short summary of):
>>>
>>> x86_64: eth0
>>> i686: em1
>>>
>>> Looking in /etc/sysconfig/network-scripts, I can see only ifcfg-em1 and no
>>> ifcfg-eth0 on all the machines (x86_64 and i686).
>>>
>>> The closest bugzilla I can see if 784314 but it looks like it hints that ifconfig
>>> is old-school and the right way to do things (and its F17 not F16).
>>>
>>> Does anyone know what I am either doing wrong or if this looks like a problem/bug.
>>> Plus, if there is a better way, I'd love to know.
>>>
>>> What I want to do is have is a bash way to get the static ip address of the
>>> machine which I can see in eth0/em1. I've been using something I found online
>>> which assumes everything is eth0 (as in I think it was for older Fedora):
>>> +++
>>> /sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
>>> +++
>>>
>>> Its too clever for me to have come up with on my own (smile).
>>>
>>> I tried expanding the grep to be 'inet addr:192.168.2' but that failed on the
>>> laptop which has an entry for wireless which is dhcp (I cannot assume wireless
>>> will be 192.168.2.*).
>>>
>>> Any suggestions appreciated,
>>> Thanks,
>>> Paul
>>
>> Okay, so I managed to figure out that 'ip' is the new command. I'd looked at it
>> earlier to try to find a way around this, but couldn't figure it out. Just spotted
>> the 'obsolete, use ip' in man page of ifconfig. As usual, there is always something
>> discovered right after I make the post.
>>
>> Should I assume that even if ifconfig is giving a problem, its academic and I
>> should just focus on ip. And, if so, how the heck does one get the ip addr. If I
>> use "ip addr show", I still get eth0 on the x86_64 and em1 on the i686?
>>
>
> I guess I really don't know what precisely is the problem you're having.
>
> Interface naming convention has been undergoing changes since, maybe, F14.
> Interfaces that were once called eth0 became em1 and other niceties.  I don't recall
> if the names changed on upgrades or only new installs.  Anyway, the changes didn't
> make my life miserable, so I've kind of ignored the changes.
>
The problem with naming is that for every server run by experienced sysadmins, 
there are thousands of machines with a single NIC which benefits not one bit 
from having a name based on which slot it occupies. That's actually not much of 
a benefit on a server, either, since the IP is assigned by MAC address in DHCP, 
and if I work on the machine I really want to be able to put any card in any 
slot and match the label on the cable to the label on the NIC, and have scripts 
which don't have to be needlessly complex to discover the name of the interface.

*Particularly if I want the script to run on multiple machines!*

> So, what is it that you are really after?  Do you just want a script, or series of
> commands, to return the IP address of a single, known interface?
>
I think he wants the "single, known interface" to have a single known name, and 
not some random characters determined by the whichness of what.

-- 
Bill Davidsen <davidsen at tmr.com>
   "We have more to fear from the bungling of the incompetent than from
the machinations of the wicked."  - from Slashdot


More information about the users mailing list