virtualbox 虚拟机 网络配置(可联网,主机虚拟机可互访)

亦凉 2022-06-01 00:24 355阅读 0赞
  1. 局域网配置
  2. eth0 Link encap:Ethernet HWaddr 08:00:27:BC:D3:10
  3. inet addr:192.168.42.19 Bcast:192.168.42.255 Mask:255.255.255.0
  4. inet6 addr: fe80::a00:27ff:febc:d310/64 Scope:Link
  5. UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  6. RX packets:69 errors:0 dropped:0 overruns:0 frame:0
  7. TX packets:85 errors:0 dropped:0 overruns:0 carrier:0
  8. collisions:0 txqueuelen:1000
  9. RX bytes:9061 (8.8 KiB) TX bytes:10963 (10.7 KiB)
  10. [root@ctl19 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
  11. DEVICE=eth0
  12. HWADDR=08:00:27:BC:D3:10
  13. TYPE=Ethernet
  14. UUID=364b750a-69c5-46f5-8e04-bc8e765a5bfd
  15. NM_CONTROLLED=yes
  16. ONBOOT=yes
  17. BOOTPROTO=static
  18. DNSI=192.168.42.1
  19. IPV6INIT=no
  20. USERCTL=no
  21. IPADDR=192.168.42.19
  22. NETMASK=255.255.255.0
  23. GATEWAY=192.168.42.1
  24. PREFIX=24
  25. DEFROUTE=yes
  26. IPV4_FAILURE_FATAL=yes

``

  1. 虚拟机联网配置
  2. eth6 Link encap:Ethernet HWaddr 08:00:27:10:0D:CB
  3. inet addr:10.0.0.154 Bcast:10.0.1.255 Mask:255.255.254.0
  4. inet6 addr: fe80::a00:27ff:fe10:dcb/64 Scope:Link
  5. UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  6. RX packets:866 errors:0 dropped:0 overruns:0 frame:0
  7. TX packets:52 errors:0 dropped:0 overruns:0 carrier:0
  8. collisions:0 txqueuelen:1000
  9. RX bytes:87516 (85.4 KiB) TX bytes:6959 (6.7 KiB)

配置图一 配置图二 配置图三

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

发表评论

表情:
评论列表 (有 0 条评论,355人围观)

还没有评论,来说两句吧...

相关阅读