Zabbixをインストールしてみる・さらに続き

なんかapacheにエラーログが出てたんだけど、ってところから続き。
色々ググって、こんな情報を発見。

/usr/share/doc/zabbix-web-3.2.1/httpd22-example.conf
というファイルがあると思いますので、このファイルを、
/etc/httpd/conf.d/zabbix.conf
というファイルにコピーして、httpdを再起動します。

とあったので、やってみた。…Apacheのエラーログは消えたけど、接続できないのは相変わらず。
Pingも通るしSSHでログインしてもりもり作業もできてるので、もしかして10050ポートが空いてないのかも?というわけでここ参考にncコマンドを実行してみる。

#nc -v -w 1 192.168.0131 -z 10050
nc: connect to 192.168.0.131 port 10050 (tcp) timed out: Operation now in progress

しっぱい。ポートの問題の可能性が高まってきた。
ちなみに、nmapコマンドでポートの状態を確認することができる。参考

[root@localhost ~]# nmap 192.168.0.131

Starting Nmap 5.51 ( http://nmap.org ) at 2017-07-03 11:56 JST
Nmap scan report for 192.168.0.131
Host is up (0.000024s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
3306/tcp open mysql

Nmap done: 1 IP address (1 host up) scanned in 13.20 seconds

やっぱこれ開いてないんじゃん。
ポート開放を行うには、CentOSだとiptablesコマンドを使えばいいらしい。iptablesの使い方メモ
現状のiptablesの設定。初期状態だと思うんだけど。

# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http

Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

これに下記コマンドを投入してポートを開ける。

# iptables -I INPUT -p tcp --dport 10050 -j ACCEPT
# iptables -I INPUT -p tcp --dport 10051 -j ACCEPT
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:zabbix-agent
ACCEPT tcp -- anywhere anywhere tcp dpt:zabbix-agent

ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http

Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

もう1度ncコマンドとnmapコマンドを打ってみる。

# nc -v -w 1 192.168.0.131 -z 10050
Connection to 192.168.0.131 10050 port [tcp/zabbix-agent] succeeded!

# nmap 192.168.0.131

Starting Nmap 5.51 ( http://nmap.org ) at 2017-07-03 13:00 JST
Nmap scan report for 192.168.0.131
Host is up (0.000024s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
3306/tcp open mysql

Nmap done: 1 IP address (1 host up) scanned in 13.18 seconds