I have connected my rasberry pi running Ubuntu 20.04 using Ethernet to my Windows laptop. I have set static IP and subnet mask of Ethernet port on Windows laptop as follows:
I have enabled Internet sharing on Windows laptop:
I have set static IP on my raspberry pi too:
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.137.50 netmask 255.255.255.0 broadcast 192.168.137.255
ether 18:9b:a5:40:5d:59 txqueuelen 1000 (Ethernet)
RX packets 203 bytes 22521 (22.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 234 bytes 12036 (12.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I am able to ping Windows laptop from Raspberry pi:
# ping 192.168.137.1
PING 192.168.137.1 (192.168.137.1): 56 data bytes
64 bytes from 192.168.137.1: icmp_seq=0 ttl=128 time=2.061 ms
64 bytes from 192.168.137.1: icmp_seq=1 ttl=128 time=5.545 ms
64 bytes from 192.168.137.1: icmp_seq=2 ttl=128 time=1.805 ms
^C--- 192.168.137.1 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 1.805/3.137/5.545/1.706 ms
Also I am able to ping raspberry pi from Windows laptop:
>ping 192.168.137.50
Pinging 192.168.137.50 with 32 bytes of data:
Reply from 192.168.137.50: bytes=32 time=4ms TTL=64
Reply from 192.168.137.50: bytes=32 time=3ms TTL=64
Reply from 192.168.137.50: bytes=32 time=1ms TTL=64
Ping statistics for 192.168.137.50:
Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 4ms, Average = 2ms
I am able to ping google from windows laptop:
>ping google.com
Pinging google.com [172.217.166.46] with 32 bytes of data:
Reply from 172.217.166.46: bytes=32 time=31ms TTL=58
Reply from 172.217.166.46: bytes=32 time=14ms TTL=58
Reply from 172.217.166.46: bytes=32 time=20ms TTL=58
Ping statistics for 172.217.166.46:
Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 14ms, Maximum = 31ms, Average = 21ms
But I am unable to ping google from raspberry pi:
# ping google.com
PING google.com (172.217.166.46): 56 data bytes
^C92 bytes from 192.168.137.50: Destination Host Unreachable
--- google.com ping statistics ---
4 packets transmitted, 0 packets received, 100% packet loss
What I am missing here?
PS:
Below are outputs of some commands which might be useful:
# cat /etc/resolv.conf
# Generated by resolvconf
domain mshome.net
nameserver 127.0.0.1
# route -ne
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 eth0
0.0.0.0 192.168.137.1 0.0.0.0 UG 0 0 0 eth0
192.168.137.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.225.0 0.0.0.0 255.255.255.0 U 0 0 0 bridge0