Use the following command to configure the Ethernet
1. ifconfig
You can use the ifconfig command to configure and view the network interface configuration.
For example:
1) configure the IP address of eth0 and activate the device.
# Ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up
2) configure the IP address of eth0: 1 and add a route.
# Ifconfig eth0: 1 192.168.1.3
# Route add-host 192.168.1.3 dev eth0: 1
3) activate the device.
# Ifconfig eth0: 1 up
4) disable the device.
# Ifconfig eth0: down
5) view the configuration of the specified network interface.
# Ifconfig eth0
6) view all network interface configurations.
# Ifconfig
2. route
You can use the route command to configure and view the configuration of the kernel route table.
For example:
1) route added to the host.
# Route add-host 192.168.1.2 dev eth0: 0
# Route add-host 10.20.30.148 gw 10.20.30.40
2) route to the network.
# Route add-net 10.20.30.40 netmask 255.255.255.248 eth0
# Route add-net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
# Route add-net 192.168.1.0/24 eth1
3) Add a default gateway.
# Route add default gw 192.168.1.1
4) view the configuration of the kernel route table.
# Route
5) delete a route.
# Route del-host 192.168.1.2 dev eth0: 0
# Route del-host 10.20.30.148 gw 10.20.30.40
# Route del-net 10.20.30.40 netmask 255.255.255.248 eth0
# Route del-net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
# Route del-net 192.168.1.0/24 eth1
# Route del default gw 192.168.1.1
You can use the following statement to implement steps 1 and 2:
Ifconfig eth0 172.16.19.71 netmask 255.255.255.0
Route 0.0.0.0 gw 172.16.19.254
Service network restart
3. traceroute
You can use the traceroute command to display the route through which the data packet arrives at the target host.
For example:
# Traceroute www.sina.com.cn
4. ping
You can use the ping command to test network connectivity.
For example:
# Ping www.sina.com.cn
# Ping-c 4 192.168.1.12
5. netstat
You can use the netstat command to display network status information.
For example:
1) display network interface status information.
# Netstat-I
2) display the Socket and the program using the Socket of all monitoring servers.
# Netstat-lpe
3) displays the kernel route table information.
# Netstat-r
# Netstat-nr
4) display the connection status of TCP/UDP transmission protocol.
# Netstat-t
# Netstat-u
6. hostname
You can use the hostname command to change the host name. For example;
# Hostname myhost
7. arp
You can use the arp command to configure and view the arp cache. For example:
1) view arp cache.
# Arp
2) Add a record corresponding to the IP address and MAC address.
# Arp-s 192.168.33.15 00: 60: 08: 27: CE: B2
3) delete a cache record corresponding to an IP address and a MAC address.
# Arp-d192.168.33.15
Related Articles]
- New Tricks: Learn quick commands for Linux
- Introduction to the File command for identifying File types in Linux
- Detailed instructions on using the Route command in Linux