EC2 を使用して AWS を使用しており、Postgresql のポートを開こうとしています。AWS では、すでに開いています。
TCP
Port (Service) Source Action
0 - 65535 sg-92aadda2 (default) Delete
22 (SSH) 0.0.0.0/0 Delete
80 (HTTP) 0.0.0.0/0 Delete
5432 0.0.0.0/0 Delete
netstat を実行すると、ポートがリッスンしているように見えます。
# netstat -an | grep 5432
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
localhost nmap を実行すると、次のようになります。
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000010s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
5432/tcp open postgresql
そしてここからが楽しみの始まりです。代替ホストから nmap を実行すると、次のようになります。
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
5432/tcp closed postgresql
また、iptables を調べて、何かが足りないかどうかを確認しましたが、iptables は空に見えます (実際にはあまり機能していないことを意味するはずです)。
$ iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
REJECT all -- anywhere 127.0.0.0/8 reject-with icmp-port-unreachable
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:postgresql
ACCEPT icmp -- anywhere anywhere
LOG all -- anywhere anywhere limit: avg 5/min burst 5 LOG level debug prefix "iptables denied: "
DROP all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
DROP all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
IPにアクセスする方法がわからないように見えるので、何か不足していますか?試行するたびに、次のエラーが表示されます。
Is the server running on host "xx.xx.xx.xx" and accepting TCP/IP connections on port 5432?
外部サーバーがアクセスできるようにポートを開くにはどうすればよいですか? 前もって感謝します =) 追加のデータが必要かどうかをお知らせください。
編集: 以下で尋ねられるように、telnet をテストし、ローカルホストに telnet できましたが、外部から試行すると次のようになります:
$ telnet xx.xx.xx.xx 5432
Trying xx.xx.xx.xx...
telnet: Unable to connect to remote host: Connection refused
また、再確認したところ、適切に ssh に telnet できました。
$ telnet xx.xx.xx.xx 22
Trying xx.xx.xx.xx...
Connected to xx.xx.xx.xx.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1