3.16667

3.2 | 6 ratings Rate this file 14 Downloads (last 30 days) File Size: 2.81 KB File ID: #8233

Get MAC and IP Address, Network IDs

by Steven Huang

 

06 Aug 2005 (Updated 09 Aug 2005)

This c-mex function obtains the MAC and IP addresses and IDs of the computer.

| Watch this File

File Information
Description

Obtain physical address (MAC) and IP address of the computer. Acts as an MATLAB version 'ipconfig'.

MATLAB release MATLAB 6.5 (R13)
Other requirements VC6 ++
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
08 Aug 2005 urs (us) schwarz

a more MLbbish solution could look like this (on wintel boxes):
a=strread(evalc('!ipconfig -all'),...
   '%s','delimiter','\n');
a([strmatch('IP A',a),...
   strmatch('Physical',a)])

08 Aug 2005 Stephen LL

Here is another solution for getting the IP address that should work on most computers.
MyExternalIP=regexp(urlread('http://checkip.dyndns.org'),'(\d+)(\.\d+){3}','match');

15 Aug 2005 Marcelo Pisani

The authour does not provide instructions of how to compile / call the file in Matlab. The solution proposed here by Stephen could not get the MAC number. The solution proposed by Schwarz will fail in non-english versions of IPCONFIG.EXE.

16 Aug 2005 Michael Kleder

Good approach if java isn't an option, such as when running matlab with "matlab -nojvm" or if a Java call isn't desired.

If Java is an option, I've had good luck with:
char(java.net.InetAddress.getLocalHost.toString)

15 Sep 2005 Najeeb Ahmed

this software solve my problem i am really now full relex now solve my mentally tention.
Thanxs

29 Sep 2011 Tsinghua  
29 Dec 2011 Peter

I love the speed of this function compared to the dos ipconfig solution. However, I cant seem to figure out how to store the displayed information into a variable?

I have never worked with the mex files, so trying to alter it to spit out output is too hard for me.

Would appreciate help

Peter

01 Feb 2012 Xiangrui Li

Here are a way to get MAC address for different systems:
system('getmac'); % windows
system('netstat -I en0'); % mac
system('/sbin/ifconfig eth0'); linux

-Xiangrui

Please login to add a comment or rating.
Updates
09 Aug 2005

Error handling of GetIP is added. This makes the function call more tractable.

Also network identification fetching is added.

Tag Activity for this File
Tag Applied By Date/Time
mac address Steven Huang 22 Oct 2008 07:55:14
ip address Steven Huang 22 Oct 2008 07:55:14
networking Steven Huang 22 Oct 2008 07:55:14
network ids Steven Huang 22 Oct 2008 07:55:14
mac address Christian 17 Jul 2009 16:51:15
ip address Itamar 29 Nov 2009 07:52:37
ip address Oleg 13 Apr 2010 03:45:33
mac address Mohamed Hilal 26 Sep 2011 18:15:15
mac address Mohamed Hilal 26 Sep 2011 18:15:15
ip address Sander Aerts 14 Oct 2011 03:45:43
mac address windows mac linux Xiangrui Li 01 Feb 2012 15:47:19

Contact us at files@mathworks.com