Set a static IP address in Linux
1, enter in the terminal: Vi/etc/sysconfig/network-scripts/ifcfg-eth0
2, start editing, fill in IP address, subnet mask, gateway, DNS, etc.
[[Email protected] Desktop]# Cat/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0 #设备名称
Type=ethernet #网络类型
Uuid=bfafdad5-e1c9-4adf-864b-c772e4965ab7
Onboot=yes #开机自启动. Must have
Nm_controlled=yes
Bootproto=static #静态ip. Must have
Defroute=yes
Ipv4_failure_fatal=yes
Ipv6init=no
Name= "System eth0"
ipaddr=192.168.23.128 #ip地址. Must have
Prefix=24
gateway=192.168.23.2 #网关. Must have
netmask=255.255.255.0 #子网掩码. Must have
dns1=192.168.23.2 #dns. Must have
hwaddr=00:0c:29:10:ec:9d #mac地址
last_connect=1480146093
3. After editing, save and exit.
4, restart the network services. Service network restart or/etc/init.d/network restart
5, Ping the gateway, ping the outside network for testing. Can ping to indicate that the network is normal.
Set a static IP address in Linux