First: use the command to modify (effective immediately, restart failed) # ifconfigeth0192.168.0.1netmask00000000255.0up description: eth0 is the first Nic, and the others are eth1, eth * 192.168.0.1 is the IP address of the first Nic configured for the NIC. net...
First, use the command to modify the changes (the changes take effect immediately and the restart fails)
# Ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
Note:
Eth0 is the first Nic, and the others are eth1, eth *
192.168.0.1 is the IP address configured for the first Nic
Netmask 255.255.255.255.0 is configured with a subnet mask.
Up indicates immediate activation.
For more information about ifconfig parameters, 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 the restart takes effect, write these to the startup script rc. local.
Type 2: modify the configuration document (you need to restart the network configuration to always take effect)
1. modify the IP address
Manually modify/etc/sysconfig/network-scripts/ifcfg-eth0 file # Second Nic: vi/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE = eth0 # physical DEVICE name
IPADDR = 192.168.1.10 # IP address
NETMASK = 255.255.255.0 # mask value
NETWORK = 192.168.1.0 # NETWORK address (optional)
BROADCAST = 192.168.1.255 # BROADCAST address (optional)
GATEWAY = 192.168.1.1 # GATEWAY address
ONBOOT = yes # [yes | no] (whether to activate the device during boot)
USERCTL = no # [yes | no] (whether non-root users can control the device)
BOOTPROTO = static # [none | static | bootp | dhcp] (no protocol used during boot | static allocation | BOOTP protocol | DHCP protocol)
Note: bind two IP addresses to a single NIC
Linux device configuration files are stored in/etc/sysconfig/network-scripts,
For the first Ethernet device, the configuration file name is generally ifcfg-eth0
To bind one more IP address to the first device,
You only need to create a file named ifcfg-eth0: 0 in the/etc/sysconfig/network-scripts directory,
Content example:
DEVICE = "eth0: 0"
IPADDR = "211.100.10.119"
NETMASK = "255.255.255.0"
If you need to bind another IP address, you only need to add the file name to the eth0: x of the DEVICE in the file. LINUX supports up to 255 IP aliases.
DEVICE indicates the DEVICE name, IPADDR indicates the IP address of the DEVICE, NETMASK indicates the subnet mask, and ONBOOT indicates automatic start at startup.
2. modify the Gateway
Vi/etc/sysconfig/network
NETWORKING = yes
HOSTNAME = Aaron
GATEWAY = 192.168.30.1
3. modify DNS
The configuration file is under/etc/resolv. conf.
Vi/etc/resolv. conf
Nameserver 202.109.14.5 # Primary DNS
Nameserver 219.141.136.10 # Secondary DNS
Search localdomain
4. restart network configuration
There are multiple methods:
1: # service network restart under the root account
2: #/etc/init. d/network restart
3: # ifdown eth0
# Ifup eth0
4: # ifconfig eth0 down
# Ifconfig eth0 up
5. start and close the firewall
Effective immediately:
1: # service iptables start
# Service iptables stop
Restart the system to take effect:
2: # service iptables on
# Service iptables off
6. modify the host name
Vi/etc/sysconfig/network, change the HOSTNAME line to HOSTNAME = host name, and the modification will take effect after restart
Author "searching"