When connecting to the Pi via the network, by default, DHCP is enabled. This way it is possible for your Pi to change IP address from time to time.
That’s annoying when creating bookmarks, and having to find out the address time and again.
That’s why I’m going to setup a static IP for my Pi now.
Just connect to the Pi using ssh and type
This outputs some text where you can find your wireless adapter (probably called wlan0) .
Take a piece of paper and note down
- The current address (inet addr)
- Broadcast range (bcast)
- Subnet Mask (mask)
after that, type the command
sudo route -n
Note down the address of the gateway (second column) and the destination (first column).
Next, we need to adjust a configuration file, for the Pi to read when booting.
Do this the following way :
sudo nano /etc/network/interfaces
This starts the nano text editor, while editing an existing file called “interfaces”.
Somewhere in the file you should find something like
iface wlan0 inet manual
change it to
iface wlan0 inet static
and type the following below it
address [your chosen fixed IP address] netmask [your netmask] network [your destination] broadcast [your broadcast range] gateway [your gateway]
Lastly, reboot your Pi
That should do the trick.