我正在 QEMU 下运行 SunOS 4.1.4(那些日子......),通过tap
主机上的设备联网。我像这样启动虚拟机......
qemu-system-sparc \
-rtc base=utc \
-drive file=sunos-root.img,format=raw,bus=0,unit=0 \
-drive file=sunos-home.img,format=raw,bus=0,unit=1 \
-drive file=sunos-gnu.img,format=raw,bus=0,unit=2 \
-nic tap,br=virbr0,helper=/usr/libexec/qemu-bridge-helper \
-nographic
...一切都运行良好,除了网络,它似乎只是偶尔工作。
当 SunOS 启动时,它除其他外,还通过 .telnet 服务器和 rshell 服务器运行inetd
。 Tap 接口连接到桥virbr0
( 192.1681.22.1
),并分配 SunOS 虚拟机192.168.122.103
:
bash-3.2# ifconfig le0
le0: flags=63<UP,BROADCAST,NOTRAILERS,RUNNING>
inet 192.168.122.103 netmask ffffff00 broadcast 192.168.122.255
ether 52:54:0:12:34:56
如果我幸运的话,我可以简单地 从主机那里telnet 192.168.122.103
(或),它就可以工作了。rsh
其他时候则不然,我也不明白为什么。如果我循环运行这个......
while ! rsh -l root 192.168.122.103 /bin/true; do
sleep 1
done
...它会最终工作。
出站流量从虚拟机始终工作(例如,我可以可靠地从我的主机telnet 192.168.122.1 22
获取SSH-2.0-OpenSSH...
横幅)。tcpdump
当无法 telnet 到虚拟机时在 Tap 界面上运行,我看到:
18:39:07.584861 IP 192.168.122.1.40270 > 192.168.122.103.telnet: Flags [S], seq 2038492576, win 64240, options [mss 1460,sackOK,TS val 2376785260 ecr 0,nop,wscale 7], length 0
18:39:07.585177 IP 192.168.122.103.telnet > 192.168.122.1.40270: Flags [S.], seq 2034944001, ack 2038492577, win 4096, options [mss 1460], length 0
18:39:07.585205 IP 192.168.122.1.40270 > 192.168.122.103.telnet: Flags [.], ack 1, win 64240, length 0
18:39:07.585279 IP 192.168.122.1.40270 > 192.168.122.103.telnet: Flags [P.], seq 1:28, ack 1, win 64240, length 27 [telnet DO SUPPRESS GO AHEAD, WILL TERMINAL TYPE, WILL NAWS, WILL TSPEED, W
ILL LFLOW, WILL LINEMODE, WILL NEW-ENVIRON, DO STATUS, WILL XDISPLOC [|telnet]
18:39:07.773325 IP 192.168.122.103.telnet > 192.168.122.1.40270: Flags [.], ack 28, win 4069, length 0
18:39:10.323018 IP 192.168.122.1.40270 > 192.168.122.103.telnet: Flags [P.], seq 28:30, ack 1, win 64240, length 2
18:39:10.373287 IP 192.168.122.103.telnet > 192.168.122.1.40270: Flags [.], ack 30, win 4067, length 0
18:39:11.401927 IP 192.168.122.1.40270 > 192.168.122.103.telnet: Flags [P.], seq 30:32, ack 1, win 64240, length 2
18:39:11.573256 IP 192.168.122.103.telnet > 192.168.122.1.40270: Flags [.], ack 32, win 4065, length 0
18:39:12.672424 IP 192.168.122.1.40270 > 192.168.122.103.telnet: Flags [P.], seq 32:34, ack 1, win 64240, length 2
18:39:12.773266 IP 192.168.122.103.telnet > 192.168.122.1.40270: Flags [.], ack 34, win 4063, length 0
所以你可以看到,似乎有流量来回传递,但仍然不起作用。这就是事情成功时的样子:
18:41:38.435167 IP 192.168.122.1.40282 > 192.168.122.103.telnet: Flags [S], seq 404147648, win 64240, options [mss 1460,sackOK,TS val 2376936111 ecr 0,nop,wscale 7], length 0
18:41:38.435489 IP 192.168.122.103.telnet > 192.168.122.1.40282: Flags [S.], seq 2054336001, ack 404147649, win 4096, options [mss 1460], length 0
18:41:38.435525 IP 192.168.122.1.40282 > 192.168.122.103.telnet: Flags [.], ack 1, win 64240, length 0
18:41:38.435585 IP 192.168.122.1.40282 > 192.168.122.103.telnet: Flags [P.], seq 1:28, ack 1, win 64240, length 27 [telnet DO SUPPRESS GO AHEAD, WILL TERMINAL TYPE, WILL NAWS, WILL TSPEED, W
ILL LFLOW, WILL LINEMODE, WILL NEW-ENVIRON, DO STATUS, WILL XDISPLOC [|telnet]
18:41:38.459878 IP 192.168.122.103.telnet > 192.168.122.1.40282: Flags [P.], seq 1:4, ack 28, win 4069, length 3 [telnet DO TERMINAL TYPE [|telnet]
18:41:38.459971 IP 192.168.122.1.40282 > 192.168.122.103.telnet: Flags [.], ack 4, win 64237, length 0
18:41:38.460564 IP 192.168.122.103.telnet > 192.168.122.1.40282: Flags [P.], seq 4:34, ack 28, win 4096, length 30 [telnet WILL SUPPRESS GO AHEAD, DONT NAWS, DONT TSPEED, DONT LFLOW, DONT LI
NEMODE, DONT NEW-ENVIRON, WONT STATUS, DONT XDISPLOC, SB TERMINAL TYPE SEND SE [|telnet]
可以看到,这次Telnet协议交换成功完成。
这不是防火墙问题(我-j ACCEPT
在链的顶部添加了一条规则INPUT
,没有限制OUTPUT
,并且此流量不会到达FORWARD
链)。
也许 QEMU lance 以太网驱动程序只是有问题?