网络工具

测试网络

显示主机名
    hostname
    centos6 /etc/sysconfig/network

    更改主机名
        centos7使用  配置文件/etc/hostname

            hostnamectl status

            [root@localhost ~]# hostnamectl
               Static hostname: localhost.localdomain
                     Icon name: computer-vm
                       Chassis: vm
                    Machine ID: c00fb0d822ce4e889fc914291bc4ec31
                       Boot ID: cb0856f215c54eed9b5a3ae3e30c37b2
                Virtualization: vmware
              Operating System: CentOS Linux 7 (Core)
                   CPE OS Name: cpe:/o:centos:centos:7
                        Kernel: Linux 3.10.0-327.el7.x86_64
                  Architecture: x86-64

            hostnamectl set-hostname HOSTNAME



测试网络连通性
    ping
        ping x.x.x.x 80 
        可以测试端口是否打开,是否运行相应的服务。
    mtr

显示正确的路由表
    ip route

确定名称服务器使用:
    nslookup
    host
    dig

跟踪路由
    •traceroute

        [root@yangyouwei ~]# traceroute 10.1.0.1
        traceroute to 10.1.0.1 (10.1.0.1), 30 hops max, 60 byte packets
         1  10.1.0.1 (10.1.0.1)  0.444 ms  0.752 ms  0.656 ms

    •Tracepath

        [root@yangyouwei ~]# tracepath 10.1.0.1
         1?: [LOCALHOST]     pmtu 1500
         1:  10.1.0.1 (10.1.0.1)                                    1.512ms reached
         1:  10.1.0.1 (10.1.0.1)                                    1.213ms reached
             Resume: pmtu 1500 hops 1 back 1

网络客户端工具

lftp, ftp, lftpget, wget
    # lftp[-p port] [-u user[,password]] SERVER
子命令:
get、mget、ls、help

# lftpgetURL
# ftp
# wget
wget[option]... [URL]...
    -q: 静默模式
    -c: 断点续传
    -O: 保存位置
    --limit-rates=: 指定传输速率

FTP

ftp:工具比较老了,推荐是用lftp,默认一般不安装。

[root@yangyouwei ~]# ftp 10.1.0.1 
Connected to 10.1.0.1 (10.1.0.1).
220 (vsFTPd 3.0.2)
Name (10.1.0.1:root): ftp  ##########输入用户名 ftp 或anonymous 匿名登陆
331 Please specify the password.
Password:        #####匿名登陆不使用密码
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd            #########显示处于ftp服务器的那个目录下
257 "/"             ##########ftp服务器的根下,不是服务器系统的根。
ftp> ls                ##########显示当前目录下的内容
227 Entering Passive Mode (10,1,0,1,99,87).
150 Here comes the directory listing.
drwxr-xr-x   23 0        0            4096 Jul 23 06:14 pub
226 Directory send OK.
ftp> cd pub            #############切换目录
250 Directory successfully changed.
在命令提示符下!COMMAND可执行终端下的命令不用退出ftp
ftp> !pwd
/root


ftp> help
Commands may be abbreviated.  Commands are:

!               debug           mdir            sendport        site
$               dir             mget            put             size
account         disconnect      mkdir           pwd             status
append          exit            mls             quit            struct
ascii           form            mode            quote           system
bell            get             modtime         recv            sunique
binary          glob            mput            reget           tenex
bye             hash            newer           rstatus         tick
case            help            nmap            rhelp           trace
cd              idle            nlist           rename          type
cdup            image           ntrans          reset           user
chmod           lcd             open            restart         umask
close           ls              prompt          rmdir           verbose
cr              macdef          passive         runique         ?
delete          mdelete         proxy           send

下载文件,文件默认下载到用户本地主机的工作目录下。

get FILENAME
注:文件名支持table键补全

passive(被动) 表示切换模式

主动模式:默认ftp服务器是主动模式
被动模式:
    注:主动模式,是让客户端主动向服务器的指定端口提交请求,被动模式,客户端等待服务器发起请求

ftp> passive
Passive mode off.  主动模式服务器开启20端口
ftp> passive
Passive mode on.

切换本地目录 ftp> lcd 效果等同于!cd
退出ftp
bye或quit

lftp

