Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Giving Your Devices Constant IP Addresses

0.00/5 (No votes)
21 Oct 2015 1  
Giving your devices constant IP addresses

Introduction

I have a standard wireless router provided by my internet provider Telus. It's an Actiontec V1000H. Even this device supports setting up permanent IP address, so the chances are, yours probably has that feature too.

What is an IP Address?

An IP address is an Internet Protocol address.

Each device on a network must have a unique network address in order to differentiate itself from other devices on the network. So think of an IP address as a devices telephone number on your home network.

Lots of devices are now connected to your wifi/network router, these now include your TV set, DVD/Blueray Player, Games Console, Mobile Phones, Tablets, PCs, Laptops, Hifi Receiver, Home Entertainment system, etc. And all of them have at least one IP address. I say at least one, because some devices can have more than that.

Consider your PS4, it has 2 routes through which to connect to your router and thus gain access to the internet and/or other devices on your home network, the first route is through its wired connection, and the other is through its wifi connection. Each one of these routes goes through a piece of networking hardware inside the PS4.

Each piece of networking hardware in your device has a MAC address. This is a permanent and globally unique identification number. Number with letters in ? Yes it's a number, but it's not in base 10 (decimal), it's in base 16 or hexadecimal (0-9, then 10=a etc f=15). So this MAC address is almost guaranteed to be unique in the whole world, the network router uses this MAC number to identify the device and give it an IP address so that all devices on the network can talk to each other through the internet protocol (hence IP address).

So each device has one or more MAC addresses and each MAC address is given an IP address by your router. When a device connects to your network, either wirelessly or through a cable, the router gives it an IP address randomly. That's why every time you plug in a device to your network, it ends up with a different IP address. If we want to connect to a certain device through remote desktop, VNC, SSH, ftp, etc. we want to know the IP address every time.

Note that the IP address given to your device is a local IP address only, that is, its context is on the LAN (Local Area Network) it is connected to. So this IP address is not your devices IP address on the internet, you will not be able to connect to that device from the web with that IP address. That's a more complicated task and beyond the scope of this tip.

Let's Go !

Ok, first of all bring up your web admin page for your wifi router. Don't have one? Check your instruction manual online (there are lots of instruction manual web sites), the chances are your router does have a web portal or admin page, even if you don't think so.

A good way to discover the IP address of your wifi router and hence its URL (or admin web page address), is to bring up a command shell in windows/linux and ask for the network info. On Windows goto Start->Run->cmd.exe, now in the command shell type:

ipconfig

Here is an example of the output of PC:

Windows IP Configuration

Ethernet adapter Ethernet:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Local Area Connection* 3:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . : telus
   Link-local IPv6 Address . . . . . : fe80::9910:XXXX:8b88:9956%4
   IPv4 Address. . . . . . . . . . . : 192.168.1.68
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.254

Ethernet adapter Bluetooth Network Connection:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Tunnel adapter isatap.telus:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : telus

Tunnel adapter Teredo Tunneling Pseudo-Interface:

   Connection-specific DNS Suffix  . :
   IPv6 Address. . . . . . . . . . . : XXXX:0:5ef5:99fb:XXXX:27a6:3a57:fabb
   Link-local IPv6 Address . . . . . : XXXX::241a:20a6:XXXX:febb%9
   Default Gateway . . . . . . . . . : ::

From here, we can see my routers (Default Gateway) IP address is 192.168.1.254, ok type that in your web browser in the address text entry box. for me this brings up my routers web admin page, like I said before check your manual, your router may have its admin page hosted on a different address.

For linux/unix OS, simply type:

ifconfig

Discovering the Device MAC Address

You will now need to find the MAC address of each device. The best way to do this is to look at the web admin  page of your router, and turn off the device whose MAC address you want to know, then write down what MAC addresses are already connected, then connect the device. Obviously the new MAC address will be your devices MAC address.

Reserving an IP Address for a Specific Network Device

From the MAC address of your device, we now allocate a specific IP address, so that every time the device connects to your home network, it will be given the same reserved IP address.

For most routers, you need to look for a settings page/tab called DHCP Reservation. For me, I have to log in to the device first, then go to my Advanced settings, from here, I can open the DHCP Reservation page.

On this page, I select the MAC address of my device and give it a specific IP address. I use numbers such as 192.168.1.100 for my PC, 192.168.1.101 for my Raspberry Pi, 192.168.1.102 for my goflex network drive, etc.

Conclusion

So you can now set a device to have a static IP address on your home network, no more searching for IP addresses!

Another benefit is to only allow the MAC addresses you recognize (i.e., your own network devices) to connect to your wifi (use the security page of your router). That way, anybody who knows/cracks your wifi router password cannot connect to the internet through your router, so no more strange old men sitting in cars outside your house!

Happy networking!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here