6

I'm away from a network and unable to use my RPi. I've got a laptop with a SD card reader, would it be possible to mount the SD card in the laptop and configure the ethernet interface on the Pi with a static IP, then configure the laptop with another static address on the same subnet, then use an ethernet cable between the two so I can then continue to use the RPi via SSH? What file on the Pi do I need to edit?

tlhIngan
  • 3,372
  • 5
  • 19
  • 33
Dog Ears
  • 2,027
  • 6
  • 19
  • 28
  • What host and RPi OSs are you using? – Alex Chamberlain Jul 06 '12 at 21:01
  • @Alex Chamberlain I've got a few laptops including windows 7 and Mac I OS, my Pi is running the standard Debian. Cheers. It looks straight forward other than the virtualization step :) – Dog Ears Jul 06 '12 at 21:15
  • You might be able to edit files on ext4 on Mac, but don't quote me on it. – Alex Chamberlain Jul 06 '12 at 21:22
  • Dog Ears, you should add that extra information Alex asked for to your question. – Anders Jul 08 '12 at 02:38
  • 1
    @Anders - Not including the distro has worked out well: all excellent answers! I'll accept your answers, although it's not relevant to me as I've not got a DHCP server, but hey, have some rep! – Dog Ears Jul 08 '12 at 08:43

3 Answers3

7

Debian Linux

You need to edit the file /etc/network/interfaces.

Change

iface eth0 inet dhcp

To

auto eth0
iface eth0 inet static
 address 192.168.1.90
 gateway 192.168.1.1
 netmask 255.255.255.0

Make sure whichever subnet you use, that it is different then the subnet used by your wireless card. If you are using Windows, you can install VirutalBox, and set up Linux in order to be able to edit the file, since Windows can't read the ext4 partition on the SD card. You should then be able to connect to you Raspberry Pi by connecting an ethernet cable directly between the laptop and the Pi. This is how I have mine set up.

Also, if you are using Windows, you can set up Internet Connection Sharing. This will allow you to access the internet from your Raspberry Pi.

Alex Chamberlain
  • 15,530
  • 14
  • 67
  • 113
Kibbee
  • 1,102
  • 3
  • 11
  • 15
6

Arch Linux

You need to edit /etc/rc.conf. Using the example from the Arch Linux Beginners' Guide, a static IP setup would look similar to

HOSTNAME="arch"
interface=eth0
address=192.168.1.100
netmask=255.255.255.0
broadcast=192.168.1.255
gateway=192.168.1.1

You should also edit /etc/resolv.conf. You can probably use nameserver 192.168.1.1, or if that doesn't work you could use Google's Public DNS, nameserver 8.8.8.8.

Alex Chamberlain
  • 15,530
  • 14
  • 67
  • 113
5

Avahi

Yes, if you have a Linux distribution, you can easily mount the SD and change the contents on the SD file system.

As Kibbee wrote, you need to change the content in /etc/network/interfaces on the SD-card if you want static IPv4 addresses. You also need to change the contents in /etc/resolv.conf on the SD-card as Alex wrote. As that is also information you get through dynamic addresses.

But a better solution would be to install Avahi on your raspberry instead of setting a static address if you plan to move the Raspberry Pi between networks. Then the Raspberry will tell Apple computers and other Linux boxes with avahi installed what IP address your Raspberry Pi got. So you can connect without knowing the IP address.

sudo aptitude install avahi-discover avahi-utils avahi-autoipd

and then you can test this on the other computers

getent hosts raspberrypi.local
avahi-util -a

or try this

ssh pi@raspberrypi.local

to connect to your Raspberry Pi. You might want to check out /usr/share/doc/avahi-daemon/examples/ for some examples you can move into /etc/avahi/services/ to post more information from avahi. If you want to use IPv6, check out /etc/avahi/avahi-daemon.conf so that avahi works with IPv6 too.

Anders
  • 424
  • 2
  • 6