3

I currently have a web server running on my pi, and I am trying to access it from my windows machine. At one point I had the pi physically connected to the same network as my computer was (wifi), but due to circumstances out of my control that is no longer an option. I am at University and have very few options with the network.

Does anyone have any suggestions how I can continue to run the server on my pi, and access it? Can I connect it directly to my PC? Any suggestions would be appreciated. Thanks!

blackandorangecat
  • 1,246
  • 5
  • 18
  • 37
  • define a WIFI hotspot on your PC and make the PI connect to it – AhmadWabbi Feb 28 '17 at 16:17
  • You can use a lan cable to access it. Connect you LAN cable to the Raspberry Pi and give a static IP to raspberry pi to connect to it. – Ayush Feb 28 '17 at 16:18
  • Wifi method is also good as suggested by @AhmadWabbi . You can hardcode the network id and password in your raspberry pi by editing the interfaces file. – Ayush Feb 28 '17 at 16:21
  • Is your Pi at home and your PC at University or something - your current situation is unclear to me at least. – Mark Setchell Feb 28 '17 at 16:36
  • @MarkSetchell They are both at university. My PC is connected to the network via wifi. The Pi WAS connect to the same network via ethernet cable. They can no longer talk to each other because of network changes, so I need to find a new way to connect them. I also need to keep my PC connected to the outside world. I think from the comments and answers by Ayush and others, I will try the jacking the pi directly into my PC and setting a static IP. Unless some sees a problem with this. – blackandorangecat Feb 28 '17 at 16:40
  • @Ayush See comment above. I tried to tag you in it as well, but was only allowed one tag. – blackandorangecat Feb 28 '17 at 16:41
  • @blackandorangecat You can configure you RPi to get connected to the network via Wifi. Then you can ssh to it from the network. – Ayush Feb 28 '17 at 16:45
  • @Ayush Connecting the pi to the wifi is another set of problems. The wifi uses WPA2-Enterprise security which does not really work with RPI. I have already pursued that idea, and was hoping for an alternative :) – blackandorangecat Feb 28 '17 at 16:48
  • @blackandorangecat You will have to find some other network to which you and RPi can connect simultaneously. – Ayush Feb 28 '17 at 16:58
  • Possible duplicate of [Hook up Raspberry Pi via ethernet to laptop without router?](http://stackoverflow.com/questions/16040128/hook-up-raspberry-pi-via-ethernet-to-laptop-without-router) – Ciro Santilli OurBigBook.com Apr 25 '17 at 07:10

3 Answers3

1

You should be able to static an IP on your PC and the Pi withing the same subnet and do it that way. Most network cards should be able to manage that without a crossover cable. IF you are using wifi on your PC there should be no issue with that as you can have a wired connection on the pi and wireless to the outside world.

1

Buy a domain name from http://namecheap.com and activate Dynamic DNS functionality in it and point its A record to your raspberry Pi's IP address (or your home router's address from which you can forward the request to your pi). Read more about Dynamic DNS here https://www.namecheap.com/support/knowledgebase/category.aspx/11/dynamic-dns.

With this method you can access your raspberry pi from anywhere across the world.

This is especially helpful if you do not have a static IP address.

Shakti Phartiyal
  • 6,156
  • 3
  • 25
  • 46
1

Accessing RPi Using LAN Cable :

Edit your boot/cmdline.txt file by plugging the memory card into the computer and then editing this file in the boot folder and add ip=192.168.0.200 this line to give it a static IP.

Change the IP of lan adapter in your computer to something like 192.168.0.10 (So that both are on the same network)

After this you can use this ip 192.168.0.200 to ssh to Raspberry Pi using Putty.

Using WiFi to connect to RPi

  1. SSH to RPi.
  2. Now follow the following steps :

Edit interfaces file

sudo nano /etc/network/interfaces

Make ‘auto io’ to ‘auto wlan0’. This command makes RPi automatically try to connect to wifi.

Add the following lines or edit if they do not exist:
allowhotplug
wlan0
iface wlan0 inet dhcp
wpaconf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Now edit the **wpa_supplicant** file.
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add the following lines:
network={

ssid="YOUR_NETWORK_NAME"

psk="YOUR_NETWORK_PASSWORD"

}

Restart the wlan0 interface
use command: sudo ifdown wlan0; sudo ifup wlan0;

After RPi is connected to the network you can use IP scanner to scan for the IP of RPi to ssh to it.

Ayush
  • 741
  • 9
  • 19
  • Thanks. This is what I ended up doing. https://pihw.wordpress.com/guides/direct-network-connection/in-a-nut-shell-direct-network-connection/ – blackandorangecat Feb 28 '17 at 22:59