December 3rd, 2008, 02:28 PM
Get routers mac address?
I am trying to learn how to build packets, I got everything down except how to get your routers mac address or what ever it uses in the packet.
How can I get my routers mac address? I am fine with using an external C++/asm dll.
December 9th, 2008, 01:07 AM
Re: Get routers mac address?
When you say 'Your Router' are you talking about the device your computer connects to or the network card in your computer? As the MAC address of your network card can be found out with similar code to this...
You will have to add a reference to 'System.Management' into the same project.
public static NICInfo GetNICInfo()
const String NO_MAC_ADDRESS = "00:00:00:00:00:00";
NICInfo nicInfo = null;
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
nicInfo = new NICInfo(mo["MacAddress"].ToString(), mo["DNSHostName"].ToString());
if (nicInfo == null)
nicInfo = new NICInfo(NO_MAC_ADDRESS, Environment.MachineName);
Note: NICInfo is just a struct to hold a Machine name and MAC address pair.
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.