Complete novice with this topic - struggled to grasp an understanding.
Two devices - Device A, Device B(Laptop)
Device A - IP Address 192.169.0.120
Device B - IP address 192.169.0.121
Device B(Laptop) is connected to WiFi, and to Device A through Ethernet cable.
I have an embedded app in Device A, which i access though web browser on Device B(Laptop), on Device A's IP Address.
Is it possible to make this IP address public - for instance my mobile to pick up Device A's IP address?
I've looked into VPN's (hamachi) and port forwarding. is this the right way to go?
image of example setup
You can use ngrok to obtain the public ip address. This will basically expose your machine as public although it is in private network.
reference : https://ngrok.com/
You can't connect from outside the network using your local ip (192.168.0.120). Check out this topic if you want to know how to grab your external ip:
Getting the 'external' IP address in Java
Related
I have an ESP8266 that connects to my WiFi network after being configured (via WiFi Manager library) and runs a HTTP web server that displays certain sensor data. It connects to my specific network with a 192.168.0.XX IP and it works well.
My problem comes with the android app, and how to actually programmatically retrieve the IP that the webserver is running on? My routers DHCP only reserves IP's for a week - so hardcoding the IP into the app is not a good option, and having less tech-savvy people find the IP and configure it themselves is also not what I'm looking to do.
I also can't hardcode a static IP as friends & family will be using this with different networks and routers (so 192.168.0.X would not work on a router with an IP of 10.0.0.1 for example).
So, how do I go about programmatically getting the IP of my ESP8266 that is connected to my local network?
There is a solution that maybe isn't very optimal and professional, but will do for hobby project. You can make your android app scan your local network using http GET on all addresses - e.g. trying to GET something like this: http://192.168.0.X/sensor_status. You can configure your esp8266 device to respond with code 200 (OK) and save this address in your android app's persistent storage. Next time you can simply check if there is ip saved in persistent storage and try to connect to it. If esp8266 is not available under remembered ip, you can re-scan your network.
There's a way to make a MySQL with XAMPP go online to connect by Mobile Data (Android app) or PC app without beeing on the same local area connection?
This are the specs of the PC where XAMPP is running:
16GB RAM
i7-8700
SSD - 512GB
Integrated GPU
100MB Internet Connection (Optical Fiber)
What im tying to do is connect to the DB without beeing on the same connection as the PC where XAMPP is on execution,something like open the Android app on California meanwhile the PC is on Baja California
The problem is that your PC is most likely sitting behind a router. The router maps multiple private IP addresses to one public IP address. How does it do that? It uses NAT. In very basic terms, when a device D1 (say with private ip 192.168.1.10), sits behind a router and wants to communicate with a public device D2, it sends a request. The request goes to the router. The router adds the public IP address and an arbitrary port (e.g. 12345) to the packet. The router keeps a table with all ports linked with the private devices (e.g. 192.168.1.10 -> 12345, ...). Then it sends the packet to D2 using D2's public IP address. D2 sends a response back to the router public IP. The router forwards the packet to the private device using the port number and the table, in this case the device is D1.
So, you can't directly communicate with a device sitting behind a router from outside the router. However, you can use port forwarding. You can tell the router to always map a specific port to a specific private IP (your PC's IP). Then, you make the other deivce (your Android app) communicate with it using that port.
In summary, if we have two devices, A and B, and A is behind a router. If A wants to initiate a connection with B, then:
if B is behind the same router, then they can use their private IP addresses.
if B is not behind any router, then A can communicate with it using B's public IP address, as demonstrated above.
If B is behind a different router, then there must be some kind of port forwarding.
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'm trying to connect my pc to my android phone via WIFI..
But the problem is anytime I disconnect my phone from WIFI and turn it on again
I'm getting a different IP address so my pc doesn't connect until I change the IP address to connect to.. Is there any way to get the correct IP address of the phone?
That might be a router settings issue. Have you ever heard of "DHCP Reservation"? Most routers support such an option, which enables the router to memorize an IP to every distinct client ever connected and then to assign this ip to the respective client every time it reconnects.
Check your router settings / documentation for this option.
Here is a link, which could help you with your further investigation:
http://lifehacker.com/5822605/how-to-set-up-dhcp-reservations-so-you-never-have-to-check-an-ip-address-again
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.