Linux中常用的網絡命令
阿新 • • 發佈:2018-05-27
Linux一、設置網絡參數的命令
ifconfig:查詢、設置網卡與IP網絡等相關參數
ifconfig:查詢、設置網卡與IP網絡等相關參數
[root@www ~]# ifconfig {interface} {down|up} [root@www ~]# ifconfig interface {options} interface:eth0、eth1、ppp0 options:mtu、up,down、netmask、broadcast [root@www ~]# ifconfig eth0 192.168.10.11 netmask 255.255.255.128 mtu 8000 修改文件參數 [root@www ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 [root@www ~]# service network restart
ifup、ifdown:啟動與關閉網絡接口
[root@www ~]# ifup {interface}
[root@www ~]# ifdown {interface}
route:查看、配置路由表
[root@www ~]# route [-nee] [root@www ~]# route add [-net|-host] [網絡或主機] netmask [mask] [gw|dev] [root@www ~]# route del [-net|-host] [網絡或主機] netmask [mask] [gw|dev] -n:不要使用通信協議或主機名,直接使用IP或port number -ee:顯示更詳細的信息 [root@www ~]# route add -net 192.168.10.0 netmask 255.255.255.0 dev eth0 [root@www ~]# route add default gw 192.168.1.250
ip:整合式命令,可以直接修改各種參數
[root@www ~]# ip [options] [動作] [命令] link:與設備相關的設置,MTU、MAC地址等 [root@www ~]# ip [-s] link show [root@www ~]# ip link set [device] [動作或參數] //up|down、address、name、mtu addr/address [root@www ~]# ip address show [root@www ~]# ip address [add|del] [IP參數] [dev設備名] [相關參數] route [root@www ~]# ip route show [root@www ~]# ip route [add|del] [IP或網絡號] [via gateway] [dev 設備]
二、無線網絡:iwlist、iwconfig
三、DHCP客戶端命令:dhclient
[root@www ~]# dhclient eth0
四、網絡排錯與查看命令
ping
[root@www ~]# ping [選項與參數] IP
[root@www ~]# ping -c 3 192.168.1.1 //指定發三個ICMP數據包
traceroute
[root@www ~]# traceroute [選項與參數] IP
-n:單純使用IP
-U:使用UDP
-I:使用ICMP
-T:使用TCP
-w:默認5秒不響應則不通
-p:端口號
-i:設備
[root@www ~]# traceroute -n www.baidu.com
netstat
[root@www ~]# netstat -[rn] //查看路由
[root@www ~]# netstat -[antulpc] //與網絡接口有關的參數
-a:所有
-t:TCP
-u:UDP
-l:Listen狀態的服務
-p:列出PID和Program的文件名
-c:設置幾秒鐘後自動更新一次
host、dig、nslookup //檢測主機名對於的IP
telnet、ssh //遠程連接服務
ftp、lftp //遠程數據傳輸
tcpdump、wireshark //數據包捕獲功能
links、wget //網頁相關功能
nc、netcat //啟動任意TCP/UDP數據包的端口連接
[root@www ~]# nc [-u] [IP|Port] [Port]
[root@www ~]# nc -l [IP|Port] [Port]
-u:使用UDP
[root@www ~]# nc localhost 25
Linux中常用的網絡命令