The Linux ifconfig command has already been used to view the NIC information. Here we will describe how to use this command to perform simple configuration and status settings for the NIC, which involves switching the IP address, MAC address, and nic status.
Ifconfig
Configure the IP address of the NIC
Ifconfig eth0 192.168.0.1 netmask 255.255.255.0
Configure the IP address and 24-bit mask of 192.168.0.1 on eth0. What if I want to configure another IP address 192.168.1.1/24 on eth0? Use the following command
Ifconfig eth0: 0 192.168.1.1 netmask 255.255.255.0
Then run the ifconifg command to view the information of the two NICs: eth0 and eth0: 0. If you want to add more IP addresses, enter the names of the network adapters: eth0: 1, eth0: 2. OK!
Configure the hardware address of the NIC
Ifconfig eth0 hw ether xx: xx
You can change the hardware address of the NIC, and then you can cheat the IP address in the LAN.
Disable Nic
Ifconfig eth0 down
Enable the NIC
Ifconfig eth0 up
The ifconfig command has powerful functions. You can also set the MTU and hybrid mode of the NIC. I will not discuss it one by one. I can study it myself in time.
Note: The NIC information configured using the Linux ifconfig command does not exist after the NIC is restarted. To save the above configuration information to your computer forever, you need to modify the NIC configuration file.
- Fully parse Linux ifconfig command 1)
- Describes how to manage Linux User Accounts
- Detailed introduction to the creation of Linux batch users
- Linux mounting commands
- Linux mount command usage