【メールサーバ】メール利用のポート開放

  • ポート開放
    ルーターの設定で25番ポート(SMTP用)と
    110番ポート(POP用)または143番ポート(IMAP用)を開放し、
    iptablesでも上記ポートを開放します。

    iptables -L --line-numbers
    
    Chain INPUT (policy ACCEPT)
    num  target     prot opt source    destination
    1    ACCEPT     all  --  anywhere  anywhere     state RELATED,ESTABLISHED
    2    ACCEPT     icmp --  anywhere  anywhere
    3    ACCEPT     tcp  --  anywhere  anywhere     state NEW tcp dpt:ssh
    4    ACCEPT     tcp  --  anywhere  anywhere     tcp dpt:http
    5    ACCEPT     tcp  --  anywhere  anywhere     tcp dpt:https
    6    REJECT     all  --  anywhere  anywhere     reject-with icmp-host-prohibited
    

    5番目と6番目の間にメール用のポートを設定します。

    iptables -I INPUT 6 -p tcp -m tcp --dport 25 -j ACCEPT
    iptables -I INPUT 7 -p tcp -m tcp --dport 110 -j ACCEPT
    service iptables save
    
    iptables -L --line-numbers
    
    Chain INPUT (policy ACCEPT)
    num  target     prot opt source    destination
    1    ACCEPT     all  --  anywhere  anywhere     state RELATED,ESTABLISHED
    2    ACCEPT     icmp --  anywhere  anywhere
    3    ACCEPT     tcp  --  anywhere  anywhere     state NEW tcp dpt:ssh
    4    ACCEPT     tcp  --  anywhere  anywhere     tcp dpt:http
    5    ACCEPT     tcp  --  anywhere  anywhere     tcp dpt:https
    6    ACCEPT     tcp  --  anywhere  anywhere     tcp dpt:smtp
    7    ACCEPT     tcp  --  anywhere  anywhere     tcp dpt:pop3
    8    REJECT     all  --  anywhere  anywhere     reject-with icmp-host-prohibited
    

    下記サイトでポートの開放を確認します。
    http://www.cman.jp/network/support/port.html