Access Internet When Raspberry Pi Is Directly Connected to Computer Using Ethernet

When a Raspberry Pi™ hardware is directly connected to a computer using an Ethernet cable, perform these steps to access the Internet from the hardware.

  1. Connect the Raspberry Pi hardware to a wireless network.

  2. Open a Secure Shell (SSH) command-line session with the hardware using the IP address as 169.254.0.2. This is the static IP address assigned to the hardware during the Hardware Setup process for direct connection.

    r = raspberrypi(‘169.254.0.2’,’pi’,’raspberry’); 
    openShell(r);
    

    Here, raspberry and pi are the default user name and password of the Raspberry Pi hardware.

  3. From the routing table, delete the default route, 0.0.0.0. The hardware uses this route to access external hosts.

    sudo ip route del 0.0.0.0/0
    
  4. Check if the hardware is now connected to the Internet by executing the ping command on the Google® DNS IP address, 8.8.8.8. A successful response indicates that the hardware is connected to the Internet.

    ping 8.8.8.8

See Also