LinuxQuestions.org
Visit Jeremy's Blog.
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-29-2015, 06:03 AM   #1
Neville Hillyer
Member
 
Registered: Jul 2015
Posts: 57

Rep: Reputation: Disabled
Get router MAC address with BusyBox v1.16.1


I have a Netgear router with BusyBox v1.16.1.

This version of BusyBox appears not to have a hostid command.

Is there a way to get the router MAC address within the BusyBox environment?
 
Old 07-29-2015, 06:25 AM   #2
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 875

Rep: Reputation: 282Reputation: 282Reputation: 282
Not sure if the busybox versions give the exact same output but ip and ifconfig both give the MAC address of any interfaces.
 
1 members found this post helpful.
Old 07-29-2015, 09:04 AM   #3
Neville Hillyer
Member
 
Registered: Jul 2015
Posts: 57

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by wildwizard View Post
Not sure if the busybox versions give the exact same output but ip and ifconfig both give the MAC address of any interfaces.
Thanks for the prompt reply. It appears that both ifconfig and ip are available on my BusyBox.

I normally use OS X and can easily test ifconfig but not ip. As far as I can tell neither have specific read only options so getting either IP or MAC addresses would require more filtering than I expected.

Is there an easier way to do this?
 
Old 07-29-2015, 11:31 AM   #4
Neville Hillyer
Member
 
Registered: Jul 2015
Posts: 57

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Neville Hillyer View Post
Is there an easier way to do this?
This is the easiest way I can find to do it in OS X:

while read x y; do [ $x = ether ] && echo $y; done < <(ifconfig)

Is there a better way to do it with my BusyBox?
 
Old 07-29-2015, 11:50 AM   #5
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by Neville Hillyer View Post
This is the easiest way I can find to do it in OS X:

while read x y; do [ $x = ether ] && echo $y; done < <(ifconfig)
That was... unexpected!!!

I have never seen a while loop being used for that purpose. An easier (in my humble opinion) way to get all the MAC addresses is:
Code:
ifconfig | grep ether | awk '{ print $2 }'
3c:08:14:6e:fc:00
4c:c2:a9:1d:12:dd
0e:c2:a9:4d:52:dd
Or, if you only want the MAC address for a specific device, try:
Code:
ifconfig en0 | grep ether | awk '{ print $2 }'
1c:17:04:3f:ac:00
The above commands have been executed under OS X 10.7.

I know nothing about BusyBox though.

Best regards,
HMW

PS. Since I am paranoid, I have spoofed the addresses. DS

Last edited by HMW; 07-29-2015 at 11:54 AM.
 
1 members found this post helpful.
Old 07-29-2015, 01:57 PM   #6
Neville Hillyer
Member
 
Registered: Jul 2015
Posts: 57

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by HMW View Post
That was... unexpected!!!
I often use a 'while' 'read' combination, frequently with 'case' on OS X.

I was trying to do it in shell as much as possible because of BusyBox limitations but I see that my BusyBox does have both awk and grep.

Unless somebody finds a better way I may use:

x=$(ifconfig | grep ether); echo ${x#*ether}
 
Old 07-29-2015, 03:10 PM   #7
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by Neville Hillyer View Post
I often use a 'while' 'read' combination, frequently with 'case' on OS X.
Hey, whatever suits you best. I wasn't trying to put your approach down or anything, I was just genuinely surprised.

There are, as they keep saying, more than one way to skin a cat.

Best regards,
HMW
 
  


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
how do I find what MAC address web pages see as my MAC address rob.rice General 20 05-29-2010 02:08 AM
somebody cloned a MAC address and is using it on my WRT54GL router unclejed613 Linux - Wireless Networking 2 01-30-2010 10:44 PM
Trouble automating rsync Mac OS 10.5 to Synology (BusyBox) Server tenraek Linux - Server 0 03-15-2009 02:38 PM
How do I obtain a "busybox linux" router WAN ip address? Usalabs Linux - Networking 6 09-15-2006 06:53 PM

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

All times are GMT -5. The time now is 07:45 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