For my project using Raspberry Pi I needed access to it without having a monitor but also enough to be able to change things – VNC is of course the answer! But I also want to be able to connect it directly to my laptop because I wouldn’t have a router or anything. Thankfully RPi supports Auto-MDIX so it’s possible to connect without a crossover cable, but the only issue is the RPi needs to know what it’s IP address is. I spent a while looking for how to do this, most things said just plugging the cable into the RPi and laptop would work but I still had absolutely no idea what the IP of the board was – so the easiest way to fix this is simply to remove the SD card from the board, place it into a computer and edit the cmdline.txt file, adding this to the end:
You can replace the IP with whatever you need, then simply plug into both and SSH into the RPi and you should be good.
Note: You should also create a second copy of the cmdline.txt file to not include this as this won’t work for any other connection (router).