I am having trouble to enable a host-to-guest communication using qemu VMs. The goal is to connect via SSH from the host to the guest VM.
I have the following setting:
- host: local access to SSH server inside guest VMs required
- guest: qemu based VMs started using tap interface (parameters, 4 tap devices in total):
-netdev tap,ifname=tap0,id=mw,script=no,downscript=no -device virtio-net,netdev=mw,mac=52:54:01:34:AD:EF
VMs are interlinked via a bridge br0
, but not the physical interface eth0
.
Question/hypothesis:
I think to make it work, I need to add eth0
to the bridge first and second create a static route via
route add -host <any chosen internal IP, e.g. 192.168.1.2> dev tap0
where I have third assigned before an additional internal IP to eth0
via
ip addr add <any chosen internal IP on the same subnet as route, e.g. 192.168.1.3> dev eth0
?
If so, my problem is I am bound to remote access since everything happens on a server. So I cannot add/remove interfaces via brctl
since I then loose my ssh connection to the server!
Thus, I tried to put everything into /etc/network/interfaces
, here is my code:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
hostname 'actual hostname here'
address 'actual IP here'
netmask 'actual netmask here'
gateway 'actual gateway IP here'
auto br0
iface br0 inet manual
pre-up /sbin/tunctl -t tap0 -u 'actual user here' -g netdev
pre-up /sbin/tunctl -t tap1 -u 'actual user here' -g netdev
pre-up /sbin/tunctl -t tap2 -u 'actual user here' -g netdev
pre-up /sbin/tunctl -t tap3 -u 'actual user here' -g netdev
pre-up ip link set tap0 up
pre-up ip link set tap1 up
pre-up ip link set tap2 up
pre-up ip link set tap3 up
bridge-ports tap0 tap1 tap2 tap3
bridge-stp 0
bridge_maxwait 0
bridge_fd 0
post-down ip link set tap0 down
post-down /sbin/tunctl -d tap0
post-down ip link set tap1 down
post-down /sbin/tunctl -d tap1
post-down ip link set tap2 down
post-down /sbin/tunctl -d tap2
post-down ip link set tap3 down
post-down /sbin/tunctl -d tap3
Now, when I add eth0
to the line bridge-ports eth0 tap0 tap1 tap2 tap3
I cannot get a connection via ssh to the server anymore. After rescuing and checking the log file, I cannot see any error or hint why eth0
with the bridge interface did not work!?
Where is my fault? Thanks a lot in advance!
EDIT: I also tried this in vain
auto lo
iface lo inet loopback
iface eth0 inet manual
auto br0
iface br0 inet manual
pre-up /sbin/tunctl -t tap0 -u 'actual user here' -g netdev
pre-up /sbin/tunctl -t tap1 -u 'actual user here' -g netdev
pre-up /sbin/tunctl -t tap2 -u 'actual user here' -g netdev
pre-up /sbin/tunctl -t tap3 -u 'actual user here' -g netdev
pre-up ip link set eth0 up
pre-up ip link set tap0 up
pre-up ip link set tap1 up
pre-up ip link set tap2 up
pre-up ip link set tap3 up
hostname 'actual hostname here'
address 'actual IP here'
netmask 'actual netmask here'
gateway 'actual gateway IP here'
bridge-ports eth0 tap0 tap1 tap2 tap3
bridge-stp 0
bridge_maxwait 0
bridge_fd 0
post-down ip link set tap0 down
post-down /sbin/tunctl -d tap0
post-down ip link set tap1 down
post-down /sbin/tunctl -d tap1
post-down ip link set tap2 down
post-down /sbin/tunctl -d tap2
post-down ip link set tap3 down
post-down /sbin/tunctl -d tap3
Any idea anyone?