Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My PC won't connect to my Pi using a network cable
#1
As I am resetting a lot of my equipment, this old issue cropped up again for me. It happens every so often for some, not all, of my students too.
It's basically due to both your PC and Pi attempting to get an IP address from a DHCP server that doesn't exist in a direct connection, so neither can establish a proper network link.

There are 3 solutions to this:

1st If you can, buy a small network switch. When both machines are connected via a switch which has access to your network, they can find your network's DHCP server. This is my personally preferred method, especially when I have a few different machines I want to target - a switch avoids lots of messy unplugging/plugging.

2nd Connect both your PC and Pi via ethernet to your network router. That way both machines get IPs from your router's DHCP server.

3rd A little less elegant but effective: set both devices to static IPs on their own private network. This is fiddly because you need to type commands into the Pi's terminal, but it works well.
On the Pi, carefully enter these two commands:

sudo nmcli con add type ethernet ifname eth0 con-name wired-static ipv4.addresses 192.168.2.1/24 ipv4.method manual autoconnect yes
sudo nmcli con up wired-static

This assigns 192.168.2.1 to your Pi. Now set your PC's ethernet to a static IP in the same range:

Win + X → Network Connections
Right-click Ethernet → Properties
Double-click Internet Protocol Version 4 (TCP/IPv4) (<<this might vary depending on your version of Windows, but basically set IPv4 to manual)
Select "Use the following IP address":

IP address: 192.168.2.2
Subnet mask: 255.255.255.0
Gateway: leave blank
DNS: leave blank


Click OK

Now your wired connection should work!
You can also enable WiFi on both devices for internet access - they'll route traffic appropriately. 
While you can use raspberrypi.local (or whatever your Pi's hostname is) to connect, using the IP address 192.168.2.1 directly is faster and guarantees you're using the wired connection.

Hopefully you won't have a problem - it's only a small number of setups that have this issue, but this solution should fix it.

Actually there is a 4th option, just make sure both systems are on the same WiFi network.. WiFi these days is impressively fast, but... wired is quite significanly faster and you will feel that difference if you are doing a lot of debugging or sending data back and forward.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)