Data Acquisition Categories
How to Manage Dynamic IP Addresses In Data Acquisition Applications Over the Internet
One of the most exciting applications for DI-71X (DI-710, -715B, -718B) Ethernet products is to acquire data from anywhere in the world over the Internet. Although setting up IP addresses is a straightforward procedure in this situation, the approach potentially suffers from one troubling flaw: IP addresses assigned by an Internet Service Provider (ISP) are commonly dynamic, meaning that they can change from time to time. I refer here to the IP address assigned by the ISP to the router, which DI-71X products use to connect to the Internet. The fact that IP addresses are dynamic, meaning that they can change and in the process render all your careful IP address assignments useless, is a problem that needs to be recognized and dealt with before it happens.
As you are probably aware, every time you connect to the Internet, you do so using an ISP. In most situations the ISP has a pool of IP addresses they own and routinely and temporarily lend to their customers. This means that, quite transparently to you, the IP address you use to surf the Web today, may not be the same one that you used yesterday. That one may be used by your neighbor today, and yet a different customer of the ISP next week. Generally, you don't care that this IP address shell game takes place behind the scenes as long as when you fire up your computer you have ready access to the Web. However, there are some situations when it does matter.
Figure 1 — Properly Managed, any DI-71X device can be accessed from any location in the world through the internet.
One such example is when you expose a DI-71X instrument to the Internet with the goal of accessing the data it acquires from a remote location. Figure 1 represents this application in schematic form, and a step-by-step approach for making it a reality is as follows:
- Connect the DI-71X instrument to the LAN, which is managed by a router that ultimately allows devices on the LAN to connect to the Internet through an ISP. The router typically assigns the instrument a private IP address that is useful only on the LAN, or private side of the network.
- Using utilities that are built into the router, assign the 71X instrument's private IP address to one of 65,535 ports.
- Again, using utilities that are built into the router, expose the selected port to the Internet.
- Determine the public IP address of the router by using a free utility like www.whatismyipaddress.com/.
That's all there is to it. You can now access the DI-71X instrument from anywhere on the Internet by using the IP address obtained in step (4) and the port you chose in step (2). Is all this too good to be true? In some situations, the answer is yes. Read on.
The Fly in the IP Address Ointment
I've already explained how the IP address assigned by the ISP to the 71X's router today may not be the one assigned to it tomorrow, and you have probably guessed the ramifications of this: While the IP address remains unchanged, accessing a 71X instrument located in New York from a PC in Tokyo is fast and easy. But the instant the ISP changes the public IP address of the 71X's router, you can't access it from across the street. If your ISP can spontaneously change your router's IP address you have three options:
- Ask your ISP to assign you a static IP address (one that won't change).
- In the event that an IP address changes, have an inside person query the router and relay the new address to you.
- Use a Dynamic DNS service.
The first option, a static IP address, is simultaneously the easiest solution and the most difficult to secure. Remember that ISPs own only a finite quantity of IP addresses, which they lease to all their subscribers. The one they give to you permanently as a static IP address is one that, by definition, no one else can use. The assignment of static IP addresses lowers the ISPs inventory of available IP addresses with the usual supply versus demand affect on price: Static IP addresses are expensive, if you can get one at all. Option (2) is clearly inconvenient, if not impractical. What happens if the router's IP address changes at 2 AM? The best solution, and the topic of the remainder of this application note, is to use a dynamic domain name service (DDNS).
What is DDNS?
You can think of DDNS as an automated version of option (2) described above, your assistant that spends most of its time doing nothing, but springs into action whenever the public IP address of the router changes. In a nutshell, assuming your router supports the DDNS protocol, it can autonomously and automatically contact any number of free web-based services whenever the router detects that its public IP address has changed. The router logs on to an account you setup and maintain, and updates the account with its latest public IP address. Since the same account is accessible by you using your favorite browser, you can determine the IP address of your router at anytime, and from anywhere.
How To Use Dynamic DNS Websites
There are actually quite a few DDNS websites, which you can join and use free of charge, but only those supported by the router will actually work. So the first step is to verify that your router does indeed support DDNS and the specific DDNS websites it can access. My router supports the following: www.DynDns.org, www.No-IP.com, and www.EasyDns.com. Since I have experience using DynDns.org, I'll use that website as an example in all further discussions, with the caveat that other websites may function slightly differently. Getting started with DDNS is simple and free. After you determine the website you want to use, go there and:
- Establish an account, creating a unique username and password.
- Next, you'll want to create a hostname for each router you want to manage. If you have three different locations, each exposed to the Internet, then you'll need three hostnames, one for each router. Many DDNS websites support host names beyond the basic name of the website. DynDns.org supports a total of forty-six. The hostname I chose for myself was ‘rwlockhart.isa-geek.com' (no chuckles, please. It seemed appropriate at the time).
- Next, turn your attention to your router by accessing its DDNS features and configure it for the DDNS account you established in steps 1 and 2. You'll need to tell the router the DDNS website, your hostname, your username, and finally your password. Figure 2 is a screen shot of my router's DDNS configuration panel. Clearly shown are entries for the items just described. Finally, make sure you enable the DDNS feature.
Figure 2 — Screen shot of the DDNS configuration panel for a D-link wireless router. (click image to enlarge)
- When the router's DDNS feature is enabled the router will access your account on the DDNS website and update the account with its current public IP address. It will do this again whenever it detects a change, 24/7/365. Not bad for free, right?
- To determine the public IP address for any remote location, you simply log onto the DDNS website. Figure 3 is a screenshot of my account clearly identifying my hostname, the public IP address of my router, and the date and time when the router last updated the information. In this example, I'd access my DI-71X instrument at IP address 22.214.171.124, and at whatever port I assigned the instrument to on the private side of the network.
It is important to note that although you may use an ISP that supplies dynamic IP addresses, meaning that the public IP address of your router may change from time to time, you have complete control over the port number assigned to the 71X instrument on the private side of the network. It will never change unless you change it. So as long as you can access a DDNS service to determine the current public IP address of your router, you can be assured that everything else remains unchanged. Moreover, I want to stress that your ISP will never change your router's public IP address while you're accessing it. You don't have to worry about being in the middle of a data upload or instrument configuration and having the process hang because your ISP impulsively changes the IP address in the middle of the session.