centos7.3配置临时IP、配置永久IP
vmbox:
1.设置网络,桥接.
2.ifconfig eth0 192.168.200.113
3. vi /etc/resolv.conf
nameserver 114.114.114.114
nameserver 8.8.8.8
重启.
配置永久IP地址:https://blog.****.net/sjhuangx/article/details/79618865
centos7.3配置临时IP、配置永久IP
一、centos7.3配置临时IP地址
-
查看网络接口
>
ifconfig 仅仅查看当前活动状态的网络接口
ifconfig eth0 仅查看eth0网卡状态信息
ifconfig -a 即ifconfig -all 查看所有启动禁用的网络接口
ip a 查看所有的网络接口信息 -
启动关闭网卡
启动网卡
ifconfig eth0 up
ifup eth0
关闭网卡
ifconfig eth0 down
ifdown eth0 -
临时IP配置
临时修改IP地址,立即生效,重启服务器或网络失效
[[email protected] ~]# ifconfig eth0 192.168.56.111 netmask 255.255.255.0
[[email protected] ~]# ifconfig eth0 192.168.56.112/24
[[email protected] ~]# ifconfig eth0 192.168.56.113 ->默认24掩码
4 . 重启网络
[[email protected] ~]# systemctl restart network //centos7
[[email protected] ~]# service network restart //centos5/6
[[email protected] ~]# /etc/init.d/network restart //centos5/6
二、centos7.3配置永久IP地址
Centos网卡配置文件路径: /etc/sysconfig/network-scripts
修改配置文件
[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=网卡名称
NAME="System 网卡名称" 名称 name可以不存在
BOOTPROTO=none 默认值或static 这两种属于静态获取ip地址dhcp 动态获取ip
NM_CONTROLLED=no yes表示用这个,no表示不用network—manager。关闭NetworkManager 不关闭也可以不写
ONBOOT=yes 开机启动,**设备,默认是关闭的。
TYPE=Ethernet 类型:局域网
IPADDR=172.16.80.252 需要配置的ip地址
NETMASK=255.255.255.0 子网掩码
GATEWAY=172.16.0.1 网关 不上网DNS和这个也可以不用写。
DNS1=172.16.0.1 域名服务器 domain name server 最多可以写三个DNS
DNS2=114.114.114.114 全国通用的地址
202.106.0.20 北京的DNS。
查看DNS配置文件:cat /etc/resolv.conf
//根据需要配置后,保存即可。