centos增加内网ip

 1.centos 右键右上角的网络连接,选择编辑连接,然后选中eth0 ,然后编辑,选择IPV4设置,然后添加自己的ip,掩码和网关

2.网卡重启 service network restart

3.添加路由规则 router add -host  服务器ip  gw  网关地址

在centos中配置ip的步骤:

1. /etc/sysconfig/network-scripts/ifcfg-eth0

[root@web-1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0                                    //由eth0来启动
BOOTPROTO=dhcp                                 //获取IP的方式是自动获取,static是固定IP,none是手动
HWADDR=00:0c:29:62:9a:a2                       //网卡的物理地址
NM_CONTROLLED=yes
ONBOOT=no                                      //启动时网络接口是否有效
TYPE=Ethernet
UUID="ed818867-f233-4909-a55d-856833ffce9e"
USERCTL=no
IPV6INIT=no                                    //是否支持IP6
PEERDNS=yes

2. /etc/sysconfig/network

[root@web-1 ~]# vi /etc/sysconfig/network
NETWORKING=yes    //网络是否可用
HOSTNAME=web-1    //主机名,主机名在/etc/hosts里面配置

3. /etc/hosts

[root@web-1 ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

 4. /etc/resolv.conf

[root@web-1 ~]# vi /etc/resolv.conf
; generated by /sbin/dhclient-script
search localdomain          //搜索要找的域名,在/etc/hosts里面设定的有
nameserver 192.168.174.2    //DNS服务器对应的IP

如果想要自动获取IP地址,只需要/etc/sysconfig/network-scripts/ifcfg-eth0文件中的 ONBOOT=no 改为ONBOOT=yes 然后执行下面命令就可以了

[root@web-1 ~]# service network restart

猜你喜欢

转载自blog.csdn.net/u011101777/article/details/51741788