How to connect to a Raspberry Pi without internet using an Ethernet cable and a DHCP server

The other week I was at a hackathon at work and brought my Raspberry Pi. Normally at home, I will plug the RPi into my router and get its IP address from my router's UI. I could not do this at work. After some Googling I learned that it is possible to SSH into a headless RPi without an available internet connection, using only a ethernet cable and a DHCP server. Simply plug an ethernet cable from your laptop to your RPi (you do not need a cross over ethernet cable as the RPi has the software to do it without one), and start a DHCP server on your laptop. It will then provide you with an IP address that you can SSH into. After I did this, I was able to configure the Wifi settings on the pi and get access to my companies network. This guide will work for any version of Raspberry Pi.

Downloads required

The DHCP Server for Windows. The download link is here.

Steps:

Plug the Ethernet cable into your RPi and laptop, and turn on the RPi.

Turn on the DHCP server according to the instructions below.

Watch the DHCP server in the Window's system tray carefully to find the IP address of your RPi, or obtain the IP from the web UI.

Configuring and enabling the DHCP Server for Windows

Unzip the zip file. You should see these contents:

matthew_moisen_dhcp_filelistThe dhcpwiz file is used to configure the DHCP server. After it is done configuring, it will save its settings to the dhcpsrv.ini file and then start the dhcpsrv application. In the future, you can turn on the DHCP server by just opening the dhcpsrv application, assuming you didn't erase the dhcpsrv.ini file.

Open the dhcpwiz application and click "Next". If your RPi is not connected to your laptop via the Ethernet cable, you should see this:

matthew_moisen_dhcp_config_1Note how the Local Area Connection's IP Address is 0.0.0.0 - this is because it is not being used.

Connect your RPi to your laptop and turn it on. Hit Refresh on the DHCP GUI until you see a change to this:

matthew_moisen_dhcp_config_2

Make sure that the IP Address starts with 169.254.. before proceeding. If it is anything else then you need to play around with the network settings for your Local Area Connection. Notably, make sure that it isn't using a static IP address/DNS server address.

Click on the Local Area Connection row, and click Next.

matthew_moisen_dhcp_config_4Click on HTTP (Web Server). This isn't necessary but it makes finding the IP address much more convenient. If you chose not to turn this on, then you have to watch the system tray for an alert that disappears very quickly

Just leave the default selections for all of the following screens, and continue to click Next until you get here:

matthew_moisen_dhcp_config_5Check "Overwrite existing file" and hit the "Write INI file" button. This creates the configuration file that the DHCP server will use.

and hit Next.

matthew_moisen_dhcp_config_3Check "Run DHCP server immediately" and click "Finish". This will then launch the dhcpsrv executable using the dhcpsrv.ini configuration that was just created.

matthew_moisen_dhcp_serverNow click on "Continue as tray app". This will minimize the DHCP server to your system tray.

matthew_moisen_dhcp_system_trayAt this point, you really have to pay attention and act quickly if you chose not to run the webserver.

From 1 second to 5 minutes from now, an alert will pop up over the system tray and will display an IP address; it will disappear in about 2 seconds. If nothing happens after 5 minutes, restart the RPi and the DHCP server.

matthew_moisen_dhcp_system_tray_alertYou will actually see two alerts. One will be the IP address of your laptop, and one will be the Raspberry Pi.

Normally, your laptop's IP is 169.254.0.1 and your RPi's IP is 169.254.0.2 - however, I've seen these switched, and I've also seen the RPi get *.03 - so you should try both.

However, hopefully you turned on the HTTP server. Go to http://localhost/dhcpstatus.xml and obtain the IP address directly.

matthew_moisen_dhcp_server_uiTake the IP address and Putty in, or remote desktop in:

matthew_moisen_dhcp_putty

Trouble Shooting

This can be finicky and rather frustrating. When I did this at work, my connection dropped after 5 minutes and I was unable to get the DHCP server to reserve an IP address to my RPi for another 10 minutes or so.

In fact, when I was making this post I restarted the RPi and the DHCP server so that I could take a picture of the system tray alert; however the alert never came.

In general, if this happens to you, restart the RPi and the DHCP server, and wait up to 5 minutes (I usually get frustrated and restart after 2 minutes, but I've seen it dish out an IP address at 5 minutes).

For this blog post, I restarted it 5 times over 15 minutes and didn't get anywhere. Sometimes it wouldn't even give my laptop an IP address, let alone the RPi. At one point I copied all of the files in the dhcpsrv2.5.1 folder into another directory and restarted again, and it immediately worked. I have no idea if this is just a coincidence, but you may want to try it if you cannot obtain the IP address after restarting the RPi and the DHCP server.


Comments

Add Comment

Name

Email

Comment

Are you human? * three = 3


Name: Dante

Creation Date: 2017-02-27

Yo, thank you, the time difference (waiting 5 minutes and then restarting) made it work for me. No one else even mentioned that. Thanks so much.


Name: D.A

Creation Date: 2018-07-24

Thank you I have been searched 3 weeks for solution