一、桥接模式设置方法
[root@Centos66 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
HWADDR=00:0c:29:8d:e8:5b
DNS1=8.8.8.8
USERCTL=no
PEERDNS=yes
IPV6INIT=no
[root@Centos66 ~]# /etc/init.d/network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:
Determining IP information for eth0... done.
[ OK ]
二、NAT—静态ip地址配置上网
先设置网卡为NAT模式
[root@Centos66 ~]#vi/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.0.15
NETMASK=255.255.255.0
GATEWAY=192.168.0.2
HWADDR=00:0c:29:8d:e8:5b
DNS1=8.8.8.8
USERCTL=no
PEERDNS=yes
IPV6INIT=no
[root@Centos66 ~]# /etc/init.d/networkrestart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Determining if ip address 192.168.0.15 isalready in use for device eth0...
[ OK ]
[root@Centos66 ~]# ping www.baidu.com
PING www.a.shifen.com (112.80.248.74)56(84) bytes of data.
64 bytes from 112.80.248.74: icmp_seq=1ttl=128 time=45.2 ms
64 bytes from 112.80.248.74: icmp_seq=2ttl=128 time=45.5 ms
64 bytes from 112.80.248.74: icmp_seq=3ttl=128 time=48.0 ms