Closed xiekeyang closed 4 years ago
What happens if you try to ping the IP address behind www.google.com
from the guest ?
ping 172.217.3.164
You cand find the IP address by doing dig www.google.com
from the host.
@serban300
ping ip seems fail as well:
localhost:~# ping 172.217.3.164 -c 2
PING 172.217.3.164 (172.217.3.164): 56 data bytes
--- 172.217.3.164 ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss
Addition:
guest can connect to host server:
localhost:~# curl http://172.31.59.129:8080 -d "hello world"
Welcome to echo-server! Here's what I know.
......
hello world
172.31.59.129:8080
is an echo server on host.
@xiekeyang are you sure you are routing the traffic out of the tap device through the right host network interface ?
Can you provide the output of the ifconfig
command on the host ? And the commands that you used in order to route the traffic out of the tap device through the host network interface ?
@serban300 it really because I made mistake on setting iptables (error on host network interface). I fix it to:
iptables -t nat -A POSTROUTING -o $HOST_IFACE -j MASQUERADE
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i $TAP_DEV -o $HOST_IFACE -j ACCEPT
And now it works to ping internet ip address. Thanks so much.
But how to set the guest DNS server, as to reach internet domain (ping www.google.com
)?
host ifconfig info is:
$ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:ea:fe:16:f9 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001
inet 172.31.59.129 netmask 255.255.240.0 broadcast 172.31.63.255
inet6 fe80::426:beff:feb7:3d22 prefixlen 64 scopeid 0x20<link>
ether 06:26:be:b7:3d:22 txqueuelen 1000 (Ethernet)
RX packets 1056 bytes 100091 (100.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 783 bytes 130974 (130.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
fc-tap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.0.2 netmask 255.255.255.252 broadcast 0.0.0.0
ether 8e:2f:90:cb:d9:8a txqueuelen 1000 (Ethernet)
RX packets 183 bytes 21263 (21.2 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 242 bytes 22177 (22.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 132 bytes 10506 (10.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 132 bytes 10506 (10.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
guest DNS server seems unwork to follow enp4s0
, 172.31.59.1
I think you will have to set up the DNS servers yourself under /etc/resolv.conf
@serban300 It works now. Thanks so much for your help! 👍
@xiekeyang i can ping an ip , config /etc/resolv.conf still cant reach internet domain, meserver 8.8.8.8, How did you solve it
What I want:
I setup one micro vm on aws
i3.metal
, and ssh into the guest vm successfully.Then I want to connect to internet from guest vm, but it is failed.
Problem:
It is failed when ping google failed
information:
I refer similar issues like #696 and #988 on community, but guest internet is still unreachable. It is reachable by host.
The related env variables are that:
network setting:
Set host network according to On The Host
And set guest network according to In The Guest
The network request is:
check tap dev on host:
check ip forward:
check network interface on guest:
check ip route on guest:
I didn't set DNS server on guest (
/etc/resolv.conf
), which is blank. I've no idea on this, could anyone help to take a look? Thanks a lot!