Set IP address under Centos/linux1. Temporary entry into force settings
1.1 Modifying the IP address
#ifconfig eth0 192.168.100.100
1.2 Modifying the gateway address
#route add default GW 192.168.100.1 dev eth0
1.3 Modifying DNS
# echo "NameServer 8.8.8.8" >>/etc/resolv.conf
2. Permanent Effect Settings
2.1IP address permanent setting takes effect
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0 #设备名称, the name of the NIC
hwaddr=00:0c:29:93:2a:5c #网卡MAC地址 (Physical address)
type=ethernet #网卡类型以太网模式
uuid=8ad6b8b6-6905-4a4b-a1ac-1c1cab22305f # Global Unique identifier
Onboot=yes #系统启动时是否激活此设备
Nm_controlled=yes #Network manger parameters, real-time effective, no need to restart the network card immediately after the change takes effect.
bootproto=static #网卡获得ip地址的方式 (default is DHCP, which means auto get)
ipaddr=192.168.0.107 #IP地址
gateway=192.168.0.1 #网关 (can be set separately or set here)
prefix=24
dns1=192.168.1.1
netmask=255.255.255.0 #子网掩码
broadcast=192.168.1.255 #网卡广播地址
2.2 Gateway address permanent setting takes effect
Not set in the NIC, set here
# vi/etc/sysconfig/network
Networking=yes #表示系统是否使用网络, no means network is not available
Hostname=doiido #设置本机的主机名 to be the same as the host name set in/etc/hosts
gateway=192.168.100.1 #设置网关的IP地址
2.3DNS Permanent Settings
Not set in the NIC, set in this file
Modify the/etc/resolv.conf file
# vi/etc/resolv.conf
NameServer 8.8.8.8 #google域名服务器
NameServer 114.144.114.114 #国内域名服务器
3. Restart the NIC
Method One:
# Service Network Restart #重启网络服务
# Service Network Stop #关闭网络服务
# Service Network Start #启动网络服务
Method Two:
#/etc/init.d/network stop
#/etc/init.d/network Start
#/etc/init.d/network Restart
Network card status Query
# Service Network Status
View current Routing and gateway Information
# Netstat-r
Centos/linux Network card settings IP address configuration is permanently active