Static IP on Raspberry Pi

If you have alot of things connected to your local net you will eventually want to give every gadget it's own, static IP. Here's a brief description on how to do that on your Raspberry Pi. I have a WIFI dongle attached to mine and I wanted both the LAN and WIFI to have the same IP (as I will only connect either the LAN cable or use the WIFI dongle)

In your terminal, type:

sudo nano /etc/network/interfaces

Now, copy in the following, replace XX with the IP you want on your Pi:

auto lo

iface lo inet loopback

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

auto wlan0
iface wlan0 inet static
address 192.168.1.XX
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255

auto eth0
iface eth0 inet static
address 192.168.1.XX
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255

Press CTRL-O to save and then CTRL-X to quit the nano editor. You must also edit the /etc/wpa_supplicant/wpa_supplicant.conf file. Type:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Edit the settings to match your WIFI SSID and password

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="YOUSSIDHERE"
key_mgmt=NONE
auth_alg=OPEN
wep_key0=YOURWEPKEY/PASSWORD HERE
}

Press CTRL-O to save and then CTRL-X to quit the nano editor. Then reboot your Pi with:

sudo reboot

 

Source: http://raspisimon.no-ip.org/ipaddress.php

Tags: