May 28

Configure the LAN Network on your Raspberry PI

So you’ve powered on your PI and booted from the SD card. If you do not have any internet/network connectivity this may help…

you can check your network devices are installed and have a driver configured by typing the IP command:

ip link show

This will show all network interfaces currently connected to your PI. LO is the local host for internal IP traffic. eth0 is the on board RJ45 connector. wlan0 (if connected) is the USB wireless dongle. Your output should be similar to this:

root@raspberrypi:/# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN mode DEFAULT
 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 1000
 link/ether b8:47:eb:33:24:53 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DORMANT qlen 1000
 link/ether 80:1f:49:ff:38 brd ff:ff:ff:ff:ff:ff
root@raspberrypi:/#

As long as eth0 appears on the list your on board network adapter is ready to be configured:

  1.  log into your Raspberry PI using the root account.
  2. At the prompt type:
cd /etc/network

then to edit your network interfaces type:

nano interfaces

check your network interface is configured correctly:

If you are using DHCP from your router: (The address is issued by your router- normally the default)

auto lo

iface lo inet loopback

iface eth0 inet dhcp

If you are going to fix the IP address you need something like:

auto eth0
    iface eth0 inet static
        address 192.168.0.2
        netmask 255.255.255.0
        gateway 192.168.0.254

You will need to modify the above IP addresses to match your current router configuration.

When you have finished configuring your interface you can exit out of “nano” (the text editor) by pressing CTRL+X  It will prompt to save changes.

Much more detail can be found on: http://wiki.debian.org/NetworkConfiguration

To restart the interface you type:

sudo /etc/init.d/networking restart

you can individually bring down interfaces using

ifdown eth0

and re-instate them with

ifup eth0

Once your network interface is up and running you can test it by issuing a ping command to your router:

ping 192.168.0.1

And to check you can get out to the internet a ping to a popular site:

ping www.google.com