LoginSignup
5
4

More than 5 years have passed since last update.

メールサーバの構築でポートが開かなくてハマった

Posted at

現象

環境はConoHaのVPS、CentOS7.4
Postfixの設定をしたが、外部から見れない

Firewallも設定した
image.png

ConoHaのコンパネからも設定した
image.png

ローカルなら開いてる
image.png

外部から見ると開いていない
image.png

???!??!:thinking::thinking::thinking::thinking:

原因究明

なんとなくnmapをtcpdumpしてみた

問題のサーバA側で
tcpdump port 465 -w mailtest.dump
を実行し、別のサーバBで
nmap AのIPアドレス -p 465 -ttl 64
として、ダンプされたmailtest.dumpをWiresharkで見てみると、
image.png
となり、[SYN]に対し、[RST,ACK]が返されているのでやっぱりポートは閉じている。
ちなみにAが受信した時点でのttlは50。

比較のため、
Aで
tcpdump port 80 -w httptest.dump
を実行し、別のサーバBで
nmap Aアドレス -p 80 -ttl 64
として、ダンプされたhttptest.dumpをWiresharkで見てみると、
image.png
となり、[SYN]に対し、[SYN,ACK]が返されているのでやっぱりポートは開いている。
ちなみにAが受信した時点でのttlは50。

よくわかんない結果となったが、ここで注目したのはTTLの値で、両方同じ値であることから、[SYN]をはじいているのは途中にあるルータとかではなく、サーバ自身であることがわかる。

初心に帰ってnetstatしてみる

image.png
smtpssmtpLISTENはしてるけど127.0.0.1でしか聞いてない…!?:thinking:

原因

/etc/postfix/main.cf
image.png
それはそうの舞:dancer::dancer:

感想

tcpdumpのくだり必要だった?

この記事を書いていたら3306番が開いているのに気付いた。調べたらMySQLってFirewallの設定に関係なくデフォルトで3306番をLISTENしているらしい。ちょっと怖い。

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4