码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS设置静态IP并可访问外网

时间:2016-12-02 22:08:11      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:system   设置   pre   主机   local   settings   network   search   ref   

1.设置虚拟机的网络适配器为NAT模式

 

2.编辑虚拟网络编辑器

选中VMNet8更改设置

子网IP:192.168.101.0

子网掩码:255.255.255.0

NAT设置

网关:192.168.101.2

DHCP设置

起始地址:192.168.101.128

结束地址:192.168.101.254

 

3.宿主机VMNet8更改适配器设置

IP地址:192.168.101.1

子网掩码:255.255.255.0

其它都不设

 

4.虚拟机静态IP设置

右键网络图标,Edit Connections, IPV4 Settings

Method:Manual

Address:192.168.101.128

NetMask:255.255.255.0

GateWay:192.168.101.2

 

DNS servers:192.168.101.2

Search domains:localdomain

 

5.测试外网访问

ping www.baidu.com

宿主机用XShell进行连接

 

配置结果查看:

-----------------------------------------------------------------

vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE="eth0"

BOOTPROTO=none

IPV6INIT="yes"

NM_CONTROLLED="yes"

ONBOOT="yes"

TYPE="Ethernet"

UUID="aa8f2b19-fea9-4d05-a84c-fa419abc4537"

IPADDR=192.168.101.128

PREFIX=24

GATEWAY=192.168.101.2

DNS1=192.168.101.2

DOMAIN=localdomain

DEFROUTE=yes

IPV4_FAILURE_FATAL=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_FAILURE_FATAL=no

NAME="System eth0"

HWADDR=00:0C:29:F2:17:46

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

LAST_CONNECT=1469458152

 

vi /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=localhost.localdomain

 

vi /etc/resolv.conf

# Generated by NetworkManager

search localdomain

nameserver 192.168.101.2

-----------------------------------------------------------------

CentOS设置静态IP并可访问外网

标签:system   设置   pre   主机   local   settings   network   search   ref   

原文地址:http://www.cnblogs.com/ndood/p/6127096.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!