translated

This commit is contained in:
geekpi 2017-02-07 10:10:18 +08:00
parent 25eae5f925
commit df48b23f9d
2 changed files with 72 additions and 71 deletions

View File

@ -1,71 +0,0 @@
translating---geekpi
How to Check Remote Ports are Reachable Using nc Command
============================================================
A port is a logical entity which acts as a endpoint of communication associated with an application or process on an Linux operating system. It is useful to know which ports are open and running services on a target machine before using them.
We can easily [list open ports in Linux][3] on a local machine using the [netstat][4] or several other Linux commands such [NMAP][5].
In this guide, we will show you how to determine if ports on a remote host are reachable/open using simple netcat (in short nc) command.
netcat (or nc in short) is a powerful and easy-to-use utility that can be employed for just about anything in Linux in relation to TCP, UDP, or UNIX-domain sockets.
```
# yum install nc [On CentOS/RHEL]
# dnf install nc [On Fedora 22+]
$ sudo apt-get install netcat [On Debian/Ubuntu]
```
We can use it to: open TCP connections, listen on arbitrary TCP and UDP ports, send UDP packets, do port scanning under both IPv4 and IPv6 and beyond.
Using netcat, you can check if a single or multiple or a range of open ports as follows. The command below will help us see if the port 22 is open on the host 192.168.56.10:
```
$ nc -zv 192.168.1.15 22
```
In the command above, the flag:
1. `-z`  sets nc to simply scan for listening daemons, without actually sending any data to them.
2. `-v`  enables verbose mode.
The next command will check if ports 80, 22 and 21 are open on the remote host 192.168.5.10 (we can use the hostname as well):
nc -zv 192.168.56.10 80 22 21
It is also possible to specify a range of ports to be scanned:
```
$ nc -zv 192.168.56.10 20-80
```
For more examples and usage of netcat command, read through our articles as follows.
1. [Transfer Files Between Linux Servers Using netcat Command][1]
2. [Linux Network Configuration and Troubleshooting Commands][2]
Thats all. In this article, we explained how to check if ports on a remote host are reachable/open using simple netcat commands. Make use of the comment section below to write back to us concerning about this tip.
--------------------------------------------------------------------------------
译者简介:
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.
--------------------------------------------------------------------------------
via: http://www.tecmint.com/check-remote-port-in-linux/
作者:[Aaron Kili][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/aaronkili/
[1]:http://www.tecmint.com/transfer-files-between-two-linux-machines/
[2]:http://www.tecmint.com/linux-network-configuration-and-troubleshooting-commands/
[3]:http://www.tecmint.com/find-open-ports-in-linux/
[4]:http://www.tecmint.com/20-netstat-commands-for-linux-network-management/
[5]:http://www.tecmint.com/nmap-command-examples/

View File

@ -0,0 +1,72 @@
使用 “nc” 命令检查远程端口是否打开
============================================================
端口是作为与 Linux 操作系统上的应用或进程相关联的端点的逻辑实体。在使用之前,了解目标机器上哪些端口是打开的并正在运行服务是非常有用的。
我们可以使用 [netstat][4] 或其他几个 Linux 命令如 [NMAP][5] 在本地机器上轻松地[列出 Linux 中的打开端口][3]。
在本指南中,我们将向你展示如何使用简单的 netcat简称 nc命令来确定远程主机上的端口是否可访问/打开。
netcat或简称 nc是一个功能强大且易于使用的程序可用于 Linux 中与 TCP、UDP 或 UNIX 域套接字相关的任何事情。
```
# yum install nc [在 CentOS/RHEL 中]
# dnf install nc [在 Fedora 22+ 中]
$ sudo apt-get install netcat [在 Debian/Ubuntu 中]
```
我们可以使用它:打开 TCP 连接、侦听任意 TCP 和 UDP 端口、发送 UDP 数据包、在 IPv4 和 IPv6 进行端口扫描。
使用 netcat你可以检查单个或多个或一系列打开的端口如下所示。下面的命令将帮助我们查看端口 22 是否在主机 192.168.56.10 上打开:
```
$ nc -zv 192.168.1.15 22
```
上面的命令中,这些标志是:
1. `-z`  设置 nc 只是扫描侦听守护进程,实际上不向它们发送任何数据。
2. `-v`  启用 verbose 模式
下面的命令会在远程主机 192.168.5.10 上端口 80、22 和 21 是否打开(我们也可以使用主机名):
```
nc -zv 192.168.56.10 80 22 21
```
也可以指定端口扫描的范围:
```
$ nc -zv 192.168.56.10 20-80
```
更多关于 netcat 命令的例子和使用,阅读我们下面的文章。
1. [使用 netcat 命令在 Linux 服务器键传输文件][1]
2. [Linux 网络配置及除错命令][2]
就是这样。在本文中,我们解释了如何使用 netcat 命令检测远程主机端口是否可达/打开。在评论栏中留下你的想法。
--------------------------------------------------------------------------------
译者简介:
Aaron Kili 是 Linux 和 F.O.S.S 爱好者,将来的 Linux SysAdmin 和 web 开发人员,目前是 TecMint 的内容创建者,他喜欢用电脑工作,并坚信分享知识。
--------------------------------------------------------------------------------
via: http://www.tecmint.com/check-remote-port-in-linux/
作者:[Aaron Kili][a]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/aaronkili/
[1]:http://www.tecmint.com/transfer-files-between-two-linux-machines/
[2]:http://www.tecmint.com/linux-network-configuration-and-troubleshooting-commands/
[3]:http://www.tecmint.com/find-open-ports-in-linux/
[4]:http://www.tecmint.com/20-netstat-commands-for-linux-network-management/
[5]:http://www.tecmint.com/nmap-command-examples/