Sunday, February 02, 2014

Raspberry Pi and peer to peer networking

 

Normally, when using the Pi and doing development work, I use it headlessly. It sits somewhere in the basement and I communicate with it using Remote Desktop. However, since I am testing NFC (Near Field Communications), I had a need to be close to the Pi when doing development work.

So I installed peer-to-peer networking. After the usual Google searches, I was able to piece together how to do it. This write up really is for my own reference so I will know how to do it at some future point in time. Note that I am doing this using a cable, not a wireless dongle. Apparently using a wireless dongle is possible as well, I just haven’t tried it.

First my setup: I work from a Windows 8.1 lap top and and when the Pi is setup in the basement, I wirelessly connect to it, via my router of course.

Be forwarned, unfortunately, there is no way to make the necessary changes on the Pi without hooking it up to a monitor of sorts, be it through HDMI, VGA.

So, to install peer-to-peer networking: Take an Ethernet cable of any length, I used a short six feet (2m) cable, and plug the ends into the PC and the Pi. Restart the PI. Don’t worry about this cable needing to be a cross over type: the Pi is auto sensing.

Next, in Windows, go to Start, run and type in ‘cmd’ (no quotes). In the command window that appears type ‘ipconfig’ (no quotes). In the listing that follows, look for a heading that says ‘Ethernet adapter Ethernet’. Within that section, look for Autoconfiguration IPv4 address and write down the address that follows this. Mine was 169.254.212.0. On the next line, you should see Subnet Mask, write this down well, mine was 255.255.0.0

On the Pi, type ‘sudo nano /etc/network/interfaces’ (no quotes) In the file that opens make sure that the following lines appear:

auto lo

iface lo inet loopback

auto eth0

iface eth0 inet static

address 169.254.212.1

netmask 255.255.0.0

Modify the address line with your own IP address that you found on your PC, but add 1 to the last number (look at my example). Furthermore, use exactly the same subnet mask on the Pi as on the PC. You can comment out any other lines that appear by putting a # hastag in front of it.

Save (Control-x, then press Y). Reboot the Pi and test.

I found Remote Desktop as well as my wireless to the router and Internet to be working as usual.

No comments:

Post a Comment