If you use your Raspberry Pi as a gaming console, media server, or stand-alone computer, WiFi is a great way to get internet access. But if you connect to your Pi with SSH or a remote desktop application a lot, WiFi is actually one of the slowest and least reliable ways to do it. A direct ethernet connection is much faster and a lot more stable. By connecting to your Pi directly from your laptop or desktop with an ethernet cable you are bypassing your local network, and you aren’t sharing bandwidth with other computers on your network. It also allows you to connect to your Pi when you’re outside of your home network. If you are experiencing slow connectivity and network time outs with your current set up, you need to try this! All you need to set it up is an ethernet cable and a way to access the Rapberry Pi command prompt.
What we’re going to do is assign a static IP address to the ethernet port of the Pi. This address will depend on the IP address of the ethernet adapter on the computer you will be connecting to the Pi from.
I will be using a clean installation of Raspbian Jessie Lite to demonstrate this, but the process also works for the full version of Raspbian Jessie. The set up for a static IP is a little different for older versions of Raspbian Wheezy, but once you know how to create the static IP address, it should be easy on any OS.
Find your Ethernet Adapter’s IP Address
First, we need to find out the IP address of the ethernet adapter on the computer you will be accessing the Pi from.
Access the “Network Connections” window by right clicking on the Windows icon in the task bar, or through the Control Panel. Then right click on the Ethernet connection and select “Properties”:
Scroll down the list and select “Internet Protocol Version 4 (TCP/IPv4)”, then click the “Properties” button:
If “Use the following IP address” is selected, take note of the IP address. In this case it’s 10.0.0.6, but your’s will probably be different:
If “Obtain an IP address automatically” is selected, we will need to find your autoconfiguration IPv4 address using
ipconfig in the Windows Command Prompt:
Find your Autoconfiguration IPv4 Address
Skip this step if you found the IP address of your ethernet adapter in the step above.
The autoconfiguration IPv4 address won’t be displayed unless something is connected to the ethernet adapter of your laptop/desktop computer, so plug your Pi into your computer with an ethernet cable, and power it up.
Now we will need to access the Windows command prompt. Either search for it in the Start menu, find it in the Control Panel, or right click on the Windows icon in the task bar:
Once you get to the command prompt, enter
Scroll down to see the configuration settings of your Ethernet adapter, which should say something like “Ethernet adapter Ethernet”:
Take note of the Autoconfiguration IPv4 Address, in my case it’s 169.254.81.78. This is the IP address of the ethernet adapter on my laptop.
Find your Default Gateway IP
The next step is to find out your default gateway IP. This is the local IP address of your network router. Computers on your network use it to communicate with the router and access the internet. If you already know what it is, just skip this step.
Power up and log into your Raspberry Pi via WiFi or ethernet, then enter
route -ne at the command prompt to see your network routing information:
Under the “Gateway” column, you can see your Default Gateway IP (10.0.0.1 in my case) for each interface (Iface) – ethernet (eth0) and WiFi (wlan0). Write down your default gateway IP, we will need it later.
Find Your Static Domain Name Servers
Now we need to find out the IP addresses of the domain name servers your Pi uses to find websites on the internet. Power up your Pi and log in to the command prompt, then enter
Copy these IP addresses to a text editor on your PC or write them down for later.
Configuring the Static IP
Now we’re ready to configure the network settings on the Pi and set up our static IP address. Enter
sudo nano /etc/dhcpcd.conf to edit the dhcpcd.conf file:
Now, add this code to the end of the dhcpcd.conf file, and change the IP addresses with your own:
interface eth0 static ip_address=169.254.81.99 static routers=10.0.0.1 static domain_name_servers=126.96.36.199 188.8.131.52 2001:558:feed::1 2001:558:feed::2
The three IP address are created as follows:
static ip_address– This will be the static IP address you use to SSH or remotely connect to your Pi. Take the IP address of your computer’s ethernet adapter (found in the steps above), and change the last number to any other number between 0 and 255.
static routers– This is the default gateway IP we found above.
static domain_name_servers– These are the IP’s we found in the resolv.conf file above. Separate each IP with a single space.
For example, I found out that the IP address of the ethernet adapter on my laptop is 169.254.81.78. To create the static IP address for my Pi, I replaced the 78 with 99 to get 169.254.81.99. This is the new static IP address I will use to log in to my Pi via SSH and remote desktop connection.
The dhcpcd.conf file should look like this after you have put in your own IP addresses:
Note: I have also configured a static IP for my WiFi (wlan0) connection in the image above. If you haven’t already done the same, just ignore those lines.
After you have added the code and replaced the IP addresses, press Ctrl-X and Y to exit and save the dhcpcd.conf file.
Now reboot the Pi, and plug an ethernet cable from the Pi directly to your laptop or desktop. Open PuTTY (or another SSH client) and log in with the static IP address you created above:
Now test to make sure that your Pi is able to access the internet by pinging Google. Enter
sudo ping www.google.com at the command prompt:
If the connection is successful, you’ll see that packets have been sent and received. If the connection is unsuccessful, you will get a “Network is unreachable” error:
Watch a video of the steps above here:
We’ve created a static IP address that you can use to connect your Raspberry Pi directly with your laptop or desktop computer. You will notice a big improvement in speed and stability compared to connecting with WiFi. You can leave your Pi connected as long as you want without getting disconnected or getting network time outs. Hope this helps! Feel free to leave a comment if you have any questions, and be sure to subscribe via email to get notified when we post new articles!
Sign Up & Get at Least Two $5 Coupons Now: https://jlcpcb.com/quote