IP to MAC address binding

If you are like me and have several clients (any type) connected to your network and probably to the router, then it is important to be able to keep track of things.

For example I can ssh in to my pi as I know its IP address,  however there are times when for some reason the DHCP on the router may decide to issue it with a new IP address which can cause issues with ssh to that device, or using the hosts file to bind a host name to a particular device

127.0.0.1	localhost
127.0.1.1	e-machines
192.168.1.17	raspberrypi
192.168.1.19    raspberrypiwifi
192.168.1.1	Router
192.168.1.10	BRN001BA956BDE6
192.168.1.13	Inspiron-1011

For example the above is my OLD /etc/hosts file.   things have now changed.

With the above settings I could do

ssh user@192.168.1.17 or ssh user@raspberrypi,

both commands would have the same effect,  if the IP address changes then the /etc/hosts needs changing too.

Getting rather frustrated with this situation i decided to have a look at my router settings and found this

lan-settings

 

Lan IP settings

This area of the router configuration allows you to bind a MAC address, this is a unique HEX number string that is embedded in networking interfaces,  there are literally millions of possible combinations.

You can therefore tell a IP address to be reserved for a particular IP Mac address, so for example a raspberry pi ethernet port can have

f8:0f:41:26:84:dc as its mac address you can bind the IP address 192.168.1.100 to this.  So when ever that network interface on that device is connected it gets the same IP address.  This then of course means you can :

Set /etc/hosts file so it does not need to be changed, only updated as new devices are added

set up port forwarding knowing that for example 192.168.1.125 on port 6667 will always to that server ,which in the case of port 6667 is running an IRC server.

If you click on LAN IP Settings you get this screen up

address-reservation

 

The options allow you to specify the IP address you want,  mac address (type ifconfig to get a list of devices and associated details

eth0 Link encap:Ethernet HWaddr f8:0f:42:81:84:bf

is where you look to get the MAC address.

You can also look under attached devices.

I still need to hack a new /etc/hosts file but this is going to save me so much hassle, later on, I can then replicate the same /etc/hosts file across the network and of course just alter it slightly for each device, as things need to be in a different order.

NOTE: For the purpose of this article i have pasted in my own mac addresses but then changed them manually in the text,  this is for security reasons. I have also scrubbed out the device name for the router.