1 相互ping通:不能使用nat,nat只能单向通,虚拟机不能ping通主机,选择桥接:
如图:
2然后设置 ip:最好设置静态ip这样下次不用再改,这里我们只演示使用eth0网卡,=》 vi /etc/sysconfig/network-scripts/ifcfg-eth0,
# Intel Corporation 82540EM Gigabit Ethernet Controller
DEVICE=eth0
#BOOTPROTO=dhcp
TYPE=Ethernet
NM_CONTROLLED=yes
BOOTPROTO=static
DNS1=192.168.0.1 ONBOOT=yes
HWADDR=::::f7:a8
USERCTL=no
IPV6INIT=no
NETMASK=255.255.255.0
IPADDR=192.168.0.105
GATEWAY=192.168.0.1
这里子网掩码,网关都是和我的使用的主机网卡一致,
dns1这里也要一致(不设置或者resov.cnf不设置是不能进行域名访问),ip可以
如图
3禁止掉SELINUX(用于域名解析)
[root@localhost tomener]# vim
/etc/selinux/config
# This file controls the state of SELinux
on the system.
# SELINUX= can take one of these three
values:
# enforcing - SELinux security policy is
enforced.
# permissive - SELinux prints warnings
instead of enforcing.
# disabled - No SELinux policy
is loaded.
#SELINUX=enforcing
SELINUX=disabled(这个不设置也可以)
#
SELINUXTYPE= can take one of these two values:
#
targeted - Targeted processes are protected,
# mls -
Multi Level Security
protection.
SELINUXTYPE=targeted
这里是把SELINUX=enforcing 改为
SELINUX=disabled
4 配置完,需要重启网络服务:service network restart 。基本上就可以访问外网域名和互通