I'm thinking of a way to find the public IP of router at home, remotely.
For example if I'm in university and I need to connect to a machine in my home network. How can I get the public IP to connect to it?
To get the IP from that machine I can use something like this website - http://api.exip.org/?call=ip
But how can I send it to myself remotely?
One of the ideas is to write some sort of script that will check my email address for incoming messages. So when I need to know the IP, I just send some email to myself with specific text (or subject). When script will find that specific text, it will send the IP to the same email.
Another idea it to write a script that will upload a new file to the server (for example DropBox) every time the public IP is changed.
Or I can combine those two and email new IP every time it changes (not that often, but still it’s a spam).
What other solutions there can be, and how can I implement them (or the one that I have)?
I have Linux/Unix and Windows machines which I can use. I have no problem in writing code in different languages or looking in to any possible approach.
most of home router have dynamic DNS facility , you will find it in your router configuration as DDNS and configuration page you will find list of supported DDNS service ,most popular DDNS service is dyndns.org you have to subscribe there and they will give you tow free subdomain like example.dyndns.org , and after configuring that on your router you can easily from any where ping example.dyndns.org to know your router IP
Related
Xfinity is my ISP. I would like to be able to (occasionally) access my home network while away from home. I know how to configure the router etc., but the issue is this: I do not have a static IP, and without the router's current IP address, I cannot connect with it. My question is this: Is there some way to build a website that shows the current IP address? Note that this does not have to be up-to-the-second accurate - I could possibly write something to update the site say on a daily basis.
I'm building a home IoT device and I can't figure out a way of setting a static IP which would work on any network. I want to be able to ship this device to anyone having previously set a static IP and all they would have to do is connect to the internet and be good to go.
Any help is appreciated!
Consider using Teredo(Miredo in OpenSource world). Following is an excerpt copied shamelessly from Wikipedia.
In computer networking, Teredo is a transition technology that gives full IPv6 connectivity for IPv6-capable hosts that are on the IPv4 Internet but have no native connection to an IPv6 network. Unlike similar protocols, it can perform its function even from behind network address translation (NAT) devices such as home routers.
You can let your customers to configure the robot like a normal IoT device. Once the device is up and running, it will automatically connect to relay server and get an IPv6 address. This IPv6 address can be static or dynamic, updated to your server without using any third party.
This will give you seamless bi-directional connectivity between your server and robot(s) without resorting to port forwarding. You may have to address the security concerns by restricting the access to IPv6 address using PKI infrastructure.
Checkout Miredo at https://www.remlab.net/miredo/. You can even consider setting up your own Miredo server/relay.
the gateway IP of home routers changes constantly. this is why there is No-IP, DynDNS,... and similar services . this is also a common working solution. your customers need a dynaemic DNS provider or a similar service. This is also a common solution for scurity cameras. Another possibility is that the RPi sends the information to a cloud or another storage outside of the network and the app has access to this cloud. however this could be problematic because of privacy...
http://www.noip.com/support/knowledgebase/using-security-camera-systems-with-no-ip/
http://www.networkcameracritic.com/?p=124
the problem is that you want the external or WAN IP to be static like that of google or other big companies. This is very expensive and not every Internet Service Provider has this service. Another problem is that the IP of a smartphone on that the app runs also changes constantly.
Maybe the accepted answer in this link is useful http://www.superuser.com/questions/778640/do-you-need-a-static-ip-address-to-setup-a-webserver
Why do you need a static IP? I assume you want to open ports on the device and then have users to connect to it.
If that is the case: Simply do not do it! Its a major security problem.
Why?
Having all ports closed provides zero attack surface. If you open ports to the Internet, IoT device search engines will find this and try to attack it. And even if you protocol is secure today and even if users use secure passwords, how can you guarantee this in 5 years?
Instead open a connection from the device to a server, and let the users connect to the server. This allows central protection, monitoring (IDS) and security updates.
Here is an update in case anyone is having the same issue. I ended up using node package ip to update each robot's ip in my database. Each client then pulls the ip from the DB to connect.
Here is a snippet of my code. The server is fired on boot.
var ip = require('ip');
var mongo = require('mongodb')
var MongoClient = mongo.MongoClient
var url = 'your_url'
var name = "example"
function updateIP() { // update ip if need be
var my_ip = ip.address()
console.log(my_ip)
MongoClient.connect(url, function(err, db){
console.log(err)
var robots = db.collection('robots')
robots.findAndModify(
{name: name},
[['name', 1]],
{$set: {ip: my_ip}},
{update: true})
})
}
I am logging every user's IP when they access the company's page.
There are two ways to access the page from inside the local network:
http://company/webpage
and
https://webpage.company.com
What bugs me is that even when the users use the https global IP, their accesses are still recorded on database with their IP as 10.50.1.12 or 10.50.1.100.
Does that means that the browser or something else is redirecting the https://webpage.company.com to company/webpage? Or does that mean that I'm using a flawed method to log the users IP?
Another way to ask my question (just to make sure I'm being clear): if I'm accessing my Internet web page from inside the LAN network, am I effectively going outside my network and then back? If not, where am I going wrong with my logging?
Code used to log user's IP:
user.LastIP = HttpContext.Current.Request.UserHostAddress;
I'm curious about this because I want to make sure the users inside the company will access the page using exclusively the LAN Network. The goal is to save bandwidth usage, which is scarce.
Edit:
Pinging the https://webpage.company.com from inside the LAN network will result in a reply from a global IP address like 194.xxx.xxx.xxx. So I'm clearly getting the user's IP wrongly. What would be the ideal way of retrieving the IP from the page accessing entity?
Access to http://company/webpage will result in a DNS lookup of the host name "company". To resolve this, DNS will need a fully qualified domain name (fqdn), so it will add a top level domain (according to the configured search list in the client). In this example, it seems fair to assume that the fqdn will be "company.com". This, in turn, may very well resolve to the same IP address as the "webpage.company.com". You can check this by using dns lookup utilities like 'nslookup' and 'dig', or simply by using 'ping company' and 'ping webpage.company.com'.
The users IP addresses you mention, 10.50.1.12 and 10.50.1.100, seems to be the local IP addresses of the client hosts. I base this assumption on the fact that these IP addresses come from the RFC-1918 address range which is used for internal addresses. My guess is that these are the correct IP addresses, and that your logging works fine.
The users IP address you will log from accessing 'http://company/webpage' and 'https://webpage.company.com' should in most cases be the same. You can see it this way: it doesn't matter what the target URL is, traffic is still coming from the same host, the same IP address.
In any case, you most probably don't need to worry about any traffic leaving your local network.
So for those who knows what bitcoin miner is I got one, for those who don't know what it is they can search to see what i mean.
Anyway as far as I have seen, machine is running and configurable through mikrotik installed on raspberry pi.
And I got it working.
The problem is that machine is located on my friend's house, and I need access to the machine from time to time. So far I have made redirect on router so machine is accessible to outside world.
But I can access it only if I know what is ip address of my friend internet. But as he have dynamic ip address, the address is changing from time to time, and I can't access the machine unless he tells me the new address.
What are the possible ways to track dynamic ip address and know what is the address when it's changed so I can access machine any time?
You can access your external ip address formatted as simple text from http://wtfismyip.com/text. You can write a shell script to 'wget' the address and 'mail' it to you. The 'crond' on your raspberry pi can then regularly execute the script.
How can we know our own EXTERNAL IP address on the CLIENT (=our computer); NOT our internal IP address, NOT through an existing web site, NOT through a new website we would fabricate for this question; JUST with pure client OS commands scripting and/or JavaScript? Is that possible? In fact, if someone as a way to do that they should collect 1 million dollars because nobody has EVER come up with an answer to that on ANY website on this planet to my knowledge, A.R.
I think somebody DID ask that already, but using C#
IPHostEntry host;
string localIP = "?";
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
localIP = ip.ToString();
}
}
return localIP;
I don't know the OS you're targeting, but you might create an console application and read the value from it
Hope it helps
As Gricha mentioned, it can be requested via external site. There is an open source project that is also hosted.
You can get your external IP info in JSON format by calling this API:
curl http://ip2country.sourceforge.net/ip2c.php?format=JSON
in C#, there must be a similar method to call web API.
The project info is here: http://code.google.com/p/ip-address/
You can't find an external ip address from a simple system call. You can receive it from the router, which is probably router specific, or you need to make a call from an something out side of your lan. Typically this is done through a HTTP request or some other popular internet service.
Also, individual computers on a local network don't have an external ip. The router has one address and forwards packets to the individual device.
You can't do that without going out of your current network.
To know your IP address you need to ask your router about. It's your router that gives you the IP in his network.
To know the IP address that belongs to your router in their network - you need to ask someone in that network about your IP. Because that network gives him an IP.
Finally if you want to know your IP outside your ISP's network - you need to ask someone outside your ISP's network about it.