Raspberry Pi Point to Point connection via Ethernet to Windows PC
I often find it necessary to configure my raspberry pis for access via VNC, SSH, and an ethernet connection. There are times when you cannot login over Wi-Fi because you may be at a location where your pi cannot get Wi-Fi signal, access to your network, or your network may not have the ports open that are necessary for your needs. In these cases, we can configure the raspberry pi to allow us VNC access via ethernet by doing the following:
On your raspberry pi, set a static IP with a different prefix from your main network
install dnsmasq & configure to assign IP to any PC connected to the raspberry pi via ethernet - this helps us avoid any need to configure a static IP on the PC we will be using to access the pi, as you may not have that permission on every PC
You will need to perform the following in your terminal:
sudo nano /etc/dhcpcd.conf
Next, you will need to edit the file, I did the following:
interface eth0
static ip_address=192.168.0.2
noipv6
static routers= (yes,blank!)
static domain_name_servers= (blank! Don't even put this there)
After, you can install what we will use to assign IP addresses to the client PCs using:
sudo apt install dnsmasq
At the conclusion of the operation, we will need to configure the file:
sudo nano /etc/dnsmasq.conf
You can edit your file by uncommenting the relevant lines, however, I find it much easier to copy and paste the following to the end of the file:
interface=eth0
bind-dynamic
domain-needed
bogus-priv
dhcp-range=192.168.0.100,192.168.0.200,255.255.255.0,12h
Replace all IPs with your required values. After completing the above, you should be able to VNC or SSH into your raspberry pi using its static IP address from any PC connected to it via ethernet. Hope this helps!