4

I have a device that I need to connect to over SSH. The device is connected to my workstation via a direct ethernet connection. I'm attempting to assign the connected device an IP address somehow that I can SSH to, however all of the guides I'm finding have the user configure the IP from whatever device they're working with (namely Raspberry Pi's and so on). This is not something I can do with this device as I've no physical interface to work with.

I've been recommended to setup a DHCP server on my workstation so it would take care of this for me, however I've no idea how to configure it and none of the guides I have followed have been helpful. With that approach, I seem to have been able to bind an IP to the interface the device is connected on, however SSHing to that IP just brings me back to my own machine.

So my main question is: How do I assign an IP address to a device directly connected to my computer via ethernet cable without having any kind of access to the device (no interface, keyboard, monitor, etc). If the answer is to set up a DHCP server on my machine, how do I properly configure this and get an IP I can SSH to?

For reference, I am using Ubuntu 16.04 with OpenSSH installed. The device is also running some flavor of Linux and has SSH software installed, but again there's no way to interact with it except through SSH. I also do not have access to my router, so plugging the device in there and letting the router do the work is not an option.

2

The link given by @steve is appropriate, but if you want to try something simple first just to see what the device does you can use dnsmasq, which is a simple dns and dhcp server. Install with sudo apt-get install dnsmasq. If this also enables and starts the server you need to stop and disable it.

If, say, your device is on your ethernet interface eth2, and you have done sudo ifconfig eth2 192.168.9.1 to set the interface ip address, then you can try:

sudo dnsmasq -d -C /dev/null --port=0 --domain=localdomain --interface=eth2 --dhcp-range=192.168.9.2,192.168.9.10,99h

which sets up a dhcp server in debug mode (-d), not as a daemon, with dns (port=0) able to offer addresses in the range .2 to .10, and to hold the same ones for 99hours.

If your device broadcasts a request to discover an address you should see it, and the reply (offer):

dnsmasq-dhcp: DHCPDISCOVER(eth2) 94:71:ac:ff:85:9d 
dnsmasq-dhcp: DHCPOFFER(eth2) 192.168.9.2 94:71:ac:ff:85:9d 

The numbers are the ip address assigned and the device's mac address. You may need to reset or power on the device if it has given up broadcasting. The device might reply to ping 192.168.9.2 and then you can try to ssh too. You can interrupt the dnsmasq once the address has been offered in this test and put the options in the standard dnsmasq config file and so on.

You may also usefully run sudo tcpdump -i eth2 to see what packets pass.

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.