1.配置host-only:主機通訊網絡
修改 /etc/sysconfig/network-script/ifcfg-eth0 注意HWADDR和VirtualBox網絡配置裏host-only模式mac一致oop
HWADDR=08:00:27:FE:24:46 TYPE=Ethernet BOOTPROTO=static NETMASK=255.255.255.0 IPADDR=192.168.56.100 GATEWAY=192.168.56.254 DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no NAME=eth0 UUID=642a94f2-30e8-4db7-91ec-3af99a8f2a5f ONBOOT=yes
2.配置網絡地址轉換(NAT):上外網code
修改 /etc/sysconfig/network-script/ifcfg-eth1 注意HWADDR和VirtualBox網絡配置裏NAT模式mac一致ip
HWADDR=08:00:27:81:A6:34 TYPE=Ethernet BOOTPROTO=dhcp NAME=eth1 ONBOOT=yes
3.確認配置ast
[root@c7 ~]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:fe:24:46 brd ff:ff:ff:ff:ff:ff inet 192.168.56.101/24 brd 192.168.56.255 scope global enp0s3 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fefe:2446/64 scope link valid_lft forever preferred_lft forever 3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:81:a6:34 brd ff:ff:ff:ff:ff:ff inet 10.0.3.15/24 brd 10.0.3.255 scope global dynamic enp0s8 valid_lft 86239sec preferred_lft 86239sec inet6 fe80::a00:27ff:fe81:a634/64 scope link valid_lft forever preferred_lft forever [root@c7 ~]# ping baidu.com PING baidu.com (123.125.115.110) 56(84) bytes of data. 64 bytes from 123.125.115.110: icmp_seq=1 ttl=53 time=23.7 ms 64 bytes from 123.125.115.110: icmp_seq=2 ttl=53 time=24.4 ms 64 bytes from 123.125.115.110: icmp_seq=3 ttl=53 time=25.4 ms