码迷,mamicode.com
首页 > 系统相关 > 详细

Linux中常用的网络命令

时间:2018-05-27 16:47:11      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:Linux

一、设置网络参数的命令
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中常用的网络命令

标签:Linux

原文地址:http://blog.51cto.com/gdutcxh/2120809

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!