19

I have Model B and connected via Ethernet and running Raspbmc.

It's taking new IP address whenever I restart it, of course may be because of DHCP, but I want to configure this Raspberry Pi with a static IP address, so that I can use my XBMC remote.

1

3 Answers 3

23

Per the instructions found here:

  1. In XBMC, go to Programs → Raspbmc settings → Wired network configuration.
  2. Uncheck the Automatic DHCP option.
  3. Provide a static IP address. Make sure the IP address is far away from the IP addresses typically assigned by the router to the networked devices at home. For example, if a router assigns addresses starting from 192.168.0.10, then pick a static IP like 192.168.0.50
  4. Scroll down and check the Update Now option. Raspbmc will take a few seconds to apply the new configuration.
  5. Make sure you can ping the static IP address you assigned. Voila, your Raspbmc now has a fixed IP address!
0
14

A solution would be to configure a DHCP static lease, if your router allows it. I like this solution because:

  • I can set all of my connected devices' IP address and DNS configuration in a unique place.
  • The Raspberry Pi won't get a taken IP address
  • I can bring my Raspberry Pi to a friend's place without reconfigure it
  • I can have multiple OS on the Raspberry Pi without configure them
  • I can reinstall the OS without reconfigure it

To configure a DHCP static lease:

  1. In a terminal on the Raspi, run the ifconfig command to know its MAC address (HWaddr XX:XX:XX:XX:XX:XX).
  2. Open your favorite browser and enter your router's IP address. Probably 192.168.0.1 or 192.168.1.1.
  3. Look for the DHCP static lease option. In the example here, the "DCHP Reservation" button.
  4. Enter the MAC address you picked up in the first step and associate it with the IP address you want to. Click here to see an example of the web interface.
  5. Restart the RPi to make it get the IP address you just set up.
3
  • 3
    This also has the nice side that the DHCP server shouldn't hand that IP to someone else by accident.
    – XTL
    Commented Oct 19, 2012 at 9:08
  • 2
    Also, if you taker your Raspberry Pi to a friends place, it can pick up an IP appropriate to that network rather than try to use your home IP address which may not work, and may even stop another device on the network from working.
    – Mark Booth
    Commented Oct 19, 2012 at 12:49
  • 1
    Another benefit: If you have multiple OS on the device, you don't have to set the IP address on each system. Commented Jan 7, 2013 at 23:23
2

For those of you (like me) who prefer to do things the manual way, then you can edit the interface file at /etc/network/interfaces:

# DHCP
# ~~~~
# iface eth0 inet dhcp

# Static
# ~~~~~~
iface eth0 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx

You will then need to restart the network service...

2
  • 1
    This works on Debian... I'm assuming the process is the same (or similar) on RaspbMC
    – Andrew
    Commented Oct 19, 2012 at 12:11
  • 2
    This is why I updated the question, for I would advise this answer on any other distribution. Commented Oct 19, 2012 at 12:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.