Sunday, 18 May 2014 11:38

Configure the Raspberry Pi a Static IP Address

Written by
Example Configuration
  • Raspberry IP: 192.168.0.123
  • Router IP (Gateway): 192.168.0.254
  • Subnet Mask: 255.255.255.0
  
List the network interface we currently have available:
cat /etc/network/interfaces
The output should look like this:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
The line iface eth0 inet dhcp shows that it is currently getting out IP address via DHCP. We need to change this line to iface eth0 inet static.

Edit /etc/network/interfaces
sudo nano /etc/network/interfaces
Change  iface eth0 inet dhcp to iface eth0 inet static and add the following settings just below it:
address 192.168.0.123
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
Here is an example:

auto lo

iface lo inet loopback
iface eth0 inet static
address 192.168.0.123
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Finally, reboot the Raspberry Pi.
 
 
Fixing DNS problems
DNS is the service that converts the website URL, i.e. www.goggle.com into the IP address (173.194.126.36) that is needed for actual communication. 
 
Check your DNS entrie
cat /etc/resolv.conf
 
Here is an example of the output
nameserver 192.168.0.254
The nameserver should same as your gateway (your modem IP). If the nameserver and the gateway is different, you should modify the /etc/resolv.conf file and change the nameserver to your gateway IP.
sudo nano  /etc/resolv.conf
 
 
Read 6832 times Last modified on Friday, 06 June 2014 18:55

Leave a comment

Back to Top