我是网络领域的新手。我有一台运行 Ubuntu 的服务器,它有 2 个网卡。eth0 是主网卡,现在我想将虚拟机设置为网络服务器,并使用第二个网卡将 80 流量仅传输到虚拟机。我认为这很简单,只需将电线插入第二个网卡,在路由器上将静态 IP 设置为该网卡的 MAC 地址,并在虚拟机中的客户虚拟机设置上将桥接连接设置为该新网卡即可。唉,简单似乎永远行不通……那么,我该如何设置呢?以下是几次调用的输出。我不知道为什么第二个网卡是“tun0”而不是 eth1,也不知道“tun0”是什么意思(隧道……?没有设置任何隧道)。任何帮助都非常感谢!
是否配置
eth0 Link encap:Ethernet HWaddr c0:4a:00:03:ce:07
inet addr:192.168.1.106 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::c24a:ff:fe03:ce07/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:127281 errors:0 dropped:0 overruns:0 frame:0
TX packets:113963 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:19873825 (19.8 MB) TX bytes:24075843 (24.0 MB)
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:65536 Metric:1
RX packets:155 errors:0 dropped:0 overruns:0 frame:0
TX packets:155 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:14960 (14.9 KB) TX bytes:14960 (14.9 KB)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.1 P-t-P:10.8.0.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
路线-n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
10.8.0.0 10.8.0.2 255.255.255.0 UG 0 0 0 tun0
10.8.0.2 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
/etc/网络/接口
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet dhcp