"Linux" ifconfig command detailed __linux

Source: Internet
Author: User

reproduced from: http://www.cnblogs.com/peida/archive/2013/02/27/2934525.html


Many windows are very familiar with the Ipconfig command-line tool, which is used to obtain and modify network interface configuration information. The Linux system has a similar tool, namely ifconfig (Interfaces config). You typically need to log in as root or use sudo to use the Ifconfig tool on a Linux machine. Depending on the option properties used in the Ifconfig command, the Ifconfig tool can be used to simply get network interface configuration information and modify these configurations.

1. command format:

ifconfig [Network Devices] [parameters]

2. Command function:

The Ifconfig command is used to view and configure network devices. This command can be used to configure the network appropriately when the network environment has changed.

3. Command parameters:

Up start specifies network device/NIC.

Down closes the specified network device/network adapter. This parameter effectively blocks IP traffic through the specified interface, and if you want to permanently close an interface, we also need to remove all routing information for that interface from the core routing table.

The ARP setting specifies whether the NIC supports the ARP protocol.

-promisc settings support the promiscuous mode of the NIC, if selected, the NIC will receive all packets from the network

-allmulti setting supports multicast mode, if selected, the NIC will receive all multicast packets from the network

-A displays all interface information

-S Displays summary information (similar to netstat-i)

Add to configure IPV6 address for the specified network card

Del Delete the IPv6 address of the specified network card

< hardware address > Configure the Maximum Transmission unit of the network card

mtu< bytes > Set the Maximum Transmission Unit (bytes) of the network card

netmask< Subnet Mask > Set the subnet mask for the network adapter. The mask can be a 32-bit hexadecimal number with a prefix of 0x, or it can be 4 decimal digits separated by dots. If you don't want to divide your network into subnets, you can ignore this option; If you want to use subnets, remember that each system in your network must have the same subnet mask.

Tunel Build Tunnels

DSTADDR set up a remote address to establish point-to-point communication.

-broadcast< address > Set broadcast protocol for specified network adapters

-pointtopoint< address > Set up Point-to-Point communication protocol for network adapters

Multicast set up multicast flags for network adapters

Address set IPV4 addresses for network adapters

txqueuelen< length > Set the length of the transmission queue for the NIC

4. Use instance:

instance 1: Show Network Device Information ( activation State of )

command:

Ifconfig

Output:

[Root@localhost ~] # ifconfig
Eth0 Link encap:ethernet hwaddr 00:50:56:bf:26:20
inet addr:192.168.120.204 bcast:192.168.120.255 mask:255.255.255.0
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:8700857 errors:0 dropped:0 overruns:0 frame:0
TX packets:31533 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:596390239 (568.7 MiB) TX bytes:2886956 (2.7 MiB)

Lo Link encap:local Loopback
inet addr:127.0.0.1 mask:255.0.0.0
Up loopback RUNNING mtu:16436 metric:1
RX packets:68 errors:0 dropped:0 overruns:0 frame:0
TX packets:68 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2856 (2.7 KiB) TX bytes:2856 (2.7 KiB)

Description:

Eth0 represents the first network card, in which hwaddr represents the physical address of the network card, you can see the physical address of the current network card (MAC address) is 00:50:56:bf:26:20

Inet addr is used to represent the IP address of the network card, the IP address of which is 192.168.120.204, broadcast address, bcast:192.168.120.255, mask address mask:255.255.255.0

Lo is the loopback address of the host, which is generally used to test a network program, but does not want the local area network or extranet users to be able to view, only on this host to run and view the network interface used. For example, the HTTPD server is designated to the bad address, in the browser input 127.0.0.1 will be able to see your Web site. But just as you can see, other hosts or users of the local area network do not know.

First line: Connection type: Ethernet (Ethernet) HWADDR (Hardware MAC address)

Second line: Network card IP address, subnet, mask

Third line: Up (on behalf of the NIC Open) RUNNING (network card on behalf of the network cable is connected) multicast (support multicast) mtu:1500 (Maximum transmission Unit): 1500 bytes

Line fourth to fifth: Receive and send packet statistics

Line seventh: Receive and send data byte count statistics.

instance 2: start off the specified network card

command:

Ifconfig eth0 up

Ifconfig eth0 Down

Output:

Description:

Ifconfig eth0 up for boot nic eth0 ifconfig eth0 down to turn off Nic Eth0. SSH login Linux server operation should be careful, closed can not be opened, unless you have multiple network card.

instance 3: Configure and remove IPV6 addresses for network adapters

command:

Ifconfig eth0 Add 33FFE:3240:800:1005::2/64

Ifconfig eth0 del 33ffe:3240:800:1005::2/64

Output:

Description:

Ifconfig eth0 Add 33ffe:3240:800:1005::2/64 Configure IPV6 address for NIC Eth0;

Ifconfig eth0 Add 33ffe:3240:800:1005::2/64 Remove IPV6 address for Nic Eth0;

practice, SSH login Linux server operation should be careful, closed can not be opened, unless you have multiple network card.

instance 4: modify MAC address with Ifconfig

command:

ifconfig eth0 hw ether 00:aa:bb:cc:dd:ee

output: [root@localhost ~] #  ifconfig eth0 down //off Nic
[ Root@localhost ~] #  ifconfig eth0 hw ether 00:aa:bb:cc:dd:ee //Modify MAC address
[ Root@localhost ~] #  ifconfig eth0 up //start Network card

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: info-contact@alibabacloud.com 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.