7 firewallのインストールと設定

firewallのインストールと設定

注意

  • Raspbianのプロンプトは、$
  • キー入力の文字は、緑色
  • sshのポート番号は、55522
  • ホームページ閲覧のポート番号は、80
  • メール送信のポート番号は、587
  1. firewallのインストール
    firewallは、ネットワークのデータ転送で必要なポート番号だけ開け、不要なポート番号は全て閉じることで、セキュリティを向上させる機能です。インストールは、以下のように行います。
    $ sudo apt-get install ufw
  2. firewallの設定
    firewallは、インストールしただけでは機能していません。設定は以下のように行います。
    $ sudo ufw default DENY
    $ sudo ufw allow 55522
    $ sudo ufw allow 80
    $ sudo ufw allow 587
    $ sudo ufw enable
    ・・・
    Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
    Firewall is active and enabled on system startup
  3. firewallの設定確認
    $ sudo reboot
    ・・・
    再起動後
    sudo ufw status
    Status: activeTo Action From
    — —— —-
    55522 ALLOW Anywhere
    80 ALLOW Anywhere
    587 ALLOW Anywhere
    55522 (v6) ALLOW Anywhere (v6)
    80 (v6) ALLOW Anywhere (v6)
    587 (v6) ALLOW Anywhere (v6)上記のようにStatusがactiveになっていて、80、587、55522のポート番号がALLOWになっていればOK。$ sudo iptables -L
    ・・・
    Chain ufw-user-input (1 references)
    target prot opt source destination
    ACCEPT tcp — anywhere anywhere tcp dpt:55522
    ACCEPT udp — anywhere anywhere udp dpt:55522
    ACCEPT tcp — anywhere anywhere tcp dpt:http
    ACCEPT udp — anywhere anywhere udp dpt:80
    ACCEPT tcp — anywhere anywhere tcp dpt:submission
    ACCEPT udp — anywhere anywhere udp dpt:587
    ・・・
    上記のように80、587、55522のポート番号がACCEPTになっていればOK。