Порты Amazon-EC2 не открыты, несмотря на настройки групп безопасности и iptables

2266
pie3636

Я только что арендовал сервер Amazon EC2, предназначенный для размещения приложения node.js, которое слушает клиента через порт 9001.

Я настроил группы безопасности и добавил входящие и исходящие правила для этого порта . Там нет брандмауэра (Amazon Linux), и я полностью отключил iptables.

А sudo netstat -plunta | grep LISTENвозвращает это:

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2064/sshd  tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2104/sendmail  tcp 0 0 0.0.0.0:9001 0.0.0.0:* LISTEN 3207/node  tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 2146/mongod  tcp 0 0 :::80 :::* LISTEN 2303/httpd  tcp 0 0 :::22 :::* LISTEN 2064/sshd  

Мое приложение node.js прослушивает этот порт и все адреса с помощью команды server.listen(9001, "0.0.0.0");

Тем не менее, nmap сервера возвращает это:

Portscan scan report for 172.31.47.81 Host is up. All 1000 scanned ports on 172.31.47.81 are filtered  Portscan done: 1 IP address (1 host up) scanned in 2.32 seconds 

Кроме того, выполнение Nmap на моем телефоне говорит мне, что открыт только порт 80.

Если я запускаю приложение node.js на сервере и выполняю a telnet <ip_server> 9001, оно работает. Однако, если я делаю то же самое со своего персонального компьютера, я получаю ошибку тайм-аута.

Я знаю, что этот вопрос неоднократно задавался, но ни одно из решений, которые я пробовал, не сработало. Я могу пропинговать сервер, использовать ssh для подключения к нему, но приложение node.js не будет работать, а любой из портов, которые должны быть открыты, на самом деле нет (даже попытка подключиться через браузер к веб-серверу не не работает, несмотря на то, что httpd настроен с правильным веб-сайтом, поэтому порт 80 также не открыт).

Есть идеи как это исправить?

2

1 ответ на вопрос

2
Michael - sqlbot

All 1000 scanned ports on 172.31.47.81 are filtered

As, indeed they should be.

There are several ranges of IPv4 addresses that are reserved for use on private networks.

10.*.*.* 172.16.*.* through 172.31.*.* 192.168.*.* 

Any address in these ranges can't be directly accessed across the Internet.

http://tools.ietf.org/html/rfc1918

https://www.arin.net/knowledge/address_filters.html

EC2 instances always have a private IP address associated with them, and sometimes an externally-accessible public IP. These external addresses are either dynamically allocated at instance launch from a pool (and deallocated when the instance is stopped or terminated, at which point the address goes back to the pool), or can be continually reserved by the customer and associated/disassociated with instances and retained for the customer's subsequent reuse (in which case, they're called "Elastic IP Addresses.")

Internally to one customer's EC2 deployment in a given region (and across VPN tunnels into VPC) the instances can address each other by their private IP (and should, because it's free of data transport charges)... but across the Internet, instances can only be accessed by their public (a.k.a. "external") IP address, which is visible in the console... even though, from the instance's perspective (i.e. ifconfig, etc.) the only known address is the private one.

The EC2 infrastructure transparently does the network address translation (NAT) between the external public and the internal private address.

If you're accessing the instance by ssh from outside, the IP address you're using to establish the ssh connection will be the one you'll need to use to access other services, as well.

Похожие вопросы