Replace eth0
in the following commands with the actual network card you want to operate.
# View all network interfaces
ifconfig -a
# View enabled networks
ifconfig
# Open the eth0 network interface
ifconfig eth0 up
# Close the eth0 network card
ifconfig eth0 down
# Configure network card information
ifconfig eth0 192.168.2.10 netmask 255.255.255.0 broadcast 192.168.2.255
# Modify the network card eth0 MAC address
ifconfig eth0 hw ether AA:AA:BB:CC:dd:EE
# Display network interface information
ip link show
# Enable network card
ip link set eth0 up
# Turn off the network card
ip link set eth0 down
# Enable the mixed mode of the network card
ip link set eth0 promisc on
# Turn off the mixed mode of the network card
ip link set eth0 promisc offi
#Set the network card queue length
ip link set eth0 txqueuelen 1200
#Set the maximum transmission unit of the network card
ip link set eth0 mtu 1400
# Display network card IP information
ip addr show
#Set the eth0 network card IP address 192.168.0.1
ip addr add 192.168.0.1/24 dev eth0
# Delete the eth0 network card IP address
ip addr del 192.168.0.1/24 dev eth0
# Display system routes
ip route show
#Set the system default route
ip route add default via 192.168.1.254
# View routing information
ip route list
# Set the gateway of the 192.168.4.0 network segment to 192.168.0.254, and the data goes through the eth0 interface
ip route add 192.168.4.0/24 via 192.168.0.254 dev eth0
# Set the default gateway to 192.168.0.254
ip route add default via 192.168.0.254 dev eth0
# Delete the gateway of the 192.168.4.0 network segment
ip route del 192.168.4.0/24
# Delete default route
ip route del default
# Delete route
ip route delete 192.168.1.0/24 dev eth0
# If the network interface is not enabled
ifconfig eth0 up
# Set the static IP of the eth0 network port
ifconfig eth0 192.168.1.100
# If the network interface is not enabled
ifconfig eth0 up
# Get dynamic ip
dhclient eth0