I'm try to detect a network cable interface using it's mac address.
On some machine there is many type of adapter (cable, wifi, usb dongle, etc).
Is it possible to have the types of each mac address, such as wifi/cable/other?
The primary application is a Java program, but other languages would be useful too.
You can get your machine's current MAC in Java; you can't get remote MAC addresses.
Get MAC address on local machine with Java
If you were to connect the computer to the network one way, get the MAC address, and then remember that, you'd have it.
It sounds like what you want is a regexp to tell you if a particular MAC address is a wifi device, a cable router, etc; I don't think the space of MAC addresses was well enough designed to reliably allow for that, and you'd still miss cases of MAC spoofing.
Related
I am trying to connect 2 computer in my home using DatagramSockets (or even Sockets) in java. What exactly should I do? Which IP Address should I use to connect them?
If your machine is using DHCP then it's not upto you to decide which ip address you will use. Your machine will be assigned some dynamic ip address. To see that use ifconfig on Linux box and ipconfig on win machine. Once you have their IP address you can use these to connect your machine. Chances are high that your machine has dynamic ip's.
Assuming you're a windows user:
to get your LAN IP address open a command prompt and type ipconfig.
A bunch of stuff will show up, you are looking for the line that says
IPv4 address.....: 192.168.#.#
It should be noted however, that this is a so "dynamic" ip address, that can be changed whenever you disconnect and reconnect from your router.
I recommend that you either make your ip static (look this up on google, there are lots of tutorials) or use your computers hostname instead. To obtain your hostname you simply type hostname in the commandprompt.
in your code you can get your ip address by doing this in your client code:
String ip = Inet4Address.getByName("<your servers hostname>").getHostAddress();
I hope this helps, although questions like these belong on Super User, as they really don't have much to do with coding.
I'm building an email sending software and user's requirement is, this program would be able to get and change the MAC address of the system. I searched over internet and found how can we get MAC address using java. Here I found a sample code that list all MAC addresses of the system. Using this code I have my output like this.
Current IP address : 169.254.74.152
Current MAC address : 00-27-10-52-D6-49
Current MAC address : 70-F3-95-82-2A-85
Current MAC address : 0A-00-27-00-00-11
Current MAC address : 0A-00-27-00-00-12
Current MAC address : 00-27-10-52-D6-48
BUILD SUCCESSFUL (total time: 2 seconds)
This output include MAC addresses of
1. Wireless LAN adapter WiFi
2. Wireless LAN adapter Local Area connection
3. Ethernet adapter Bluetooth
4. Ethernet adapter Virtual-box
It shows the same output irrespective of whether I'm connected to internet or not. So my question is how can I determine the one I'm connected with i.e. If I'm connected and using WiFi internet I need WiFi MAC and if I'm connected using Network Cable I need that.
And also tell how to change/spoof that MAC address using Java.
It shows the same output irrespective of whether I'm connected to internet or not.
Of course it does. Your local MAC addresses don't change just because you're connected to the Internet.
So my question is how can I determine the one I'm connected with i.e. If I'm connected and using WiFi internet I need WiFi MAC and if I'm connected using Network Cable I need that.
You need it for what? There is nothing useful you can do with a MAC address in Java except to display it.
And also tell how to change/spoof that MAC address using Java.
You can't.
I want to develop a software, my proper way is JAVA, It sounds simple, but has its own problems.
I have a Network in which there are some devices ( about 400 radios or more)
I do not know their IP.
I just know the first and second part of their MAC addresses.
I want to find out their IP and the whole Mac address of all.
They are in my network, and i have forgotten their IP, and also MAC.
I found this Link useful, but in this solution it is about remote connection to nmap and also you should known the range of IP.
Note that this not about HACKING Or better to say is not about CRACKING or something like this, I have thousands of Radio's and they have been reset and need to be re-config.
Actually i need their MAC to config more than IP.
There are other questions on the net, but they are about having subnet, I do not have subnet of the LAN Network.
Now i am looking for any solution with java or other programming languages, with ARP or dd-wrt something like that, any suggestion? or any solutions? Any sample?
I appreciate this.
Thx all.
If this is your network, inspect ARP tables form network devices. You get all MAC addresses and corresponding IPs. Use SNMP protocol and corresponding libs to get this data form your Java code.
To test this approach use snmpwalk utility.
I have a device in my local network with unknown IP address and outside of my sub-net (it was configured previously as static IP in another network). I know though its MAC address. Is it possible with java to communicate with that device using only its MAC address?
I am able to get my virtual bacnet4j devices up and running. as I am running them on One windows machine i have used set of ip address 127.0.0.3-10.
I have a virtual Bacnet device which monitors other devices, which work fine when its on address 127.0.0.2 (or any other address starting with 127.0.0.* )
However I am now puuting it (Monitor) on Actual different windows machine running on IP say 192.168.2.3
My machines IP address on that Networks is say 192.168.2.2
Now The Monitor and devices won't recieve any broadcasted messagesfrom each other.
Any idea's if its achievable?
I have already tried using link service option within bacnet4j.
Now thinking of writing a bacnet router myself to achieve this. but wanted to confirm if What i am thinking is right? or is there a better way to achieve this communication.
The obvious: Any firewall activated?
Can you ping the other machine? Just to cover the bases.