2

I'm using ssh to connect to the Pi from my MS Windows PC, and I'm using a wired connection to do so. Now the problem is even though my Pi is connected to wifi (which provides internet access), it doesn't seem to be able to connect to the internet. I'm trying to download the sudo apt-get install xrdp to get GUI. However it gives out error "destination host unreachable" as can be seen on the Error message. I tried to ping the Pi from my computer's cmd and it works. So I tried to ping google.com from the pi, but it also gives destination host unreachable error. My Pi is indeed connected to the internet as when I run iwconfig it shows my router's ESSID. Anyone knows how to fix this?

I'm using ssh to connect to the Pi, and I'm using a wired connection to do so. Now the problem is even though my Pi is connected to wifi (which provides internet access)

Error message:

pi@raspberrypi:~ $ sudo apt-get install xrdp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libglu1-mesa ssl-cert x11-apps x11-session-utils xbitmaps xfonts-75dpi
xfonts-base xfonts-scalable xorg xorg-docs-core xorgxrdp
Suggested packages:
openssl-blacklist mesa-utils xorg-docs x11-xfs-utils guacamole
xrdp-pulseaudio-installer
The following NEW packages will be installed:
libglu1-mesa ssl-cert x11-apps x11-session-utils xbitmaps xfonts-75dpi
xfonts-base xfonts-scalable xorg xorg-docs-core xorgxrdp xrdp
0 upgraded, 12 newly installed, 0 to remove and 119 not upgraded.
Need to get 11.0 MB of archives.
After this operation, 17.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Err:1 http://raspbian.raspberrypi.org/raspbian buster/main armhf libglu1- 
mesa armhf 9.0.0-2.1
Cannot initiate the connection to raspbian.raspberrypi.org:80 
(2a00:1098:0:80:1000:75:0:3). - connect (101: Network is unreachable) Could 
not connect to raspbian.raspberrypi.org:80 (93.93.128.193). - connect (113: 
No route 
to host)
Err:2 http://raspbian.raspberrypi.org/raspbian buster/main armhf ssl-cert 
all 
1.0.39

Ping my Pi from computer's cmd:

C:\Users\Hp>ping 192.168.1.2

Pinging 192.168.1.2 with 32 bytes of data:
Reply from 192.168.1.2: bytes=32 time=1ms TTL=64
Reply from 192.168.1.2: bytes=32 time<1ms TTL=64
Reply from 192.168.1.2: bytes=32 time<1ms TTL=64
Reply from 192.168.1.2: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.1.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms

Ping Google:

pi@raspberrypi:~ $ ping google.com
PING google.com (172.217.168.206) 56(84) bytes of data.
From 192.168.1.2 (192.168.1.2) icmp_seq=1 Destination Host Unreachable
From 192.168.1.2 (192.168.1.2) icmp_seq=2 Destination Host Unreachable
From 192.168.1.2 (192.168.1.2) icmp_seq=3 Destination Host Unreachable
From 192.168.1.2 (192.168.1.2) icmp_seq=4 Destination Host Unreachable
From 192.168.1.2 (192.168.1.2) icmp_seq=5 Destination Host Unreachable
From 192.168.1.2 (192.168.1.2) icmp_seq=6 Destination Host Unreachable
^C
--- google.com ping statistics ---
7 packets transmitted, 0 received, +6 errors, 100% packet loss, time 215ms
pipe 4

EDIT: sudo route -n gives me the following:

pi@raspberrypi:~ $ sudo route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     202    0        0 eth0
0.0.0.0         172.20.10.1     0.0.0.0         UG    303    0        0 wlan0
172.20.10.0     0.0.0.0         255.255.255.240 U     303    0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     202    0        0 eth0

ifconfig wlan0 gives me:

pi@raspberrypi:~ $ ifconfig wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 172.20.10.10  netmask 255.255.255.240  broadcast 172.20.10.15
    inet6 fe80::9768:9bb9:4b4:143f  prefixlen 64  scopeid 0x20<link>
    ether b8:27:eb:01:00:35  txqueuelen 1000  (Ethernet)
    RX packets 398  bytes 45561 (44.4 KiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 141  bytes 17153 (16.7 KiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

and ip addr gives me:

pi@raspberrypi:~ $ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:54:55:60 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 brd 192.168.1.255 scope global noprefixroute eth0
   valid_lft forever preferred_lft forever
inet6 fe80::3ae0:826b:38ae:2d42/64 scope link
   valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:01:00:35 brd ff:ff:ff:ff:ff:ff
inet 172.20.10.10/28 brd 172.20.10.15 scope global noprefixroute wlan0
   valid_lft forever preferred_lft forever
inet6 fe80::9768:9bb9:4b4:143f/64 scope link
   valid_lft forever preferred_lft forever
15
  • what's on sudo route -n?
    – abolotnov
    Oct 11, 2019 at 17:39
  • @abolotnov Destination 192.168.1.0 Gateway 0.0.0.0 Genmask 255.255.255.0
    – aldo
    Oct 11, 2019 at 17:49
  • just this one line?
    – abolotnov
    Oct 11, 2019 at 17:50
  • ifconfig wlan0?
    – abolotnov
    Oct 11, 2019 at 17:58
  • Please don't post pictures of text. Instead paste the text output direct into the question. Please do so with the output of this commands: ip addr and ip route. You can edit your question. What operating system do you use?
    – Ingo
    Oct 11, 2019 at 18:00

1 Answer 1

4

The problem is that you have two interfaces eth0 and wlan0. Internet access is only through wlan0 but the default route is set to eth0 as shown by this line from the routing table:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     202    0        0 eth0

I have asked for the operating system you are using on the Raspberry Pi but you haven't answered it. I don't know how do you setup your networking but maybe you have to correct settings in /etc/dhcpcd.conf (if using Raspbian). Anyway, it should do immediately if you correct the default route with these commands:

rpi ~$ sudo ip route del default
rpi ~$ sudo ip route add default via 172.20.10.1 dev wlan0 proto static src 172.20.10.10 metric 202

But this isn't persistent and will be lost on reboot. As already said you should reconfigure your network setup.

0

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.