Manage Ethernet connections
Network interfaces use continuous identifiers such as eth0 and eth1.
The network interface can be set to use an alias (aliases). The alias is marked as eth0: 1 and eth0: 2. This is called a network subinterface and is virtualized, therefore, multiple addresses can be configured for a single online device. aliases are treated as separate interfaces.
View the interface configured using the ifconfig [ethX] command
Use the ifup ethX command to enable the interface
Use the ifdown ethX command to disable the interface
First, view the NIC Information
# Ifconfig, ifconfig-a, or ifconfig eth0
Run the following command to start and stop the NIC: ifup ethx, ifdown ethx, ifconfig eth0 up, or ifconfig ethx0 down.
Network SERVICE
# Service network status view Nic status
# Service network stop Nic
# Service network start Nic
# Service network restart Nic
Configure system-config-network in a graphical network
1. System → preferences → network connection
Activate/assign IP Address/DHCP
Cancel Interface
Modify DNS settings
Modify gateway address
In RHEL6.0, NetworkManager replaces system-config-network in RHEL5.4.
Nm-tool command for displaying network connection status
Nm-connection-editor graphical interface
Cnetworkmanager: The command mode interface of networkmanager
2. Use commands to configure the NIC address
Delete the NIC address and virtual NIC address
Add a network subinterface IP address to the ENI:
Ifconfig eth0: 1 192.168.0.1 netmask 255.255.255.0 up
Add an IP Address: ip addr add 192.168.0.246 dev eth0 to the same network.
Delete an ip address of the network adapter: ip addr del 192.168.0.1 dev eth0
3. edit/etc/sysconfig/network-scripts/ifcfg-ethx.
File to configure IP addresses
Configure the virtual IP address to create a new ifcfg-eth0: 1
# "Ifcfg eth0: 1 delete 192.168.123.20/24" delete subinterface
# "Ifconfig eth0: 1 del 192.168.123.0"
Supplement: Steps for configuring network sub-interfaces
1. Log On As root
2. service NetworkManager stop
3, cp/etc/sysconfig/network-scripts/ifcfg-eth0/etc/sysconfig/network-scripts/ifcfg-eth0: 0
4, vim/etc/sysconfig/network-scripts/ifcfg-eth0: 0
DEVICE = eth0: 0
ONBOOT = yes
IPADDR = 192.168.0.223 # Another IP Address
BOOTPROTO = none
NETMASK = 255.255.255.0
TYPE = Ethernet
GATEWAY = 192.168.0.9
5. service network restart
6. ifup eth0: 0
Add a virtual network interface, edit the file, and restart the network.
Description of fields in the NIC
DEVICE = eth0 DEVICE name
IPADDR = IP Address
NETMASK = mask
BROADCAST = BROADCAST address
BOOTPROTO = select protocol (none | static | bootp | dhcp)
HWADDR = Nic MAC address
ONBOOT = whether to activate the device
USERCTL = no non-root users can control
GATEWAY address, which can also be set in network
TYPE Ethernet TokenRing ATM, ADSL, etc.
PEERDNS = yes: whether to allow automatic modification of the/etc/resolv. conf configuration file
DNS1 = 202.102.224.68
DNS2 =
Network Configuration File Ethernet device
The device configuration is saved in a text file.
--/Etc/sysconfig/network-scripts/ifcfg-ethX
--/Usr/share/doc/initscripts-*/sysconfig.txt
Other global network settings in the network configuration file
Global settings in/etc/sysconfig/network
Many settings can be provided by DHCP.
GATEWAY, but the NIC configuration file takes priority
NETWORKING = yes
HOSTNAME = server1.example.com
GATEWAY = 192.168.2.254
Network Configuration File
The DNS server converts the host name to an IP address.
The server address is dhcp or specified in/etc/resolv. conf.
Search example.com
Nameserver 192.168.0.254
Nameserver 192.168.1.254
Or directly write the DNS to the ifcfg-ethxx file.
DNS1 =
DNS2 =
After the NIC is started, it is automatically written to/etc/resolv. conf.
Add route entries
Route table. Each Linux kernel has an internal table, that is, the route table. The route table is used to determine which method the kernel should use to transmit data packets for a sent data packet.
Use route to view the route table. With the-n option, you can see the gateway, which is easier than pressing the host name.
The u table shows that the subsequent settings work normally, that is, this route is available.
Use route to add a route table
Delete default route
The default route above is deleted. Add the gateway below
Two Methods for adding a soft route in Linux
First:
Route add-net 172.16.6.0 netmask 255.255.255.0 gw 172.16.2.254 dev eth0
/* Add a network named 172.16.6.0/24 to go through 172.16.2.254 eth0 */
/*-Net added network-host added host netmask subnet mask gw gateway dev device, here is your Nic name */
# Route del gw 172.16.2.254/* Delete the default gateway 172.16.2.254 */
Route del-net 172.16.86.0/24/* Delete the default network 172.16.86.0 */
Route/* display the current route table */This method is commonly used, but sometimes it does not work when you delete a route or a soft route. What is the prompt:
SIOCADDRT: unable to reach the network, so use the following method.
Second: the implemented functions are the same as those above.
Ip route add 172.16.6.0/24 via 172.16.2.254 dev eth0
# Ip route del gw 172.16.2.254
Ip route del 172.16.6.0/24 dev eth0
Ip route