Ifconfig
The syntax for ifconfig is:
Ifconfig [-A] [-v] [-S] [[]
]
[[-]broadcast [
]]
[Netmask
]
[Up|down]
Where interface for the network card name, address for IP addresses, broadcast to set the broadcast address, followed by the address for broadcast addresses IP, netmask to set the subnet mask, then address for the subnet mask IP, up and down settings Current network card status, up indicates the current network card is enabled, down indicates that the current network card is turned off.
The common parameters of Ifconfig are as follows:
-A View all network card status
-V View version information for the ifconfig command
-S View statistics
Example:
1 The IP address of the first network card is set to 192.168.0.1:
Ifconfig eth0 192.168.0.1 (format: Ifconfig network device name IP address)
2 temporarily turn off or enable the network card:
Turn off the first Nic: Ifconfig eth0 down
Enable the first block card ifconfig eth0 up
3 Set the subnet mask of the first network card to 255.255.255.0:
Ifconfig eth0 netmask 255.255.255.0 (format: Ifconfig network device name netmask subnet mask)
We can also set the IP address and subnet mask at the same time:
Ifconfig eth0 192.168.0.1 netmask 255.255.255.0
4 View the status of the first NIC:
Ifconfig eth0
If you want to see all network card status, use the Ifconfig command without parameters directly.
Ifconfig output status information is very useful, let's briefly explain:
Several states are more important:
Up/down: Whether the network card is started, if it is down, it will certainly not be used;
The number of errors packets in the RX packets is too large to indicate a problem with the NIC when it is received;
The number of errors packages in TX packets is too large to indicate a problem with the NIC when it is sent;