This article turns from Http://blog.163.com/[email protected]/blog/static/3766198320118231431594/
The Linux system is installed, and the NIC IP is configured later through command mode. The configuration file is usually/etc/sysconfig/network-scripts/ifcfg-interface-name
1. Configure the network card IP address
Vi/etc/sysconfig/network-scripts/ifcfg-eth0 #第二块网卡: Vi/etc/sysconfig/network-scripts/ifcfg-eth1
Device=eth0 #物理设备名
ipaddr=192.168.1.10 #IP地址
netmask=255.255.255.0 #掩码值
network=192.168.1.0 #网络地址 (not available)
broadcast=192.168.1.255 #广播地址 (not available)
gateway=192.168.1.1 #网关地址
Onboot=yes # [Yes|no] (whether the device is activated at boot time)
Userctl=no #[yes|no] (whether the device can be controlled by a non-root user)
Bootproto=static #[none|static|bootp|dhcp] (non-use protocol at boot | static Assignment | BOOTP protocol | DHCP protocol)
2. Configure Network card DNS
The configuration file is below/etc/resolv.conf.
Vi/etc/resolv.conf
NameServer 202.109.14.5 #主DNS
NameServer 219.141.136.10 #次DNS
Search Localdomain
So after the network configuration is complete, you need to restart the Network service: Service network restart or/etc/init.d/network restart
3. A single NIC binds two IPs
Linux Network device configuration file is stored in the/etc/sysconfig/network-scripts, for the first Ethernet network device, the configuration file name is generally ifcfg-eth0. If you need to bind more than one IP address to the first network device, just create a file named ifcfg-eth0:0 in the/etc/sysconfig/network-scripts directory with the following sample:
Device= "eth0:0"
Ipaddr= "211.100.10.119"
netmask= "255.255.255.0"
onboot= "Yes"
Where device is the name of the appliance, ipaddr the IP address of this device, netmask is the subnet mask, onboot indicates that it starts automatically when the system starts.
If you need to bind more than one IP address, simply add the file name and the eth0 in the device in the file. Linux can support a maximum of 255 IP aliases.
How to set fixed IP under Linux