How to get web client - java

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.

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.

Java Server client and hos name computer

I made a simple java client server program its work very well on my computer (localhost) but when I run the server on my computer and the client on friend computer I don't know how to get my full hostname that the client need when I go to system information get the hostname from their and run the client he cant find this hostname, what I supposed to do thank you for your help
Sounds like what you want is port forwarding.
Login to your router by going to 192.168.1.1 on your web browser (if that doesn't work try 10.0.0.1)
Type in your username and password for the router, they're usually on a sticker on the side of the router.
Get your computer's local IP address by looking for your computer's name in the list of connected hosts on the router, or by following the instructions for your OS on https://kb.iu.edu/d/aapa
Go to the port forwarding section on your router's config page and add a new rule that forwards traffic from the port you specified in your program (like 5000 or something like that) to your local IP address (something like 192.168.1.12).
Get your public IP address from https://whatismyip.com
Make your client program try to connect to your public IP on the port you chose
Start your server on your computer that you port forwarded
You should then be able to tell your friend to start his client to connect to your server.

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?

How to give access to localhost:8080 on network?

How to make my computer as a server so I run the application on IDE and be accessible by other computers on same network via their browsers?
If your server local ip for example is 192.168.1.20 and your web server port is 8080 then you can access your server by giving IP:PORT in the browser
eg: 192.168.1.20:8080/index.jsp
You can't make "localhost" accessible, by definition. What you can do instead is have the server process listen on an external IP address (or all addresses) instead of just on the loopback address. We can provide a more specific answer if you'll tell us how you're launching the application server.

Tracking client system ip address

We are launching an ERP application on cloud and hence planning to capture the system ip address of the clients machine who access the application from our server.
This ip address that we are fetching is it the system ip or localhost ip?
It is fetched using
InetAddress local_ip=InetAddress.getLocalHost();
InetAddress remote_ip=InetAddress.getByName(request.getRemoteAddr());
Is it secure to fetch the ip address or mac address? As i know the ip address is unique only across a network.
Thank You
You will not be able to track the mac unless you are on the same network. Once the packet crosses a router the mac addr becomes the mac of the routers you bounce across at each hop. Mac addresses are available to the broadcast domain only. Some devices support proxy arp though.
IP addresses might change over sessions. Think about NATted clients and DHCP assigned addresses. These keep changing. Same IP might represent another client at another time.
Considering security, as mentioned in a comment, no.

Categories