Difference between revisions of "Configuring a Static IP address on your Raspberry Pi"
|Line 1:||Line 1:|
Revision as of 14:17, 23 December 2012
Buying Guide - for advice on buying the Raspberry Pi.
SD Card Setup - for information on how to prepare the SD Card used to boot your Raspberry Pi.
Basic Setup - for help with buying / selecting other hardware and setting it up.
Beginners Guide - you are up and running, now what can you do?
Advanced Setup - for more extensive information on setting up.
Trouble Shooting - some things to check if things don't work as expected.
By default the Raspberry Pi uses DHCP to configure its network interfaces, including, on the model B, the built-in ethernet port. If you want to change this so the ethernet port has a static IP address, here's how.
DHCP for eth0 is enabled in the file /etc/network/interfaces. Here is what it looks like by default on a Raspberry Pi under the official version of Raspbian:
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
(Note: there is no actual wlan0 interface unless you attach a wireless USB network adapter. The entries that refer to wlan0 are there for when you do ;-) ).
Instead of the line:
iface eth0 inet dhcp
you need lines like this:
iface eth0 inet static address 192.168.1.1 netmask 255.255.255.0 gateway 192.168.1.254
The above example assigns the address 192.168.1.1 to eth0 with a subnet mask of 255.255.255.0, and sets the default gateway to 192.168.1.254.
Edit the file /etc/network/interfaces with the nano utility like this:
sudo nano /etc/network/interfaces
The second thing you need to do is check that you have a valid DNS server listed in /etc/resolv.conf. Edit this file using nano and add your DNS server if it is not already there. If you are using a broadband router, add the address of your router as the DNS server.