I. Commands for setting network parameters
Ifconfig: Query, set network card and IP network and other related parameters
[[email protected] ~]# ifconfig {interface} {down|up}[[email protected] ~]# ifconfig interface {options}interface:eth0、eth1、ppp0options:mtu、up,down、netmask、broadcast[[email protected] ~]# ifconfig eth0 192.168.10.11 netmask 255.255.255.128 mtu 8000修改文件参数[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0[[email protected] ~]# service network restart
Ifup, Ifdown: Starting and shutting down the network interface
[[email protected] ~]# ifup {interface}[[email protected] ~]# ifdown {interface}
Route: View, configure routing tables
[[email protected] ~]# route [-nee][[email protected] ~]# route add [-net|-host] [网络或主机] netmask [mask] [gw|dev][[email protected] ~]# route del [-net|-host] [网络或主机] netmask [mask] [gw|dev]-n:不要使用通信协议或主机名,直接使用IP或port number-ee:显示更详细的信息[[email protected] ~]# route add -net 192.168.10.0 netmask 255.255.255.0 dev eth0[[email protected] ~]# route add default gw 192.168.1.250
IP: Integrated command, can directly modify various parameters
[[email protected] ~]# ip [options] [动作] [命令]link:与设备相关的设置,MTU、MAC地址等[[email protected] ~]# ip [-s] link show[[email protected] ~]# ip link set [device] [动作或参数] //up|down、address、name、mtuaddr/address[[email protected] ~]# ip address show[[email protected] ~]# ip address [add|del] [IP参数] [dev设备名] [相关参数]route[[email protected] ~]# ip route show[[email protected] ~]# ip route [add|del] [IP或网络号] [via gateway] [dev 设备]
Second, wireless network: Iwlist, Iwconfig
Third, DHCP client command: dhclient
[[email protected] ~]# dhclient eth0
Iv. Network troubleshooting and Viewing commands
ping[[email protected] ~]# ping [选项与参数] IP[[email protected] ~]# ping -c 3 192.168.1.1 //指定发三个ICMP数据包traceroute[[email protected] ~]# traceroute [选项与参数] IP-n:单纯使用IP-U:使用UDP-I:使用ICMP-T:使用TCP-w:默认5秒不响应则不通-p:端口号-i:设备[[email protected] ~]# traceroute -n www.baidu.comnetstat[[email protected] ~]# netstat -[rn] //查看路由[[email protected] ~]# netstat -[antulpc] //与网络接口有关的参数-a:所有-t:TCP-u:UDP-l:Listen状态的服务-p:列出PID和Program的文件名-c:设置几秒钟后自动更新一次host、dig、nslookup //检测主机名对于的IPtelnet、ssh //远程连接服务ftp、lftp //远程数据传输tcpdump、wireshark //数据包捕获功能links、wget //网页相关功能nc、netcat //启动任意TCP/UDP数据包的端口连接[[email protected] ~]# nc [-u] [IP|Port] [Port][[email protected] ~]# nc -l [IP|Port] [Port]-u:使用UDP[[email protected] ~]# nc localhost 25
Common network commands in Linux