1

I have a SoC device (e.g.: a Raspberry Pi), and a laptop. I would like to create a link over direct cable Ethernet using a "cross over" cable between my machine and the Pi, so I can connect to it with SSH.

The Raspberry Pi is headless and I don't have the option of plugging it in to a network, or plug in a keyboard to change configuration. So I cannot set up a manual IP on the Raspberry Pi, and I cannot get it to be given an IP by a router.

The Raspberry Pi by default is looking for a DHCP server on the Ethernet port. I think what I need is to set up a temporary DHCP server on that interface, some guidance would be useful, or is there another solution I haven't thought of?

  • Another solution would be to connect over a serial connection, you would have to get a serial TTL dongle and connect it to the UART0 pins (115200 bauds). – phk Jan 28 '17 at 19:12
  • But of course setting up a DHCP server might be easier, I a simple one is part of busybox (udhcpd). – phk Jan 28 '17 at 19:13
0

If no dhcp is present it will get an ip on the range 169.254.0.0/16. To get the actual IP address you can try arp -a on a cmd windows or use some network scanner tool to get all live host on that range (you and the pi itself).

Make sure to configure your network interface to get a dhcp ip and not an static one.

0

Any DHCP server will do. Just make sure that it's only listening on the interface with the Raspberry Pi. Your system administrator, and the other users on your local network, will be pissed off if you start messing with the DHCP setup on your local network.

You can use dnsmasq, which is available in most Linux distributions and is easy to set up. In /etc/dnsmasq.conf, put the following lines:

interface=eth0
dhcp-range=10.13.0.2,10.13.0.2

where eth0 is the name of your laptop's wired Ethernet interface (run /sbin/ifconfig -a to list all available interfaces). Replace 10.13.0.2 by a different IP address if this one is already in use on your local network. Restart dnsmasq and plug in the cable. After a few seconds, you should be able to connect to the Pi with ssh 10.13.0.2.

If you want to give the Pi internet access via your laptop, set up NAT. Assuming that your laptop gets internet access through the network interface wlan0:

echo 1 >/proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -i eth0 -o wlan0 -j MASQUERADE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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