局域网配置
eth0      Link encap:Ethernet  HWaddr 08:00:27:BC:D3:10  
          inet addr:192.168.42.19  Bcast:192.168.42.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:febc:d310/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:69 errors:0 dropped:0 overruns:0 frame:0
          TX packets:85 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:9061 (8.8 KiB)  TX bytes:10963 (10.7 KiB)
[root@ctl19 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=08:00:27:BC:D3:10
TYPE=Ethernet
UUID=364b750a-69c5-46f5-8e04-bc8e765a5bfd
NM_CONTROLLED=yes
ONBOOT=yes
BOOTPROTO=static
DNSI=192.168.42.1
IPV6INIT=no
USERCTL=no
IPADDR=192.168.42.19
NETMASK=255.255.255.0
GATEWAY=192.168.42.1
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
虚拟机联网配置
eth6      Link encap:Ethernet  HWaddr 08:00:27:10:0D:CB  
          inet addr:10.0.0.154  Bcast:10.0.1.255  Mask:255.255.254.0
          inet6 addr: fe80::a00:27ff:fe10:dcb/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:866 errors:0 dropped:0 overruns:0 frame:0
          TX packets:52 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:87516 (85.4 KiB)  TX bytes:6959 (6.7 KiB)

配置图一

配置图二

配置图三

route  -n 查看默认网关route del default删除默认网关
[root@ctl19 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.3.0        0.0.0.0         255.255.255.0   U     1      0        0 eth10
192.168.42.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
10.0.0.0        0.0.0.0         255.255.0.0     U     1      0        0 eth8
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
可以上网的ip为网关是10.0.0.1 可以根据windows 获取(ipconfig)
连接特定的 DNS 后缀 . . . . . . . :
 本地链接 IPv6 地址. . . . . . . . : fe80::71af:1493:f05d:1c70%18
 IPv4 地址 . . . . . . . . . . . . : 10.0.0.98
 子网掩码  . . . . . . . . . . . . : 255.255.0.0
 默认网关. . . . . . . . . . . . . : 10.0.0.1
route add default gw 10.0.0.1 dev eth6   #添加默认网关这样就可以上网了
[root@ctl19 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.42.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
10.0.0.0        0.0.0.0         255.255.0.0     U     1      0        0 eth6
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
0.0.0.0         10.0.0.1        0.0.0.0         UG    0      0        0 eth6



Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