网络工具

测试网络

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

相关推荐

  • 网络管理之配置静态ip和多网卡绑定

    不知怎的,这几天教室的网络异常诡异,各种不稳定啊。原先小编都是通过自动获取(dhcp)的方式来进行网络连接的,现在这种网络情况下需要(static)的方式来配置一个固定的ip。步骤如下: 一、在终端中输入:vim /etc/sysconfig/network-scripts/ifcfg-eth0 二、进行编辑并保存退出 三、重启网络服务:service ne…

    2017-09-10
  • shell练习

    1 、编写脚本/root/bin/systeminfo.sh, 显示当前主机系统信息, 包括主机名,IPv4 地址,操作系统版本,内核版本,CPU 型 号,内存大小,硬盘大小。 运行后结果是: 2 、编写脚本/root/bin/backup.sh ,可实现每日将/etc/ 目录备 份到/root/etcYYYY-mm-dd中 运行结果是: 3 、编写脚本/r…

    Linux干货 2016-08-15
  • 马哥教育网络21期+第二周练习博客

    马哥教育网络21期+第二周练习博客 复习第一节课内容: 1,计算机的组成及其功能:     运算器,控制器,存储器,输入设备,输出设备 2,Linux的发行版:     shackware,debian,redhat 3,Linux的哲学思想 一切介文件把几乎所有资源,包括硬件设…

    Linux干货 2016-07-12
  • 第一次测试

    1.第一层  video  视频 2.第二层  audio  音频 3.第三层  字幕 查看视频详细信息 ffmpeg -i 视频文件 转码修改视频格式 ffmpeg -i 输入文件   输出文件格式 视频文件中提取音频和视频 提取视频中的音频 ffmpeg -i CP0454900262.ts -…

    Linux干货 2017-02-06
  • iptables 初识

    iptables 包过滤性防火墙     iptables是位于用户空间,是防火墙管理配置规则的工具。     iptables的作用:用来添加,删除,管理netfilter规则。     Netfilter是位于内核中真正的防火墙,由5个钩子组成,…

    Linux干货 2016-06-01
  • WEB 常见故障与处理

    一、应用故障 HTTP 502 故障 502 Bad Gateway 故障检测: 首先定位到前端故障服务器节点,在前端服务器(Telnet)上访问后端服务端口响应时间。如发现响应时间超时>10s。说明后端应用程序出现故障。需要到后端服务器查看,并查明情况。 PS:HTTP 502 Bad Gateway 故障一般分为以下2种情况: 网络问题:前端无法连…

    2016-06-03