网络访问和管理

  1. 安全远程连接 - ssh

    1. [root ~]$ ssh root@120.77.222.217
    2. The authenticity of host '120.77.222.217 (120.77.222.217)' can't be established.
    3. ECDSA key fingerprint is SHA256:BhUhykv+FvnIL03I9cLRpWpaCxI91m9n7zBWrcXRa8w.
    4. ECDSA key fingerprint is MD5:cc:85:e9:f0:d7:07:1a:26:41:92:77:6b:7f:a0:92:65.
    5. Are you sure you want to continue connecting (yes/no)? yes
    6. Warning: Permanently added '120.77.222.217' (ECDSA) to the list of known hosts.
    7. root@120.77.222.217's password:
  2. 通过网络获取资源 - wget

    • -b 后台下载模式
    • -O 下载到指定的目录
    • -r 递归下载
  3. 发送和接收邮件 - mail

  4. 网络配置工具(旧) - ifconfig

    1. [root ~]# ifconfig eth0
    2. eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    3. inet 172.18.61.250 netmask 255.255.240.0 broadcast 172.18.63.255
    4. ether 00:16:3e:02:b6:46 txqueuelen 1000 (Ethernet)
    5. RX packets 1067841 bytes 1296732947 (1.2 GiB)
    6. RX errors 0 dropped 0 overruns 0 frame 0
    7. TX packets 409912 bytes 43569163 (41.5 MiB)
    8. TX errors 0 dropped 0 overruns 0 carrier 0 collisions
  5. 网络配置工具(新) - ip

    1. [root ~]# ip address
    2. 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    3. link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    4. inet 127.0.0.1/8 scope host lo
    5. valid_lft forever preferred_lft forever
    6. 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    7. link/ether 00:16:3e:02:b6:46 brd ff:ff:ff:ff:ff:ff
    8. inet 172.18.61.250/20 brd 172.18.63.255 scope global eth0
    9. valid_lft forever preferred_lft forever
  6. 网络可达性检查 - ping

    1. [root ~]# ping www.baidu.com -c 3
    2. PING www.a.shifen.com (220.181.111.188) 56(84) bytes of data.
    3. 64 bytes from 220.181.111.188 (220.181.111.188): icmp_seq=1 ttl=51 time=36.3 ms
    4. 64 bytes from 220.181.111.188 (220.181.111.188): icmp_seq=2 ttl=51 time=36.4 ms
    5. 64 bytes from 220.181.111.188 (220.181.111.188): icmp_seq=3 ttl=51 time=36.4 ms
    6. --- www.a.shifen.com ping statistics ---
    7. 3 packets transmitted, 3 received, 0% packet loss, time 2002ms
    8. rtt min/avg/max/mdev = 36.392/36.406/36.427/0.156 ms
  7. 显示或管理路由表 - route

  8. 查看网络服务和端口 - netstat / ss

    1. [root ~]# netstat -nap | grep nginx
  9. 网络监听抓包 - tcpdump

  10. 安全文件拷贝 - scp

    1. [root ~]# scp root@1.2.3.4:/root/guido.jpg hellokitty@4.3.2.1:/home/hellokitty/pic.jpg
  11. 文件同步工具 - rsync

    说明:使用rsync可以实现文件的自动同步,这个对于文件服务器来说相当重要。关于这个命令的用法,我们在后面讲项目部署的时候为大家详细说明。

  12. 安全文件传输 - sftp

    1. [root ~]# sftp root@1.2.3.4
    2. root@1.2.3.4's password:
    3. Connected to 1.2.3.4.
    4. sftp>
    • help:显示帮助信息。

    • ls/lls:显示远端/本地目录列表。

    • cd/lcd:切换远端/本地路径。

    • mkdir/lmkdir:创建远端/本地目录。

    • pwd/lpwd:显示远端/本地当前工作目录。

    • get:下载文件。

    • put:上传文件。

    • rm:删除远端文件。

    • bye/exit/quit:退出sftp。