Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C#

Get Router / Modem LAN-MAC-Address in C#

I was asked to program a small simple software where you can press a button and it shows the lan mac address of the router which is directly connected through an ethernet cable (There is no label or anything like that on the router with the mac address written on it and we can not log on the web ui because we have no password)

I am able to show the mac address through an arp -a command inside of the code, but there are some infos that are not needed like the ip address and the type (dynamic / static) and for some non-tech people it looks maybe too complicated (It should be really simple to use - Just a button and a window to display the mac address)

I found this post on stackoverflow https://stackoverflow.com/questions/16275430/fetching-the-mac-address-of-my-router-not-my-network-card-mac-using-c-sharp but it only returns the MAC-Address of my network-card and not of the router.

Any help would be appreciated!

1 Answer

James Churchill
STAFF
James Churchill
Treehouse Teacher

Armin,

Couldn't you just parse the MAC address out of the results of the arp command?

Thanks ~James