Many people are very familiar with the ipconfig command-line tool under Windows, which is used to obtain and modify network interface configuration information. The Linux system has a similar tool, the 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 options properties used in the Ifconfig command, the Ifconfig tool can be used to simply obtain 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 changes.
3. Command parameters:
Up to start the specified network device/NIC
Down to turn off the specified network device/NIC. This parameter can effectively block the IP traffic through the specified interface, and if you want to permanently shut down an interface, we also need to remove all the routing information from the core routing table from that interface.
ARP settings specify whether the NIC supports ARP protocol
-promisc set whether to support the promiscuous mode of the network card, that is, promiscuous mode, refers to the purpose of the message Mac does not add any spreads, all receive mode of operation.
-allmulti Settings Support multicast mode, if you select this parameter, the NIC will receive all multicast packets in the network
-A displays all interface information
-S Display summary information (similar to netstat-i)
Add to configure the IPV6 address for the specified NIC
Del deletes the IPV6 address of the specified network card
MTU bytes sets the maximum transmission unit of the NIC bytes
The netmask subnet mask sets the subnet mask of the NIC, which can be either a 32-bit hexadecimal number with a prefix of 0x, or 4 decimal digits separated by a dot. If you do not plan to divide the network into subnets, you can ignore this option, and if you want to use subnets, remember that each system in the network must have the same subnet mask.
Tunel establishing a tunnel
DSTADDR set a remote address to establish point-to-point communication
-broadcast setting up a broadcast protocol for a specified network card
-pointtopoint setting up point-to-point communication protocols for network cards
Multicast setting the multicast flag for the network card
Address sets IPV4 addresses for network cards
Txqueuelen set the length of the transmission queue for the network card
4. Usage examples:
Example 1: Displaying network device information (active state)
Command: Ifconfig
Description
Eth0 represents the first Nic, where HWaddr represents the physical address of the NIC Mac
inet addr used to indicate the IP address of the network card; bcast broadcast address; mask Mask Address
Lo is the loopback address of the host, which is typically used to test a network program, but does not want the local area network or extranet users to be able to view, can only run on this host and view the network interface used. For example, the HTTPD server is assigned to the loopback address, the browser input 127.0.0.1 can see your Web site. But you can only see that the other host or user of the LAN is not known.
First line: Connection type: Ethernet (Ethernet) HWADDR (Hardware MAC address)
Second line: IP address, subnet, mask of network card
Third line: Up (for Nic on) RUNNING (network cable on behalf of the NIC is connected) multicast (support broadcast) MTU:1500 (maximum transmission Unit): 1500 bytes
Line fourth to fifth: Receive, send packet statistics
Line seventh: Receive, send data byte data statistics
Example 2: Start and close the specified NIC
Command: ifconfig eth0 up
Ifconfig eth0 Down
SSH login to try to pay attention to the students, do not accidentally turn off the network card is not even on the show tease.
Example 3: Configuring and removing IPV6 addresses for network cards
Command: ifconfig eth0 add 33FFE:3240:800:1005::2/64
Ifconfig eth0 del 33ffe:3240:800:1005::2/64
Example 4: Modifying MAC addresses with Ifconfig
Command: ifconfig eth0 hw ether 00:aa:bb:cc:dd:ee
Example 5: Configuring IP Addresses
Command:
Ifconfig eth0 192.168.1.1 Configure IP address for NIC Eth0
Ifconfig eth1 192.168.1.1 netmask 255.255.255.0 Configure IP address for NIC, plus mask
Ifconfig eth2 192.168.1.1 netmask 255.255.255.0 gateway 192.168.1.255 Configure IP address, plus mask, plus gateway for NIC
Example 6: Enabling and shutting down the ARP protocol
Command:
Ifconfig eth0 ARP Open
Ifconfig Eth0-arp off
Example 7: Setting the Maximum transmission unit
Command: ifconfig eth0 MTU 1500 default is 1500-byte MTU
Note: The NIC information configured with the Ifconfig command is temporary. The configuration does not exist after the network card restarts or after the machine restarts. To the above configuration information will always exist in the computer, it is necessary to modify the network card configuration file. Many of the commands under Linux are like this, written into a configuration file.
One Linux command per day (--ifconfig) command