Connect Raspberry Pi to a PC without router or network

If you want to connect a Pi to a computer such as a laptop or a netbook without having to have a network then one method is to connect the laptop to the Pi using an Ethernet cable and then install Remote Desktop (xrdp) onto the Pi. You can also use this method if your Pi is connected into your network of course, but what I wanted was to be able to interact with my Pi even if I had no network. On your laptop you then just run Windows Remote Desktop and connect using the IP address of the Pi in the same way as you would when connecting to any other remote computer.

Install xrdp

On the Pi you first need to install xrdp which is very straight foreword.

#sudo apt-get install xrdp

Once installed go to your laptop and run Remote Desktop, enter the IP address or the server name of the Pi and it should connect.

You may want to modify your Pi so that it has a fixed IP address which you will need if you want to connect to the Pi away from a network.

Normally the Pi will get its IP address dynamically using DCHP.

On our Pi, when logged in, if we do:

#cat /etc/network/interfaces

The line:

iface eth0 inet dhcp

indicates that we are getting our IP address dynamically from the router.

Configuring the Static IP

We have to configure the network settings on the Pi and set up our static IP address. To do this, when we are logged into the Pi:

#sudo nano /etc/dhcpcd.conf

This is to edit the dhcpcd.conf file.

Now, add this code to the end of the /etc/dhcpcd.conf file, and change the IP addresses with your own:

interface eth0
static ip_address=169.254.141.255
static routers=10.0.0.1
static domain_name_servers=192.168.1.254

The above are examples of IP address for my system which will probably be different to yours.

The three IP address are created as follows:

static IP_addresss = 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, and change the last number to any other number between 0 and 255. To find this out, on your laptop open a command prompt and enter in ipconfig. This will display the IP configuration details for your laptop. Scroll down to see the configuration settings of your Ethernet adapter, which should say something like “Ethernet adapter Ethernet” and give an IP address. On mine it is 169.254.141.78 Change the last number to any other number between 0 and 255, so my static IP address is now 169.254.141.255

static routers = This is the default gateway IP we can find by logging into the Pi and using: #route -ne 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). It is this IP address which is the default gateway IP.

static domain_name_servers = Log in to the command prompt, then enter cat /etc/resolv.conf These are the IP addresses of the domain name servers your Pi uses to find websites on the internet. 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.141.78. To create the static IP_address for my Pi, I replaced the 78 with 255 to get 169.254.141.255. This is the new static IP address I will use to log in to my Pi via SSH and remote desktop connection.

After you have added the IP addresses, press Ctrl-X and Y to exit and save the /etc/dhcpcd.conf file.

Now you can connect to the Pi from your laptop directly through the wired Ethernet connector away from your network.