###前提・実現したいこと
CentOS 7.1で、ネットワークの外部から9999番ポートにアクセスしたいです。
開放する理由は、9999番ポートでApacheを使用するためです。
細かく言うとこのApacheの上でNagiosを動かしたい感じです。Nagiosを動かすためのApacheです。
また、80番ポートではnginxで別サーバが立ち上がっています。
今の状態
・80番(HTTP)や22番(SSH)では問題なくつながっている。
・100日ほど前はこんなめんどくさいことをやらなくても9999番ポートに普通につながっていた。
CentOSのバージョンは以下
sh
1[ec2-user@ip-10-0-3-98 ~]$ cat /etc/centos-release 2CentOS Linux release 7.1.1503 (Core)
firewalldは停止しています。
sh
1[ec2-user@ip-10-0-3-98 ~]$ sudo systemctl status firewalld 2● firewalld.service - firewalld - dynamic firewall daemon 3 Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) 4 Active: inactive (dead) 5 Docs: man:firewalld(1) 6 711月 07 11:16:59 ip-10-0-3-98 systemd[1]: Starting firewalld - dynamic firewall daemon... 811月 07 11:17:00 ip-10-0-3-98 systemd[1]: Started firewalld - dynamic firewall daemon. 911月 07 11:17:01 ip-10-0-3-98 firewalld[1991]: WARNING: ICMP type 'beyond-scope' is not supported by the kernel for ipv6. 1011月 07 11:17:01 ip-10-0-3-98 firewalld[1991]: WARNING: beyond-scope: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time. 1111月 07 11:17:01 ip-10-0-3-98 firewalld[1991]: WARNING: ICMP type 'failed-policy' is not supported by the kernel for ipv6. 1211月 07 11:17:01 ip-10-0-3-98 firewalld[1991]: WARNING: failed-policy: INVALID_ICMPTYPE: No supported ICMP type., ignoring for...-time. 1311月 07 11:17:01 ip-10-0-3-98 firewalld[1991]: WARNING: ICMP type 'reject-route' is not supported by the kernel for ipv6. 1411月 07 11:17:01 ip-10-0-3-98 firewalld[1991]: WARNING: reject-route: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time. 1511月 07 11:19:05 ip-10-0-3-98 systemd[1]: Stopping firewalld - dynamic firewall daemon... 1611月 07 11:19:06 ip-10-0-3-98 systemd[1]: Stopped firewalld - dynamic firewall daemon. 17Hint: Some lines were ellipsized, use -l to show in full.
SELinuxはPermissiveです
sh
1[ec2-user@ip-10-0-3-98 ~]$ sestatus 2SELinux status: enabled 3SELinuxfs mount: /sys/fs/selinux 4SELinux root directory: /etc/selinux 5Loaded policy name: targeted 6Current mode: permissive 7Mode from config file: enforcing 8Policy MLS status: enabled 9Policy deny_unknown status: allowed 10Max kernel policy version: 28
あまり意味がないと思いますが、iptablesのlistは以下のとおりです
sh
1[ec2-user@ip-10-0-3-98 ~]$ sudo iptables --list 2Chain INPUT (policy ACCEPT) 3target prot opt source destination 4ACCEPT tcp -- anywhere anywhere tcp dpt:webcache 5ACCEPT tcp -- anywhere anywhere tcp dpt:distinct 6 7Chain FORWARD (policy ACCEPT) 8target prot opt source destination 9 10Chain OUTPUT (policy ACCEPT) 11target prot opt source destination
###試したこと
####サーバから
sh
1[ec2-user@ip-10-0-3-98 ~]$ curl --head http://localhost:9999 2HTTP/1.1 403 Forbidden 3Date: Tue, 07 Nov 2017 03:36:50 GMT 4Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16 5Last-Modified: Thu, 16 Oct 2014 13:20:58 GMT 6ETag: "1321-5058a1e728280" 7Accept-Ranges: bytes 8Content-Length: 4897 9Content-Type: text/html; charset=UTF-8 10
では問題なくレスポンスが返ります。ステータスコードが403なのは問題ないです。
nmapでは以下が返却されます。
sh
1[ec2-user@ip-10-0-3-98 ~]$ nmap localhost 2 3Starting Nmap 6.40 ( http://nmap.org ) at 2017-11-07 12:31 JST 4Nmap scan report for localhost (127.0.0.1) 5Host is up (0.0010s latency). 6Other addresses for localhost (not scanned): 127.0.0.1 7Not shown: 990 closed ports 8PORT STATE SERVICE 922/tcp open ssh 1025/tcp open smtp 1180/tcp open http 12443/tcp open https 133306/tcp open mysql 145555/tcp open freeciv 158000/tcp open http-alt 168080/tcp open http-proxy 179200/tcp open wap-wsp 189999/tcp open abyss
ちゃんと開いてます。
クライアントから
sh
1~ nmap 【グローバルIPアドレス】 2 3Starting Nmap 7.60 ( https://nmap.org ) at 2017-11-07 12:32 JST 4Nmap scan report for ec2-【グローバルIPアドレス】.ap-northeast-1.compute.amazonaws.com (【グローバルIPアドレス】) 5Host is up (0.044s latency). 6Not shown: 993 filtered ports 7PORT STATE SERVICE 821/tcp open ftp 922/tcp open ssh 1080/tcp open http 1181/tcp open hosts2-ns 12443/tcp open https 138000/tcp open http-alt 148080/tcp open http-proxy 15 16Nmap done: 1 IP address (1 host up) scanned in 8.16 seconds
なぞに9999番が閉じられていました。
sh
1curl http://【グローバルIPアドレス】:9999 2curl: (7) Failed to connect to 【グローバルIPアドレス】 port 9999: Operation timed out
つながらない。
###補足情報
ちなみに8080番もつながらないです。
こっちはnmapで開放できてるのになぜなのかわかりませんが、直面している問題に直接関係ないので、解決できればいいなぐらいです。
そして謎にこっちはGateway Timeoutです
sh
1[ec2-user@ip-10-0-3-98 ~]$ curl http://localhost:8080 2???? It works!!
sh
1~ curl http://【グローバルIPアドレス】:8080 2<HTML>[504] Gateway Timeout</HTML>
その他
何か他に設定の見直し等あればツッコミ入れていただきたいです。
追記
/etc/hosts.deny
は以下のように特に設定されていません。
sh
1[ec2-user@ip-10-0-3-98 ~]$ cat /etc/hosts.deny 2# 3# hosts.deny This file contains access rules which are used to 4# deny connections to network services that either use 5# the tcp_wrappers library or that have been 6# started through a tcp_wrappers-enabled xinetd. 7# 8# The rules in this file can also be set up in 9# /etc/hosts.allow with a 'deny' option instead. 10# 11# See 'man 5 hosts_options' and 'man 5 hosts_access' 12# for information on rule syntax. 13# See 'man tcpd' for information on tcp_wrappers 14#
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。