网络命令

2018-06-14  本文已影响0人  毛利卷卷发

ifconfig

接口地址查看和管理,默认查看active状态的接口,立即生效,重启后失效,常见选项:

ifup/ifdown

开启或关闭指定接口,基于配置文件来识别并完成接口的配置,因此会重读配置文件

route

查看和操作路由表,常见选项:

netstat

显示网路连接、路由表、接口统计、组播成员关系 ,常用选项:

ss

和netstat类似,netstat通过遍历proc来获取socket信息,ss使用netlink与内核tcp_diag模块通信获取socket信息,常用选项:

ip

ip link

链路管理,常用选项:

ip address

协议地址管理,常用选项:

ip route

路由管理,常用选项:

其他

ping

测试主机的连通性,常用选项:

traceroute

显示包经过的网络主机

[root@v6 ~]#traceroute 114.114.114.114
traceroute to 114.114.114.114 (114.114.114.114), 30 hops max, 60 byte packets
 1  192.168.1.1 (192.168.1.1)  1.987 ms  1.631 ms  1.564 ms
 2  116.243.160.1 (116.243.160.1)  4.085 ms  4.038 ms  3.952 ms
 3  124.205.97.48 (124.205.97.48)  3.902 ms  3.867 ms  4.516 ms
 4  218.241.165.17 (218.241.165.17)  4.467 ms  4.384 ms  4.334 ms
 5  * * *
 6  114.114.114.114 (114.114.114.114)  4.298 ms  4.160 ms  3.788 ms

nslookup

查询Internet名称服务器

[root@centos7 ~]# nslookup www.baidu.com
Server:     223.5.5.5
Address:    223.5.5.5#53

Non-authoritative answer:
www.baidu.com   canonical name = www.a.shifen.com.
Name:   www.a.shifen.com
Address: 61.135.169.121
Name:   www.a.shifen.com
Address: 61.135.169.125

host

DNS查找工具

[root@centos7 ~]# host www.baidu.com
www.baidu.com is an alias for www.a.shifen.com.
www.a.shifen.com has address 61.135.169.121
www.a.shifen.com has address 61.135.169.125

dig

DNS查找工具

[root@centos7 ~]# dig www.baidu.com

; <<>> DiG 9.9.4-RedHat-9.9.4-61.el7 <<>> www.baidu.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22669
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.baidu.com.         IN  A

;; ANSWER SECTION:
www.baidu.com.      37  IN  CNAME   www.a.shifen.com.
www.a.shifen.com.   37  IN  A   61.135.169.125
www.a.shifen.com.   37  IN  A   61.135.169.121

;; Query time: 178 msec
;; SERVER: 223.5.5.5#53(223.5.5.5)
;; WHEN: Fri Jun 15 11:01:17 CST 2018
;; MSG SIZE  rcvd: 90

ftp/lftp

交互式访问ftp服务器,ftp不高亮显示,lftp默认高亮显示

# 访问172.18.0.1
[root@centos6 ~]# lftp 172.18.0.1

# 列出当前服务器下的文件
lftp 172.18.0.1:~> ls                          
drwxr-xr-x   21 0        0            4096 Apr 09 10:44 pub
# 列出当前本地的文件
lftp 172.18.0.1:/> !ls
anaconda-ks.cfg  Desktop    Downloads    install.log.syslog  Pictures  Templates
bin      Documents  install.log  Music           Public    Videos

# 进入指定目录,使用get下载指定文件,默认下载至当前目录
lftp 172.18.0.1:/> cd /pub/Tools/
lftp 172.18.0.1:/pub/Tools> !ls
lost+found
lftp 172.18.0.1:/pub/Tools> get skyZIP™_Proxy.crx 
72928 bytes transferred                           
lftp 172.18.0.1:/pub/Tools> !ls
lost+found  skyZIP™_Proxy.crx
# 使用mget批量下载指定文件,put上传文件,mput批量上传文件
lftp 172.18.0.1:/pub/Tools> mget vlc*
30503216 bytes transferred in 3 seconds (11.15M/s)                       
lftp 172.18.0.1:/pub/Tools> !ls
lost+found  skyZIP™_Proxy.crx  vlc-2.2.3-win32.exe

lftpget

非交互式直接访问ftp服务器下载指定文件,默认下载至当前目录

[root@centos6 app]# ls
[root@centos6 app]# lftpget ftp://172.18.0.1/pub/Tools/vlc-2.2.3-win32.exe
[root@centos6 app]# ls    
vlc-2.2.3-win32.exe

wget

非交互式直接访问ftp、http、https服务器下载指定文件,默认下载至当前目录,常用选项:

# 静默下载指定文件
[root@centos6 app]# wget ftp://172.18.0.1/pub/Tools/vlc-2.2.3-win32.exe
--2018-06-15 11:24:24--  ftp://172.18.0.1/pub/Tools/vlc-2.2.3-win32.exe
           => “vlc-2.2.3-win32.exe”
Connecting to 172.18.0.1:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /pub/Tools ... done.
==> SIZE vlc-2.2.3-win32.exe ... 30503216
==> PASV ... done.    ==> RETR vlc-2.2.3-win32.exe ... done.
Length: 30503216 (29M) (unauthoritative)

100%[============================================>] 30,503,216  11.2M/s   in 2.6s    

2018-06-15 11:24:27 (11.2 MB/s) - “vlc-2.2.3-win32.exe” saved [30503216]
# 当本地由同名文件时,会自动将下载好的文件重命名为:原文件名.#
[root@centos6 app]# wget ftp://172.18.0.1/pub/Tools/vlc-2.2.3-win32.exe -q
[root@centos6 app]# ls
vlc-2.2.3-win32.exe  vlc-2.2.3-win32.exe.1

links

相当于字符界面浏览器,常用选项:

上一篇 下一篇

猜你喜欢

热点阅读