Under an Ubuntu 18.04 host, I have set-up an Ubuntu 10.04 guest VM from a cloned HD. The VM fires up fine, I can ssh into it from the host, but it fails to communicate outside of the host.
My question is what is wrong with my configuration below:
Guest VM:
Started with qemu-system-x86_64 G.qcow2 -m 4096 -smp 4 -no-acpi -enable-kvm -name system76 -vga std -device virtio-net,netdev=net0 -netdev tap,id=net0,ifname=tap0,script=no,downscript=no,br=br0vm
Manual network configuration with the GUI / network manager. Static IP 192.168.118.18, mask 255.255.255.0, gw 192.168.118.1, dns 192.168.118.1 (I assumed the tactic I use with my router would work here too, though that may be a mistake).
Somehow ifconfig reports interfaces I did not think were configured. I thought that with the qemu line above we defined net0, but, below, we see eth1 and virbr0!
# ifconfig
eth1 Link encap:Ethernet HWaddr 52:54:00:12:34:56
inet addr:192.168.118.18 Bcast:192.168.118.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1203 errors:0 dropped:0 overruns:0 frame:0
TX packets:1606 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:114773 (114.7 KB) TX bytes:290952 (290.9 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:313 errors:0 dropped:0 overruns:0 frame:0
TX packets:313 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:45604 (45.6 KB) TX bytes:45604 (45.6 KB)
virbr0 Link encap:Ethernet HWaddr 1e:8f:5c:98:b1:25
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
inet6 addr: fe80::1c8f:5cff:fe98:b125/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:84 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:13004 (13.0 KB)
Host configuration:
apt install uml-utilities
apt install bridge-utils
vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
sysctl -p
ip link add name br0vm type bridge
ip addr add 192.168.118.1/24 dev br0vm
ip link set br0vm up
tunctl -t tap0 -u asoundmove
ip link set tap0 up
brctl addif br0vm tap0
mkdir /etc/qemu
vi /etc/qemu/bridge.conf
allow br0vm
# test access to the guest - it works
ssh [email protected]
iptables -t nat -A POSTROUTING -o br0vm -j MASQUERADE
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -o eno1 -i br0vm -j ACCEPT
Trying things out:
I can ping the host from the guest:
ping 192.168.118.1
PING 192.168.118.1 (192.168.118.1) 56(84) bytes of data.
64 bytes from 192.168.118.1: icmp_seq=1 ttl=64 time=0.152 ms
64 bytes from 192.168.118.1: icmp_seq=2 ttl=64 time=0.145 ms
I cannot ping the switch/router to which the host is connected from the guest, the following ping returns nothing:
ping 192.168.117.1
Both ping requests (117.1 & 118.1) show in tcpdump on the guest eth1 and host br0vm, below the tcpdump for the ping 192.168.117.1 requests on the guest.
tcpdump -i br0vm not port ssh
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on br0vm, link-type EN10MB (Ethernet), capture size 262144 bytes
11:57:34.211291 IP 192.168.118.18 > routerlogin.net: ICMP echo request, id 55320, seq 1, length 64
11:57:35.216163 IP 192.168.118.18 > routerlogin.net: ICMP echo request, id 55320, seq 2, length 64
11:57:36.215940 IP 192.168.118.18 > routerlogin.net: ICMP echo request, id 55320, seq 3, length 64
11:57:37.215919 IP 192.168.118.18 > routerlogin.net: ICMP echo request, id 55320, seq 4, length 64
11:57:39.205837 ARP, Request who-has host.hostname tell 192.168.118.18, length 28
11:57:39.205859 ARP, Reply host.hostname is-at 4e:31:b7:14:1b:a9 (oui Unknown), length 28
watch -d -n 1 iptables -nvL
Chain INPUT (policy ACCEPT 2604K packets, 21G bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
50 4200 ACCEPT all -- br0vm eno1 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 1974K packets, 43G bytes)
pkts bytes target prot opt in out source destination
The 50 4200 counters increment with every ping request
watch -d -n 1 iptables -nvL -t nat
Chain PREROUTING (policy ACCEPT 4283 packets, 510K bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 4175 packets, 503K bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 9155 packets, 663K bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 9227 packets, 666K bytes)
pkts bytes target prot opt in out source destination
25 3789 MASQUERADE all -- * br0vm 0.0.0.0/0 0.0.0.0/0
However the 25 3789 counters do no increase with every ping request.
From the host, this works:
ping 192.168.117.1
PING 192.168.117.1 (192.168.117.1) 56(84) bytes of data.
64 bytes from 192.168.117.1: icmp_seq=1 ttl=64 time=0.609 ms
64 bytes from 192.168.117.1: icmp_seq=2 ttl=64 time=0.585 ms
What am I doing wrong that the IP traffic on the 118 subnet does not get forwarded to the 117 subnet?
EDIT:
Additional information:
ip -br link
lo UNKNOWN 00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
eno1 UP 30:9c:23:9b:eb:df <BROADCAST,MULTICAST,UP,LOWER_UP>
br0vm UP 4e:31:b7:14:1b:a9 <BROADCAST,MULTICAST,UP,LOWER_UP>
tap0 UP 4e:31:b7:14:1b:a9 <BROADCAST,MULTICAST,UP,LOWER_UP>
ip -br address
lo UNKNOWN 127.0.0.1/8 ::1/128
eno1 UP 192.168.117.110/24 fe80::8fae:b4f2:8b90:7601/64
br0vm UP 192.168.118.1/24 fe80::a46d:86ff:fe2a:ddbf/64
tap0 UP fe80::4c31:b7ff:fe14:1ba9/64
ip route
default via 192.168.117.1 dev eno1 proto static metric 100
169.254.0.0/16 dev eno1 scope link metric 1000
192.168.117.0/24 dev eno1 proto kernel scope link src 192.168.117.110 metric 100
192.168.118.0/24 dev br0vm proto kernel scope link src 192.168.118.1
ip -br link; ip -br address; ip routeeno1is the only physical ethernet device on the host, I am using commands from various kvm/qemu related guides, I have no idea what modern command would be, nor how to find the equivalent to the old ones. I updated my question above with theipcommands you suggested.physdevbecause it auto activates bridge-nf)