How to Determine appropriate MAC address using Java - java

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.

Related

Which ip address should I use to connect 2 computers in my home using datagram sockets in java?

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.

Internet of Things : ESP module Wifi Ip address

as you can read in title I'm making a super simple IOT (Not really)
and
using a esp8266 and want to make it connect to my home wifi network and make a communication between a android app and the module (android app connects to home wifi)
Note : Iam Using CODE VISION AVR
you may say :
Why not directly connect to ESP when its on Server Mode?
that's fine cause when ESP is server "he" can set ip for him self so
ip will be always same BUT I want it to connect to home wifi
-
Why you wont connect with IP ?
you cant find the module ip easily because its given by Wifi
-
Find ESP ip using IP scanner
Its not possible cause it changes every time and user have to change
IP every time in android app AND my app cant scann every time it want
to connect to a single device its so dumb...
-
Do a Static Ip for ESP !
well that's not possible too because maybe that IP was taken by
someone before ESP send static IP AT command ! + if IP wasent taken it may taken after Home Wifi Restarts !
Sorry for bad English :X
You can use software serial to configure esp8266 from arduino. You need to know the setup circuit perfectly. Keep it in mind that esp8266 operates on 3.3V where arduino gives 5V output. The most important thing is to send AT commands to esp8266. You can use the following command to connect with your wifi.
AT+CWJAP="Your_WiFi","password"
If you need to see the ip address of esp8266, you can use this command.
AT+CIFSR
If you want to set static ip to esp8266 , then you can try this one.
AT+CIPSTA="ip module","ip gateway","subnet mask"
Use mDNS responder:
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266mDNS/examples/mDNS_Web_Server/mDNS_Web_Server.ino
This way you would be able to connect to ESP8266 via hardcoded url like http://esp8266.local.

connect to device using MAC address with java

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?

Detecting wi-fi or cable network interface by mac address

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.

How to get web client

I want to get the web user/client mac address, i.e i want to restrict the users to open my web application with register mac address only. So other systems could not open my web application,
For example, if the user entered URL in the browser and enters, the request will go to the server, in the server side is it possible to capture the mac address of the client?,if it is possible i can restrict him to open my application by checking with my already registered mac addresses.
please help me.
The MAC address does not survive beyond IP routers. You can't find the client MAC address from a remote server.
In a local subnet, the MAC addresses are mapped to IP addresses through the ARP system. You can find the MAC address of computers within your subnet using 'arp -a' or 'nbtstat -A ipaddress' command in windows.
However, when your packets passes though the router from the local subnet through the gateway out to the Internet, the originating MAC address is lost.

Categories