默认是匿名登陆,不需要输入用户名和密码

[root@yangyouwei ~]# lftp 10.1.0.1
lftp 10.1.0.1:~> 
lftp 10.1.0.1:~> ls
drwxr-xr-x   23 0        0            4096 Jul 23 06:14 pub
ls 显示文件时,文件和目录带颜色。
支持名称补全。
支持命令历史

下载文件
get FILENAME
默认下载到,用户本地主机的当前工作目录

mget FILENAME FILENAME... ###下载多个文件。

上传文件
mput FILENAME   ###上传本地主机当前工作目录下的文件,上传到当前ftp目录下。

lftp帮助

    lftp 10.1.0.1:/> help
    !<shell-command>                     (commands)
    alias [<name> [<value>]]             bookmark [SUBCMD]
    cache [SUBCMD]                       cat [-b] <files>
    cd <rdir>                            chmod [OPTS] mode file...
    close [-a]                           [re]cls [opts] [path/][pattern]
    debug [<level>|off] [-o <file>]      du [options] <dirs>
    exit [<code>|bg]                     get [OPTS] <rfile> [-o <lfile>]
    glob [OPTS] <cmd> <args>             help [<cmd>]
    history -w file|-r file|-c|-l [cnt]  jobs [-v]
    kill all|<job_no>                    lcd <ldir>
    lftp [OPTS] <site>                   ls [<args>]
    mget [OPTS] <files>                  mirror [OPTS] [remote [local]]
    mkdir [-p] <dirs>                    module name [args]
    more <files>                         mput [OPTS] <files>
    mrm <files>                          mv <file1> <file2>
    [re]nlist [<args>]                   open [OPTS] <site>
    pget [OPTS] <rfile> [-o <lfile>]     put [OPTS] <lfile> [-o <rfile>]
    pwd [-p]                             queue [OPTS] [<cmd>]
    quote <cmd>                          repeat [OPTS] [delay] [command]
    rm [-r] [-f] <files>                 rmdir [-f] <dirs>
    scache [<session_no>]                set [OPT] [<var> [<val>]]
    site <site_cmd>                      source <file>
    torrent [-O <dir>] <file>            user <user|URL> [<pass>]
    version                              wait [<jobno>]
    zcat <files>                         zmore <files>

非交互式ftp下载命令

lftpget

ftp和lftp都是交互式命令,不能写在脚本中。脚本中使用,lftpget命令

lftpget url …

[root@yangyouwei ~]# lftpget ftp://10.1.0.1/pub/ISOs/MirantisOpenStack-5.1.iso
^C../MirantisOpenStack-5.1.iso' at 172890240 (6%) 58.67M/s eta:39s [Receiving d

wget

可以下载http资源和ftp资源。
支持多线程下载

-q 支持静默

-c 支持断点续传

-o 支持保存位置
-o /PATH/TO/NEWNAME

[root@yangyouwei ~]# wget ftp://10.1.0.1/pub/ISOs/MirantisOpenStack-5.1.iso
--2016-07-20 19:19:11--  ftp://10.1.0.1/pub/ISOs/MirantisOpenStack-5.1.iso
           => “MirantisOpenStack-5.1.iso.1”
Connecting to 10.1.0.1:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /pub/ISOs ... done.
==> SIZE MirantisOpenStack-5.1.iso ... 2586220544
==> PASV ... done.    ==> RETR MirantisOpenStack-5.1.iso ... done.
Length: 2586220544 (2.4G) (unauthoritative)

 5% [======>                                        ] 144,988,272 98.7M/s              ^ 
 7% [========>                                      ] 195,183,472 77.0M/s              ^

浏览器

纯字符界面浏览器
默认没有安装

[root@yangyouwei ~]# rpm -qf /usr/bin/links
elinks-0.12-0.21.pre5.el6_3.x86_64

[root@yangyouwei ~]# links 10.1.0.1
Home Page
内网服务

GitLab

Zabbix Server (UserName:Guest,Password:)

Yum Repository

Repo Conf Files

Fedora EPEL

Kickstart Files

FTP Server

http://10.1.0.1/ks_files/ [——]

使用ESC键调用菜单。

links –dump 纯文字方式显示,不含格式信息

