UFW(Uncomplicated Firewall)
GT110bでもファイアーウォールはnx9030からの(つまりCentOSの)/etc/iptables.rulesな設定を引きずってきたが、ようやくubuntuの流儀に従ってUFW(Uncomplicated Firewall)ベースの設定で整理した。
基本的には入側DENY/出側ALLOWにdefault設定し、入側の許可ルールを「sudo ufw allow ~」で追加していくだけで、sshやdomainなど/etc/servicesに定義済みのポートについてはその定義名を、その他のサービスやアプリケーション毎の設定については/etc/ufw/applications.d/配下に定義して「sudo ufw app list」で表示される識別子を指定すれば良い。
さくらのVPSで解放する必要があるのはDNSとWebとsshとメールだけ。 まずは/etc/ufw/applications.d/postfixにsmtpsの定義を追加し、
[Postfix]あとは、以下の様な感じで。
title=Mail server (SMTP)
description=Postfix is a high-performance mail transport agent
ports=25/tcp
[Postfix Submission]
title=Mail server (Submission)
description=Postfix is a high-performance mail transport agent
ports=587/tcp
[Postfix Secure]
title=Mail server (SSL)
description=Postfix is a high-performance mail transport agent
ports=465/tcp
yano@sakura_vps:~$ sudo ufw status
状態: 非アクティブ
yano@sakura_vps:~$ sudo ufw default DENY incoming
Default incoming policy changed to 'deny'
(適用したい内容に基づいて必ずルールを更新してください)
yano@sakura_vps:~$ sudo ufw default ALLOW outgoing
Default outgoing policy changed to 'allow'
(適用したい内容に基づいて必ずルールを更新してください)
yano@sakura_vps:~$ sudo ufw app list
存在するアプリケーション:
Apache
Apache Full
Apache Secure
Dovecot IMAP
Dovecot POP3
Dovecot Secure IMAP
Dovecot Secure POP3
OpenSSH
Postfix
Postfix Submission
Postfix Secure
yano@sakura_vps:~$ sudo ufw allow ssh
ルールをアップデートしました
yano@sakura_vps:~$ sudo ufw allow domain
ルールをアップデートしました
yano@sakura_vps:~$ sudo ufw allow "Postfix"
ルールをアップデートしました
yano@sakura_vps:~$ sudo ufw allow "Postfix Submission"
ルールをアップデートしました
yano@sakura_vps:~$ sudo ufw allow "Postfix Secure"
ルールをアップデートしました
yano@sakura_vps:~$ sudo ufw allow "Dovecot POP3"
ルールをアップデートしました
yano@sakura_vps:~$ sudo ufw allow "Dovecot Secure POP3"
ルールをアップデートしました
yano@sakura_vps:~$ sudo ufw allow "Apache Full"
ルールをアップデートしました
yano@sakura_vps:~$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
ファイアウォールはアクティブかつシステムの起動時に有効化されます。
yano@sakura_vps:~$ sudo ufw status
状態: アクティブ
To Action From
-- ------ ----
22 ALLOW Anywhere
53 ALLOW Anywhere
Postfix ALLOW Anywhere
Postfix Submission ALLOW Anywhere
Postfix Secure ALLOW Anywhere
Dovecot POP3 ALLOW Anywhere
Dovecot Secure POP3 ALLOW Anywhere
Apache Full ALLOW Anywhere
yano@sakura_vps:~$