我无法使用qemu VM启用主机到客户机的通信。 目标是通过SSH从主机连接到访客虚拟机。
我有以下设置:
-netdev tap,ifname=tap0,id=mw,script=no,downscript=no -device virtio-net,netdev=mw,mac=52:54:01:34:AD:EF
虚拟机通过网桥br0相互连接,但不是物理接口eth0 。
问题/假设:我想要使它工作,我需要添加eth0到第一个和第二个桥梁创build一个静态路由通过
route add -host <any chosen internal IP, eg 192.168.1.2> dev tap0
在那里我有一个额外的内部IP到eth0通过第三次分配
ip addr add <any chosen internal IP on the same subnet as route, eg 192.168.1.3> dev eth0
?
如果是这样,我的问题是我被绑定到远程访问,因为一切发生在服务器上。 所以我不能通过brctl添加/删除接口,因为我然后失去了我的ssh连接到服务器!
因此,我试图把所有东西放到/etc/network/interfaces ,这里是我的代码:
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
现在,当我添加eth0到线bridge-ports eth0 tap0 tap1 tap2 tap3我无法通过SSH连接到服务器了。 在救援和检查日志文件后,我看不到任何错误或暗示为什么eth0与桥接口不工作!?
我的错在哪里? 提前感谢!
编辑:我也试过这个徒劳
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
任何想法的人?
如果桥接eth0,则需要在桥接器上设置IP地址,而不是在基础eth0接口上。