Detailed explanation of linux Network Interfaces

Source: Internet
Author: User
Tags dns2 nameserver

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.

# 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 netmask up
Add an IP Address: ip addr add dev eth0 to the same network.

Delete an ip address of the network adapter: ip addr del 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" delete subinterface
# "Ifconfig eth0: 1 del"

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 = # Another IP Address
TYPE = Ethernet
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
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 =
DNS2 =
Network Configuration File Ethernet device

The device configuration is saved in a text file.


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


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.
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

Route add-net netmask gw dev eth0
/* Add a network named to go through eth0 */
/*-Net added network-host added host netmask subnet mask gw gateway dev device, here is your Nic name */
# Route del gw* Delete the default gateway */
Route del-net* Delete the default network */
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 via dev eth0
# Ip route del gw
Ip route del dev eth0
Ip route

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.