[root@yangyouwei ~]# links –dump 10.1.0.1
内网服务

[1]GitLab

[2]Zabbix Server (UserName:Guest,Password:)

[3]Yum Repository

[4]Repo Conf Files

[5]Fedora EPEL

[6]Kickstart Files

[7]FTP Server

References

Visible links

  1. http://10.1.0.1:8088/

  2. http://10.1.0.1/zabbix

  3. http://10.1.0.1/cobbler/ks_mirror

  4. http://10.1.0.1/repofiles/

  5. http://10.1.0.1/fedora-epel/

  6. http://10.1.0.1/ks_files/

  7. ftp://10.1.0.1/pub/

links –source
看源代码

curl

简单,直接看源码

[root@yangyouwei ~]# curl 10.1.0.1
<title>Home Page</title>
<body>
<h1>内网服务</h1>

<h3><a href="http://10.1.0.1:8088/">GitLab</a></h3>
<h3><a href="http://10.1.0.1/zabbix">Zabbix Server (UserName:Guest,Password:)</a></h3>
<h3><a href="http://10.1.0.1/cobbler/ks_mirror">Yum Repository</a></h3>
<h3><a href="http://10.1.0.1/repofiles/">Repo Conf Files</a></h3>
<h3><a href="http://10.1.0.1/fedora-epel/">Fedora EPEL</a></h3>
<h3><a href="http://10.1.0.1/ks_files/">Kickstart Files</a></h3>
<h3><a href="ftp://10.1.0.1/pub/">FTP Server</a></h3>

</body>

加上选项 -I 可以看服务器信息

[root@yangyouwei ~]# curl -I 10.1.0.1
HTTP/1.1 200 OK
Date: Wed, 07 Sep 2016 03:02:30 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5
Last-Modified: Sat, 23 Jul 2016 06:29:25 GMT
ETag: "20c-53847ac2446bf"
Accept-Ranges: bytes
Content-Length: 524
Content-Type: text/html; charset=UTF-8


telnet

可以测试端口是否开启。

[root@localhost yum.repos.d]# telnet 10.1.0.1 999
Trying 10.1.0.1...
telnet: connect to address 10.1.0.1: Connection refused
[root@localhost yum.repos.d]# telnet 10.1.0.1 80
Trying 10.1.0.1...
Connected to 10.1.0.1.
Escape character is '^]'.
^C
Connection closed by foreign host.

原创文章,作者:yyw,如若转载,请注明出处:http://www.178linux.com/44960

(0)
yywyyw
上一篇 2016-09-09
下一篇 2016-09-09

相关推荐

  • N26-博客作业-week9

    1、写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现; #!/bin/bash # declare -i nologin_num=0,login_num=0 for i in $(cut -d: -f7 /etc/passwd); do if …

    Linux干货 2017-04-01
  • linux查找命令locate、find

    本次博主来介绍下超实用的查找命令,没有查不到,只有做不到。 直接上干货:查找命令:locate和find,常用find,我们重点介绍find locate 通过查询系统上预建的文件索引数据库全盘查找所需文件,locate是透过update程序将硬盘中的所有档案和目录资料先建立一个索引数据库,在执行loacte时直接找该索引,查询速度会较快,索引的构建是在系统…

    2017-08-12
  • Linux命令格式及基础命令使用

    Linux命令格式command [选项] [参数]其中 选项 以 – 开始,多个选项可用一个-连起来,如ls -l -a 与ls -la相同。根据命令的不同,参数分为可选的或必须的。ifconfig格式:ifconfig [网络设备] [参数]命令功能:命令用来查看和配置网络设备。当网络环境发生改变时可通过此命令对网络进行相应的配置。示例 :i…

    Linux干货 2018-03-03
  • 马哥教育网络班21期+第7周课程练习

    1、创建一个10G分区,并格式为ext4文件系统; (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl; [root@localhost ~]#mke2fs -t ext4 -b 2048 -m 2 -L &qu…

    Linux干货 2016-08-15
  • 1128基于fastDFS,制作rpm包

    基于fastDFS,制作rpm包: 1、安装相应的环境: 1、Development tools 2、git(从外网git仓库下载源码所需) 3、Server Platform Development ———————————&#…

    2016-12-05