网络工具

测试网络

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

相关推荐

  • 基于kubernetes构建Docker集群管理详解

    一、前言        Kubernetes 是Google开源的容器集群管理系统,基于Docker构建一个容器的调度服务,提供资源调度、均衡容灾、服务注册、动态扩缩容等功能套件,目前最新版本为0.6.2。本文介绍如何基于Centos7.0构建Kubernetes平台,在正式介绍…

    2015-03-10
  • 第七周-磁盘管理、RAID及Shell脚本练习

    一、创建一个10G分区,并格式为ext4文件系统; (1)、 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl; (2)、挂载至/data/mydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳; [root@N1 ~]# mkfs.ext4 -b 2048 -m 2 -L MYDATA /…

    Linux干货 2017-08-13
  • Linux用户、组、权限管理

    Linux用户与组管理 Linux系统上,用户通过内核拷贝程序到内存中,从此发起进程。进程以发起者的身份进行,进程对文件的访问权限,取决于发起进程的用户的权限。而有些后台进程或服务类进程以非管理员身份运行,为此也需要创建多个普通用户,此类用户不需登录。 系统中,用户类别分为管理员和普通用户(系统用户和登录用户),组类别分为基本组和附加组。管理系统上的用户与组…

    Linux干货 2016-12-07
  • 高性能Mysql主从架构的复制原理及配置详解

    1 复制概述       Mysql内建的复制功能是构建大型,高性能应用程序的基础。将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台主机的数据复制到其它主机(slaves)上,并重新执行一遍来实现的。复制过程中一个服务器充当主服务器,而一个或多个其它服务器充当从服务器。主服务器…

    Linux干货 2015-04-13
  • week5

    1、显示当前系统上root、fedora或user1用户的默认shell; useradd fedora useradd user1 egrep "^(root|fedora|user1)" /etc/passwd | cut -d: -f1,7 2、找出/e…

    Linux干货 2016-11-24
  • iptables

    一、前言 什么是iptables?当我们启动iptables时,使用service命令可以启动iptables。但是并非使用service启动的iptables就能说明其是一个服务。Iptables是一个便以我们写规则的工具,真正起作用的是内核中的netfilter一个框架。Netfilter内置了5个hook函数,当一个数据包交由此机器时,经过这5个hoo…

    Linux干货 2015-10-27