网络工具

测试网络

显示主机名
    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 16:16
下一篇 2016-09-09 16:20

相关推荐

  • mysql基础

      mysql基础 数据模型: 数据模型:层次模型、网状模型、关系模型、…… 关系模型: 二维关系:表     行:row, entity     列:colume, attribution 索引:数据结构,辅助完成数据查找;  &nbsp…

    Linux干货 2016-11-01
  • shell基础if与case

    1.read   使用read来把输入值分配给一个或多个shell变量;   -p 指定要显示的提示;例如 read -p "SHURU" num   -t TIMEOUT   read 从标准输入中读取值,给每个单词分配一个变量,所有剩余单词都被分配给最后一个变量 2.流程控制   过程…

    Linux干货 2016-08-18
  • 马哥教育N22期第八周作业

    1、请描述网桥、集线器、二层交换机、三层交换机、路由器的功能、使用场景与区别。 设备 功能 使用场景 区别 网桥 根据MAC地址来转发帧,本地通信只限本网段内, 相当于中继器,线路比较长保证信号不变形的传输 工作在物理层,相当于一个物理接口 集线器 接收到的数据包进行广播转发,所有端口都能收到此数据,通过MAC确认是不是发给自己的包进行回应 广播形式转发数据…

    Linux干货 2016-11-14
  • zabbix监控Hadoop的实现

            Hadoop日常运行过程中一些参数需要进行实时监控,如:Map、Reduce任务数量,HDFS磁盘使用情况,namenode、datanode在线数量及健康情况,以便更好的掌握整个Hadoop集群架构的运行情况。         下面结合最近工作中的一些…

    Linux干货 2015-03-08
  • Linux路由实验

    一    实验背景:路由器的功能是将不同网段的主机建立通信,本次试验是在使用linux主机当作路由器,完成主机间通信。如下图所示 二、实验环境:主机A和B为CentOS7.2,主机C和D为CentOS6.8,且C和D上分别都有两块网卡 三、实验步骤     注意:为避免干扰项,需将每台主机…

    Linux干货 2016-09-07
  • nginx rewrite实战

    nginx rewrite实战 nginx rewrite实战 nginx rewrite实战 nginx rewrite 正则表达式匹配 多目录转成参数 目录对换 目录自动加“/” ,这个功能一般浏览器自动完成 禁止htaccess 禁止多个目录 禁止以/data开头的文件,可以禁止/data/下多级目录下.log.txt等请求 禁止单个文件 给favic…

    Linux干货 2016-11-17