Fedora Linux Support Community & Resources Center
  #1  
Old 19th July 2012, 05:52 PM
Frannacky Offline
Registered User
 
Join Date: Jul 2012
Location: CA
Posts: 2
linuxchrome
HWaddr missing in fedora 17 ifconfig -a output

Hello,

A few software are based on a command like ifconfig -a | grep HWaddr .... to get either the mac address or the IP address. In fedora 17, this HWaddr is missing. Even though we can easily replace HWaddr by "ether" to get the mac address when it is our own software, it's hard when it's some one else. And sometimes it's just embedded and we cannot change anything.

Questions:

1) Is there a way to get back the old output. (like if we don't want the new interface name, we can go back to the old eth*)?

2) Why has it been changed?

thanks

Franck
Reply With Quote
  #2  
Old 20th July 2012, 01:22 AM
Dutchy Offline
Registered User
 
Join Date: Aug 2011
Posts: 1,010
linuxfirefox
Re: HWaddr missing in fedora 17 ifconfig -a output

Well, if the source is open and the license allows it, you could always customize the program to your own needs.
Whether it is a good idea to let your (own) program(s) depend on the output of a tool like ifconfig is up to you to decide (it is being deprecated by a lot of distros and I believe there are more efficient ways to obtain a mac address programming wise).

The way the interfaces are named has changed because the new way better resembles the actual physical conditions of the machine.
You can read about this over here (and this also points you in the direction on how to revert back to the old way).
Reply With Quote
  #3  
Old 20th July 2012, 09:17 AM
stevea Online
Registered User
 
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,836
linuxfirefox
Re: HWaddr missing in fedora 17 ifconfig -a output

Quote:
Originally Posted by Frannacky View Post
Hello,

A few software are based on a command like ifconfig -a | grep HWaddr .... to get either the mac address or the IP address. In fedora 17, this HWaddr is missing. Even though we can easily replace HWaddr by "ether" to get the mac address when it is our own software, it's hard when it's some one else. And sometimes it's just embedded and we cannot change anything.

Questions:

1) Is there a way to get back the old output. (like if we don't want the new interface name, we can go back to the old eth*)?

2) Why has it been changed?

thanks

Franck
ifconfig is being deprecated and uses deprecated ioctl to obtain information. You should switch to 'ip' for general use. 'ip uses netlink which is the modern way to do this.

It is NOT SMART (tm) to create scripts or programs that depend on the specific format output of commands. That is amateurish. It's OK for a local hack, but does not belong in supported software. The text changed b/c the upstream developer thought the new text was better. The text output of these commands of is meant for humans and WILL change again.

Before we get to the question of HOW a script should get get the IP or MAC address, I think we should ask WHY is your script trying to get these ? Normally unless you are changing the interface you should just use the hostname of the interface and not the numerical IP. The MAC address is an 802.11 station identifier and not all networks use 802.11 - so this may be undesirable.

Sadly there is no good way to access I P& MAC from a script w/o writing some code. Maybe ther eis a perl or tcl libary t ouse netlink.
__________________
None are more hopelessly enslaved than those who falsely believe they are free.
Johann Wolfgang von Goethe
Reply With Quote
  #4  
Old 20th July 2012, 07:06 PM
Frannacky Offline
Registered User
 
Join Date: Jul 2012
Location: CA
Posts: 2
linuxchrome
Re: HWaddr missing in fedora 17 ifconfig -a output

Thank you for your input!

To answer the question why we would like to get the MAC address and the IP address, it's because the MAC address is being use to generate a unique ID to be register by a remote server. Is that a good use of it, I don't know but I was able to hack the script and make this part work.
About the IP address. Sometime you don't have a public (externally known) hostname and sometimes, you have 1 hostname for multiple IPs. So no, using the hostname is not always the best option, sometime you just can't.

The question is I guess, what is the best way to get an ip address?
if we can't trust the output of a command, then we cannot use any command, not even ip since the output may change format. I don't see a command that gives me a list of IPs, and even if there were, then the format may change. So what's the way of getting the IP address?

For the MAC address, I'm using this now:
ip link show dev em1|tail -n 1|awk '{print $2}'

thanks,

Franck
Reply With Quote
Reply

Tags
fedora, hwaddr, ifconfig, present

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] HWaddr changes randomly lobsterII Servers & Networking 7 11th June 2011 08:53 PM
no ifconfig command in Fedora 8? savagehobo Using Fedora 11 1st August 2009 04:57 AM
asus p5k, changing hwaddr. new[] Hardware & Laptops 1 28th February 2008 09:25 PM
xgl not present fedora 8 anupash.cool Hardware & Laptops 0 19th November 2007 08:26 PM


Current GMT-time: 09:58 (Saturday, 20-09-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat