The first type: Use the command to modify (direct immediate effect, restart failure)
#ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
Description
Eth0 is the first Nic, and the others are eth1,eth*
192.168.0.1 is the IP address configured for the first NIC configured for the NIC
Netmask 255.255.255.0 is configured with a subnet mask
Up means immediate activation
More parameter descriptions for ifconfig see related Help
Gateway
# route Add default GW 192.168.30.1 eth0
Dns:
# VI Etc/resolv.conf
NameServer 202.131.80.1
NameServer 202.131.80.5
If you want to restart, write these into the start script rc.local
Second: Modify the configuration document (need to restart the network configuration, always effective)
First, modify the IP address
Manually change/etc/sysconfig/network-scripts/ifcfg-eth0 file #第二块网卡: 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)
Note: A single NIC is bound to two IP
The Linux device configuration file is stored in the/etc/sysconfig/network-scripts,
For the first device on Ethernet, the profile name is typically Ifcfg-eth0
If you need to bind more than one IP address to the first device,
You only need to create a file named ifcfg-eth0:0 in the/etc/sysconfig/network-scripts directory.
Examples of the content are:
Device= "eth0:0"
Ipaddr= "211.100.10.119"
netmask= "255.255.255.0"
If you need to bind more than one IP address, simply add the file name and the eth0:x in the device in the file. Linux can support a maximum of 255 IP aliases.
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 at startup.
Second, modify the gateway
Vi/etc/sysconfig/network
Networking=yes
Hostname=aaron
gateway=192.168.30.1
Third, modify the 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
Iv. Restarting the network configuration
There are several ways to do this:
1:root Account # Service Network restart
2:#/etc/init.d/network Restart
3:# Ifdown eth0
# ifup Eth0
4:# ifconfig eth0 Down
# ifconfig eth0 up
V. Start and close the firewall
Immediate effect:
1: #service iptables start
#service iptables Stop
Restart the system to take effect:
2: #service iptables on
#service iptables off
Vi. Modifying host Names
vi/etc/sysconfig/network, modify hostname line as hostname= hostname, reboot to take effect