linux下面的常见网络命令(转载的)

网络侦错指令: ping, ifconfig, ifup, ifdown, netstat, route, traceroute, host, nslookup,
ping 是送一个ICMP的封包给那个主机
# ping 10.10.9.158
PING 10.10.9.158 (10.10.9.158) 56(84) bytes of data.
64 bytes from 10.10.9.158: icmp_seq=0 ttl=57 time=5.79 ms
64 bytes from 10.10.9.158: icmp_seq=1 ttl=57 time=1.68 ms
64 bytes from 10.10.9.158: icmp_seq=2 ttl=57 time=8.58 ms
64 bytes from 10.10.9.158: icmp_seq=3 ttl=57 time=5.95 ms
64 bytes from 10.10.9.158: icmp_seq=4 ttl=57 time=4.46 ms
--- 10.10.9.158 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4003ms
rtt min/avg/max/mdev = 1.685/5.295/8.583/2.247 ms, pipe 2
#
ifconfig 设定网络参数使用的命令
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:CD:5F:B6
inet addr:10.10.81.16 Bcast:10.10.81.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fecd:5fb6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:261604 errors:0 dropped:0 overruns:0 frame:0
TX packets:7600 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:21295623 (20.3 MiB) TX bytes:797222 (778.5 KiB)
Interrupt:10 Base address:0x1400
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:7219 errors:0 dropped:0 overruns:0 frame:0
TX packets:7219 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:10461306 (9.9 MiB) TX bytes:10461306 (9.9 MiB)

ifup/ifdown 激活、关闭益而高网卡
root@cnca-test-linux /]# ifup eth0
root@cnca-test-linux /]# ifdown eth0

netstat 查看网络信息的指令
# netstat -in
Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 0 261760 0 0 0 7656 0 0 0 BMRU
lo 16436 0 7219 0 0 0 7219 0 0 0 LRU
# netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:32769 *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 cnca-test-linux:ipp *:* LISTEN
tcp 0 0 *:telnet *:* LISTEN
tcp 0 0 cnca-test-linux:smtp *:* LISTEN
tcp 0 352 10.10.81.16:ssh 10.10.81.131:12379 ESTABLISHED
udp 0 0 *:32768 *:*
udp 0 0 *:912 *:*
udp 0 0 *:sunrpc *:*
udp 0 0 *:ipp *:*
route 显示、修改路由表
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.10.81.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
default 10.10.81.1 0.0.0.0 UG 0 0 0 eth0
traceroute 查看连接到那些主机的信息
# traceroute 10.10.9.158
traceroute to 10.10.9.158 (10.10.9.158), 30 hops max, 38 byte packets
1 10.10.81.253 (10.10.81.253) 0.580 ms 0.376 ms 0.613 ms
2 192.168.193.17 (192.168.193.17) 0.604 ms 0.354 ms 0.374 ms
3 192.168.193.46 (192.168.193.46) 1.173 ms 1.051 ms 2.070 ms
4 192.168.193.126 (192.168.193.126) 2.619 ms 3.024 ms 2.871 ms
5 10.10.161.13 (10.10.161.13) 4.909 ms 4.728 ms 3.947 ms
6 10.10.231.245 (10.10.231.245) 3.818 ms 3.117 ms 3.664 ms
7 10.10.2.33 (10.10.2.33) 4.853 ms 4.995 ms 6.321 ms
8 10.10.2.21 (10.10.2.21) 27.196 ms 18.996 ms 19.702 ms
9 10.10.9.158 (10.10.9.158) 4.107 ms 6.035 ms 3.907 ms

host 显示主机的名称
[# host -a www.163.com
Trying "www.163.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15583
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 0
;; QUESTION SECTION:
;www.163.com. IN ANY
;; ANSWER SECTION:
www.163.com. 85559 IN CNAME www.cache.split.netease.com.
;; AUTHORITY SECTION:
163.com. 16617 IN NS ns3.nease.net.
163.com. 16617 IN NS ns.nease.net.

nslookup 查询主机对应的Ip

#
# nslookup www.163.com
Non-authoritative answer:
www.163.com canonical name = www.cache.split.netease.com.
Name: www.cache.split.netease.com
Address: 220.181.28.52
Name: www.cache.split.netease.com
Address: 220.181.28.53
Name: www.cache.split.netease.com
Address: 220.181.28.54
Name: www.cache.split.netease.com
Address: 220.181.28.50
Name: www.cache.split.netease.com
Address: 220.181.28.51


telnet 可以远程管理一些设备

# telnet 10.10.81.136
Trying 10.10.81.136...
Connected to 10.10.81.136 (10.10.81.136).
Escape character is '^]'.
Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
Kernel 2.6.9-34.EL on an i686
login:

这文是转载的,原文地址:http://blog.chinaunix.net/u/24661/showart_1132652.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值