网络工具

测试网络

显示主机名
    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

相关推荐

  • 加密解密基础、OpenSSL通信 及 搭建私有CA (Blog 11)

    加密解密技术基础、PKI及创建私有CA

    2017-11-29
  • 磁盘分区磁盘管理及挂载

    磁盘分区 fdisk提供交互式接口管理分区,操作均在内存中完成,没有直接同步到磁盘;直到使用w命令保存至磁盘中。 语法: 1.查看分区使用信息:     fdisk -l [-u] [device…]:列出指定磁盘设备上的分区情况; 2.管理分区    fdisk d…

    Linux干货 2016-08-31
  • Linux系统初始化流程:系统初始化相关基础知识

    Linux系统初始化流程:系统初始化相关基础知识 内核简介 内核的功能 进程管理:通过task_struct, scheduler 实现 内存管理 I/O管理:中断以及中断处理 文件系统管理:ext3,ext4,xfs 等 驱动程序 安全相关:SELinux,各种加密库 通用软件,平台相关软件 内核设计流派 单内核:单一体系结构 linux 为单一内核 模块…

    2015-02-28
  • N22-第二周作业

    Linux上的文件管理类命令有哪些,其常用使用方法及其相关示例演示。 文件管理类命令有:cp,mv,rm cp:复制文件或者目录   单源复制:cp [OPTION]… [-T] SOURCE DEST        多源复制:cp [OPTION]… SOURCE… DI…

    Linux干货 2016-09-19
  • dns配置

    dns

    Linux干货 2018-01-22
  • Linux 网络管理

    Linux 网络管理 第一篇:计算机网络基础: 一、计算机网络: 1.TCP/IP:协议栈(使用中的模型)     ISO(国际标准化组织):OSI(开放系统互联基本参考模型),学习中的模型。           1)各层之间的相关协议和单位:     互联网…

    Linux干货 2016-09-06