2

I am attempting to set up a headless raspberry Pi 3 unit that I can SSH into via a direct Ethernet connection to my main PC running Ubuntu. Unfortunately my Pi is unable to connect to the internet which renders it useless for what I am trying to set up (small scale testbench).

I had (at one point) managed to get it to access the internet via the built in wifi, however after a routine reboot the device failed to connect.

When I have the pi connected to a screen I can see that it is connected to the wifi and that it should be able to reach the internet. However pinging the router responds with "Destination Host Unreachable". Additionally, the Pi can ping my PC and my PC can ping the Pi. The Pi can also ping my mobile devices. For some reason the router's IP address is the only address that the Pi is unable to ping.

My setup details:

Ubuntu PC:

  • Running 14.04 LST
  • IP address (found using hostname -I) is 192.168.0.9

Raspberry Pi:

  • Running Raspbian Jessie
  • IP address (found using hostname -I) is 169.254.9.9 and 192.168.0.24
  • Using arp -a gives me 4 IP addresses. The router (192.168.0.1) at <"incomplete"> on eth0, my mobile device and my PC on wlan0, and the router again on wlan0.

Router:

  • IP address is 192.168.0.1
  • No other changes from default settings

I have the Raspberry Pi connected to my PC with a standard Ethernet cable. I also have the wifi enabled on the Raspberry Pi and have a wifi card installed in my PC.

6
  • 2
    First I would look at the hundreds of similar posts on this site. Then if you have problems you need to describe the configuration in detail.
    – Milliways
    May 9, 2016 at 4:08
  • Please describe details of Wifi setup you have made on the Pi and your Wireless network, without it no one can give you an exact solution. Also re-check when you connect to a screen, run iwconfig and see if Mode:Managed ? if not then your setup must be incorrect somewhere. May 9, 2016 at 8:12
  • 1
    What are you trying to do? It looks, from the question, like your Pi is not connected to the internet, and you report that it's not connected to the internet. Are you hoping to connected via WiFi to the internet? Using wired and WiFi at the same time can be problematic. If you plan to use your PC as a router so as to give the Pi a wired connection via the PC, that's something different again. Perhaps you could describe what you hope to achieve?
    – KDM
    May 9, 2016 at 20:42
  • I was trying to ssh from my PC into my PI via a direct Ethernet cable and then use my PC as a router to let the PI access my network. That didn't work so I activated the Wifi, not realizing that this would cause as many problems as it did. What I was hoping to find out from the question was why my PI was refusing to ping my router, but could ping everything else. Turns out it was still using the Ethernet connection to ping the router instead of using the Wifi. Unplugging the Ethernet cable fixed my problem. I'm probably going to stick to SSHing via Wifi for now.
    – K G
    May 10, 2016 at 3:40
  • You could try with a Wi-Fi dongle. Otherwise the Network card could be half broken.
    – kuzeyron
    Aug 15, 2017 at 13:34

3 Answers 3

1

You need to research and configure Network Address Translation on your Ubuntu PC. I'm not sure about the default firewall on Ubuntu, but I'm running iptables on Arch Linux, for example. If you're not running any firewall on your Ubuntu then the next things should be enough.

You will need to configure your Ubuntu PC as a gateway, e.g.

# ip route add 192.168.0.0/16 dev eth0

on your Ubuntu PC.

Enable IP forwarding:

# sysctl -w net.ipv4.ip.forward=1

Then, on your Raspi:

$ sudo ip route add default via 192.168.0.1 dev eth0

Look Here for more

0

Ethernet cables have a certain wiring that allows them to connect to switches/routers, but not directly to each other. Normally when connecting a machine to another directly through an ethernet cable, you need a Crossover Cable. This isn't true all of the time, as some devices have capabilities to detect this need and handle it internally. This is why you connect machines to a switch or router. It is also a major difference between a hub and a switch.

When you see that your IP is 169.254.9.9, you should notice that it's part of a special block starting with 169. This means that you've failed to get a real IP and should be treated as an error.

If you have a real need to connect the Raspberry Pi to your machine directly, you should look at purchasing a cheap switch. It will allow you to connect more and more devices. Even if you do purchase a switch, you're going to need to teach your main machine how to share the Internet with other machines on the switch. This will involve NAT, and setup of services such as dhcpd. You will have to research how to make your computer a gateway/router.

If you seriously need to directly connect your computer to your Raspberry Pi, you'll most likely need a crossover cable, and at least dhcpd running on the other machine.

0

After reviewing this information I realized that I am SSHing into my pi via Wifi, not via the direct Ethernet connection. Additionally the Pi is attempting to ping the router via the Ethernet connection, not via the wifi. Disconnecting the Ethernet cable allows the Pi to once again ping the router without problems. While this is not my ideal setup I now know how to go about re-enabling a direct SSH connection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.