Question 2.3: Setting a Static IP Address You would like to set the IP add......

Setting a Static IP Address

You would like to set the IP address of your Raspberry Pi so that it does not change.

Step-by-Step
The 'Blue Check Mark' means that this solution was answered by an expert.
Learn more on how do we answer questions.

To set the IP address of your Raspberry Pi, whether using a wired or wireless network, you need to edit the configuration file /etc/network/interfaces.

If you view your /etc/network/interfaces file using the following command:

$ more /etc/network/interfaces

it should look something like this:

iface lo inet loopback
iface eth0 inet dhcp
iface wlan0 inet dhcp
wpa-ssid “ssidgoeshere”
wpa-psk “passwordgoeshere”

To edit this file, type the following command:

$ sudo nano /etc/network/interfaces

If you are using a wired network, change the section for the adapter eth0; for a wireless network, change the section for wlan.

First, decide on an IP address to use. You need to pick one that is both unused by any other machine on the network and within the allowed range of IP addresses for your home hub.

Modify the contents of the file, changing the word dhcp to static and adding the following lines:

address 192.168.1.16
netmask 255.255.255.0
gateway 192.168.1.1

With the file changed as shown here, the static IP address of 192.168.1.16 has been assigned to the eth0 interface.

iface lo inet loopback
iface eth0 inet static
address 192.168.1.16
netmask 255.255.255.0
gateway 192.168.1.1
iface wlan0 inet dhcp
wpa-ssid “ssidgoeshere”
wpa-psk “passwordgoeshere”

For most networks, the netmask setting should be set to 255.255.255.0 and the gateway should be the IP address of your home hub itself. This will be the same as the IP address you use to connect to its admin console.

After you edit and save the file, restart your Pi for the changes to take effect.

Discussion

Internal IP addresses are typically something like 192.168.1.16, where just the last number is changed for each of the different computers. Another common format for internal IP addresses is 10.0.0.16.

See Also

Wikipedia has everything you want to know about IP addresses.

Related Answered Questions

Question: 2.12

Verified Answer:

Use CUPS (Common Unix Printing System). Start by e...
Question: 2.5

Verified Answer:

Setting up a wireless connection is very easy if y...
Question: 2.8

Verified Answer:

Install a VNC (Virtual Network Connection) server....
Question: 2.7

Verified Answer:

The easiest way to set up SSH on the Raspberry Pi ...