Centos配置静态IP

Centos配置静态IP地址

Posted by Jae on October 10, 2018
1、编辑 /etc/sysconfig/network-scripts/ifcfg-eth0 这里的eth0不是所有的系统都通用,可以通过 ip addr查看。
[root@centos-xidian ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 1e:6f:a2:33:84:16 brd ff:ff:ff:ff:ff:ff
inet 192.168.8.175/20 brd 192.168.15.255 scope global eth0
inet6 fe80::1c6f:a2ff:fe33:8416/64 scope link
   valid_lft forever preferred_lft forever
[root@centos-xidian ~]#
2、修改为静态IP
DEVICE="eth0"
#BOOTPROTO="dhcp"  默认是dhcp,下面修改为static
BOOTPROTO="static"
HWADDR="9E:DD:32:3F:11:2A"
NM_CONTROLLED="yes"
ONBOOT="yes"  # 网卡自启动
TYPE="Ethernet"
UUID="da0b24f5-ca0b-47ad-8e38-176bd736fd14"

IPADDR=12.168.8.175 # IP地址
NETMASK=255.255.240.0 # 子网掩码这里是根据我自己情况设置
NETWORK=192.168.8.1 # 网关
3、重启网络服务
service network restart

如果出现系统找不到eth0设备的错误,直接reboot