This is the 7th day of my participation in the November Gwen Challenge. Check out the details: The last Gwen Challenge 2021
Introduction of the command
Using the ifconfig command, you can view and configure network devices. When the network environment changes, you can use this command to configure the network.
Syntax format
ifconfig [-a] [interface]
ifconfig interface [aftype] [address] [keys [args]]
Copy the code
The first syntax is used to query the current configuration and working status of the network interface. If no options or parameters are specified, ifconfig displays information about the current active network interface. If interface is specified, only the current status of the specified network interface is displayed. If the -a option is specified, ifconfig displays the status of all network interfaces, including disabled network interfaces.
The second syntax format is used to configure the network interface. Interface is the name of a network interface. The network interface name is usually the name of the driver followed by the number of a network interface device. Forexample, forexample eth0 represents the first Ethernet interface device. Aftype indicates the address type (that is, the network protocol type), such as INET (default IPv4) or INet6 (IPv6). Address is the IP address assigned to the network interface. An IPv4 address consists of four groups of decimal values with a period. The separator. Keys is one or more keywords, which we’ll explain in more detail later.
parameter
-
Up: Enables the specified network device or nic.
-
Down: Disables the specified network device or nic. This parameter effectively blocks IP traffic through the specified interface. To permanently disable an interface, remove all routing information from the core routing table.
-
Arp: Indicates whether the specified nic supports ARP.
-
-promisc: Indicates whether the interface supports the promiscuous mode. If this parameter is selected, the interface receives all packets sent to it from the network.
-
-allmulti: indicates whether to support the multicast mode. If this parameter is selected, the nic receives all multicast packets on the network.
-
-a: displays information about all interfaces.
-
-s: Displays the summary information (similar to netstat -i).
-
Add: Configures an IPv6 address for the specified NIC.
-
Del: deletes the IPv6 address of a specified NIC.
-
Mtu < bytes > : Sets the maximum transmission order (bytes) of the NIC.
-
Netmask < subnet mask > : sets the subnet mask of the NIC. The mask can be a 32-bit hexadecimal number prefixed with 0x or four decimal numbers separated by dots. If you do not plan to split the network into subnets, leave this option out. If you are using a subnet, remember that every system in the network must have the same subnet mask;
-
Tunel: to build a tunnel.
-
Dstaddr: Sets a remote address and establishes point-to-point communication.
-
-broadcast< address > : sets the broadcast protocol for the specified network adapter.
-
-pointtopoint< address > : sets the point-to-point communication protocol for the nic.
-
Multicast: Sets multicast flags for nics.
-
Address: Sets an IPv4 address for the NIC.
-
Txqueuelen < length > : Sets the length of the transmission queue for the nic;
Examples of application
- Example Query all the current network interfaces and their Settings.
ifconfig -a
Copy the code
- Set the IP address of the second network interface. Keep the default subnet mask and broadcast address.
The ifconfig eth1 192.168.90.200Copy the code
- Delete an IPv6 address to improve the performance of a network interface.
ifconfig eth1 del fe80:20f:feff:fe22:29d2/64
Copy the code
Reference documentation
- The ifconfig command