Network-Interface
來賓作業系統中的哪個網路介面或 IP 地址對應於主機作業系統中的哪個?
我聽說 KVM 中的客戶作業系統和主機作業系統可以通過在同一個專用網路中擁有網路介面或 IP 地址進行通信。我也聽說了
您可以在 ifconfig 的輸出中看到其在容器和 VM 網路中的 IP 地址和網路介面。
我在下面顯示
ifconfig
了來賓作業系統和主機作業系統的輸出。您能否告訴我來賓作業系統中的哪個網路介面或 IP 地址對應於主機作業系統中的哪個網路介面或 IP 地址,反之亦然?謝謝。在通過 VMM/KVM 的 Debian 客戶作業系統中,
user@debian:~$ /sbin/ifconfig ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAS> mtu 1500 inet 192.168.122.202 netmask 255.255.255.0 broadcast 192.168.122.255 inet6 fe80::5054:ff:fe99:5eee prefixlen 64 scopeid 0x20<link> ether 52:54:00:99:5e:ee txqueuelen 1000 (Ethernet) RX packets 5504 bytes 4872073 (4.6 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4199 bytes 559987 (546.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 20044 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 1 (Local Loopback) RX packets 488 bytes 39360 (38.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 488 bytes 39360 (38.4 KiB) TX errors 0 dropped 0 overruns 0 carries 0 collisions 0
在 Lubuntu 主機作業系統上:
$ 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:a6:79:a6:bc 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 enp0s25: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether txqueuelen 1000 (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 device interrupt 20 memory 0xfc400000-fc420000 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 3102389 bytes 174723039 (174.7 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3102389 bytes 174723039 (174.7 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:b1:aa:1f txqueuelen 1000 (Ethernet) RX packets 708 bytes 68468 (68.4 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 316 bytes 51806 (51.8 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 vnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet6 fe80::fc54:ff:fe99:5eee prefixlen 64 scopeid 0x20<link> ether fe:54:00:99:5e:ee txqueuelen 1000 (Ethernet) RX packets 257 bytes 28494 (28.4 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 23514 bytes 1240204 (1.2 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 wlx8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.97 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 prefixlen 64 scopeid 0x20<link> ether 80:1f:02:b5:c3:89 txqueuelen 1000 (Ethernet) RX packets 1269625 bytes 1045069752 (1.0 GB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 646600 bytes 101897054 (101.8 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
您的客人有一個非環回介面,
ens3
; 這是它用來與主機通信的介面。在主機上,匹配的介面是在同一個網路中的介面,就是virbr0
這裡。如果要列出屬於網橋的介面,請執行brctl show virbr0
在主機上。
您還可以將訪客中的路由與主機匹配:訪客的網關將是主機。要查看路線,請執行
ip route list
預設網關在“預設”行中給出,例如
default via 192.168.122.1 dev ens3 proto static metric 100