为了一个网络设置折腾,今天用虚拟机增加两个网卡对应PC主机上的两个网卡,开始进行虚拟机配置,
eth0 Link encap:Ethernet HWaddr 00:0c:29:db:f8:a0
inet addr:192.168.1.75 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fedb:f8a0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:63 errors:0 dropped:0 overruns:0 frame:0
TX packets:471 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4811 (4.8 KB) TX bytes:62529 (62.5 KB)
Interrupt:19 Base address:0x2024
eth1 Link encap:Ethernet HWaddr 00:0c:29:db:f8:aa
inet addr:192.168.14.185 Bcast:192.168.14.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fedb:f8aa/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2119 errors:0 dropped:0 overruns:0 frame:0
TX packets:582 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:215731 (215.7 KB) TX bytes:69193 (69.1 KB)
Interrupt:19 Base address:0x20a4
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:16436 Metric:1
RX packets:478 errors:0 dropped:0 overruns:0 frame:0
TX packets:478 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:40640 (40.6 KB) TX bytes:40640 (40.6 KB)
eth0 192.168.1.75这个事内网网卡,
eth1 192.168.14.185这个是外网网卡。
刚开始ping www.baidu.com的时候一直出现ping不通。
无法上网。
后面通过网络查询发现时route出现问题了,
问题之前的route:
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
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 1 0 0 eth0
192.168.14.0 0.0.0.0 255.255.255.0 U 1 0 0 eth1
解决问题之后的route:
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.14.1 0.0.0.0 UG 0 0 0 eth1
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
前后之间可以看出问题。
这里只不过需要增加一个网关:route add default gw 192.168.14.1
所以可以访问外部网络。