What if you want to connect your Raspberry Pi tailless but use a Windows OS on your laptop?
Well don’t despair, there are ways to do that and a few tricks that will allow you to do so under several circumstances.
So let’s recap what do we want to achieve. We want to connect a Raspberry Pi to a Windows computer, typically a laptop so that we can use the Keyboard, the Mouse and the Monitor of the laptop and replace its “engine” with a Raspberry Pi.
Old laptop or not this solution also makes for a great way to make your Pi a lot more portable. In this tailless configuration the only cable you might have is the power supply to your laptop!
Be weary that I have used a Windows 7 for the laptop and Raspbian Jessie for the RPi. Things may be slightly different using other versions.
This article should also serve as an Errata Corrige for my previous one with regards to the Pi’s support for Link-Local address. I will amend the previous post ASAP.
Requirements
Laptop
HW:
At least two USB ports
Ehernet adapter
WiFi card (optional)
SW:
A functioning Windows OS
VNC or RDP client
RPi
HW:
WiFi card
Ethernet card
SW:
VNC or RDP server (which regrettably needs to be installed upfront)
To glue them together we also need a USB Y cable and a 20-30cm Ethernet cable (Cat 5e or +) straight or crossover.
Networking
The first hurdle that we need to solve is how to try to make the laptop talk to the Pi at IP level. For that to happen the two must be connected at layer 1 and 2 of the OSI stack. The Ethernet cable plugged in your laptop’s NIC and in the Pi’s one does just that. It provides physical connectivity and data link. What we don’t get as easily is two IPs in the same subnet.
This can be achieved in many ways, let’s see a few.
Bonjour Windows
First things first though let’s talk about how to allow Windows to resolve the
That we are going to use to connect to the Pi independently from its IP address. Dealing with IP addresses is in fact quite a pain, that’s why DNS came about after all. In my previous article I mentioned the good that comes with mDNS so that you can reach raspberrypi.local independently to which IPv4 or IPv6 you are using on the Pi.
Once installed if you check the services running on your laptop you should see something like this:
Back to IP now. The first thing you should do it to disable any protocol and service that is not quite necessary from the Local Area Connection Property page of your laptop Ethernet’s card. This is what I did:
Using APIPA
Automatic Private IP Addressing is Microsoft’s interpretation of Link-Local address and it is a way of auto assigning IP addresses to hosts within a network segment without the need for a DHCP (service that is typically the job of your home router or NAS). A Class B of IP addresses has been reserved just for this purpose.
169.254.0.0/16 or 169.254.0.1 through to 169.254.255.254 with 169.254.0.0 being the subnet and 169.254.255.255 being the broadcast address. The network mask is 255.255.0.0.
Which in itself is quite a lot of technical gibberish but bare with me.
Now in the absence of a DHCP a Windows system (or any other OS supporting Link-Local address) will be configured as 169.254.x.y and this is the case for the Pi too with Raspbian Wheezy or Jessie.
I know I have said in my previous article that it didn’t but … it turns out it was grapevine knowledge which I would have been better off verifying first. I’ll amend the other article ASAP.
The following screenshots illustrate the status of the adapters and of some other aspects at the network level of both the laptop and the RPi.
Note that once the two hosts communicate with each other the IP of the RPi will be evident in the ARP cache of the laptop
Booting your Pi after plugging the network cable and power is enough for your laptop to resolve raspberrypi.local in an IP 169.254.x.y with no extra hurdles. At this point you could already connect to your Pi via VNC by configuring the service on the Pi as I explained in my previous post
About IPv6
Static IP addresses
If your laptop has an IP configured for its Ethernet adapter that you are not willing to alter then you can use the cmdline.txt to configure the Pi with an IP in the same subnet as you laptop. Easy!
More simply you could configure the eth0 of the Pi once it is booted if you have access to the GUI before making it tailless on your laptop. A good time to do this is when you install you VNC server
The following screenshots illustrate the status and configuration of the adapters and of some other aspects at the network level of both the laptop and the RPi.
DHCP via ICS
An easy enough solution to connect to your Pi is to leverage on the Internet Connection Sharing functionality of modern Operating Systems like Windows. ICS will let you share a connection on your laptop via another one. Your laptop may have a WiFi card connecting you to the Internet and an Ethernet adapter. ICS will allow you to share the WiFi via the Ethernet NIC, anything connected via an Ethernet cable to the laptop will receive an IP address and will be able to use the WiFi as a gateway to the Internet.
Now we could be interested in just that but I said that we wanted to use old laptops just as KVMs not also as Internet gateways, there is nothing wrong with that but accessing the Pi from elsewhere than the laptop with this configuration may be troublesome if not plain impossible.
What we are very much interested in is the fact the ICS transforms the Windows OS in a DHCP on the shared network adapter so that we can have our IP!
Once that’s done the local network adapter will receive an IP address in the range 192.168.137.0/24 which topically will be 192.168.137.1
Note that as the laptop provides an IP to the Pi, the Pi’s address can easily be found by looking at the ARP cache of the laptop
The Pi receives an IP like 192.168.137.x as did mine
All this good though comes at a price. The DNS resolution and the default route of the Pi are configured as if we wanted to use the laptop as our gateway. In order to use the Pi’s WiFi card instead we need to alter the file
Tip
You can change the subnet 192.168.137.0/24 to whichever you prefer by editing the registry
I only have an Ethernet card on my old laptop
In this case we need to trick the OS into believing that it has a connection to share. The best way to do this is to create for example a dialup connection as in here:
or add an additional WiFi card or other network interface via PCMCIA or a bluetoooth adapter but that would be quite inefficient and rather laborious. Unless there are some very specific needs I would just create the fake dial-up.
What else is there to say?
The ICS is certainly the most confusing and complicated but it can have its uses. If your “portable” lab becomes a bit overcrowded and you need a DHCP for some of the devices, then ICS could be your friend. Here is an example:
If your “portable” setup becomes a bit more complex and you have devices that need an IP delivered with a DHCP, ICS is your friend. In the picture above I have a tailless Pi connected to a switch to which are connected the laptop and a security camera. The camera can only do static IP or DHCP hence the need for ICS when on the move.
Also ICS inherently allows you to know the IP of its clients as by assigning them an IP that also generates an entry in the ICS’s ARP cache. By inspecting it we can immediately tell which IP have been assigned making connecting to them a lot more easy even in the absence of mDNS / Bonjour.