以下の内容はhttps://souiunogaii.hatenablog.com/entry/proxmox9-ufw-firewallより取得しました。


Proxmox9.0の初期設定(その4)ファイアウォールの設定

※[PR]当ブログの記事の中にはプロモーションが含まれています。

・Proxmox9.0のファイアウォールを設定する手順を知りたい。
・具体的な手順を分かりやすく教えてほしい。

こういった疑問に答えます。

本記事の内容

  1. Proxmox9.0のファイアウォールの設定

サトナカ (@souiunogaii)

この記事を書いている私は、某SIerに勤務しながら、
WEB系エンジニア・インフラエンジニアに憧れて、プログラミングおよびインフラ技術の勉強をしています。

こういった私が、解説していきます。

私が実機で試したコマンドや画像を載せて書いています。
記事の信頼性担保に繋がると思います。

Proxmox9.0の初期設定(その4)ファイアウォールの設定

手順① pve-firewallを無効化

systemctl stop pve-firewall
systemctl disable pve-firewall
systemctl mask pve-firewall
root@a-prxmx01:~# systemctl stop pve-firewall
root@a-prxmx01:~# systemctl disable pve-firewall
Removed '/etc/systemd/system/multi-user.target.wants/pve-firewall.service'.
root@a-prxmx01:~# systemctl mask pve-firewall
Created symlink '/etc/systemd/system/pve-firewall.service''/dev/null'.
root@a-prxmx01:~# systemctl status pve-firewall
○ pve-firewall.service
     Loaded: masked (Reason: Unit pve-firewall.service is masked.)
     Active: inactive (dead) since Mon 2025-08-25 22:28:14 JST; 24s ago
   Duration: 1h 31min 22.762s
 Invocation: ce4887909b8547d2a2b0f71ba2de7a9c
   Main PID: 1027 (code=exited, status=0/SUCCESS)
   Mem peak: 204.9M
        CPU: 34.287s

 825 20:56:50 a-prxmx01 pve-firewall[1027]: starting server
 825 20:56:50 a-prxmx01 systemd[1]: Started pve-firewall.service - Proxmox VE firewall.
 825 22:28:12 a-prxmx01 systemd[1]: Stopping pve-firewall.service - Proxmox VE firewall...
 825 22:28:13 a-prxmx01 pve-firewall[1027]: received signal TERM
 825 22:28:13 a-prxmx01 pve-firewall[1027]: server shutting down
 825 22:28:13 a-prxmx01 pve-firewall[1027]: clear PVE-generated firewall rules
 825 22:28:13 a-prxmx01 pve-firewall[1027]: server stopped
 825 22:28:14 a-prxmx01 systemd[1]: pve-firewall.service: Deactivated successfully.
 825 22:28:14 a-prxmx01 systemd[1]: Stopped pve-firewall.service - Proxmox VE firewall.
 825 22:28:14 a-prxmx01 systemd[1]: pve-firewall.service: Consumed 34.287s CPU time, 204.9M memo>
lines 1-19/19 (END)

手順② ufwをインストール

apt install ufw
root@a-prxmx01:~# apt install ufw
Installing:
  ufw

提案パッケージ:
  rsyslog

Summary:
  Upgrading: 0, Installing: 1, Removing: 0, Not Upgrading: 0
  Download size: 169 kB
  Space needed: 880 kB / 92.1 GB available

取得:1 http://deb.debian.org/debian trixie/main amd64 ufw all 0.36.2-9 [169 kB]
169 kB を 0秒 で取得しました (2,841 kB/s)
パッケージを事前設定しています ...
以前に未選択のパッケージ ufw を選択しています。
(データベースを読み込んでいます ... 現在 51562 個のファイルとディレクトリがインストールされています 。)
.../archives/ufw_0.36.2-9_all.deb を展開する準備をしています ...
ufw (0.36.2-9) を展開しています...
ufw (0.36.2-9) を設定しています ...
Creating config file /etc/ufw/before.rules with new version
Creating config file /etc/ufw/before6.rules with new version
Creating config file /etc/ufw/after.rules with new version
Creating config file /etc/ufw/after6.rules with new version
Created symlink '/etc/systemd/system/multi-user.target.wants/ufw.service''/usr/lib/systemd/system/ufw.service'.
man-db (2.13.1-1) のトリガを処理しています ...

インストール後のufwのステータス確認

ufw status
root@a-prxmx01:~# ufw status
Status: inactive

ルールに使えるアプリケーション名の表示

ufw app list
root@a-prxmx01:~# ufw app list
Available applications:
  AIM
  Bonjour
  CIFS
  DNS
  Deluge
  IMAP
  IMAPS
  IPP
  KTorrent
  Kerberos Admin
  Kerberos Full
  Kerberos KDC
  Kerberos Password
  LDAP
  LDAPS
  LPD
  MSN
  MSN SSL
  Mail submission
  NFS
  OpenSSH
  POP3
  POP3S
  PeopleNearby
  Postfix
  Postfix SMTPS
  Postfix Submission
  SMTP
  SSH
  Socks
  Telnet
  Transmission
  Transparent Proxy
  VNC
  WWW
  WWW Cache
  WWW Full
  WWW Secure
  XMPP
  Yahoo
  qBittorrent
  svnserve

手順③ ufwのルール設定

ローカルネットワークからのSSH接続を許可

root@a-prxmx01:~# ufw allow from 192.168.100.0/24 to any port ssh
Rules updated

管理PCからコンソール画面への接続を許可

root@a-prxmx01:~# ufw allow from 192.168.100.101/32 to any port 8006
Rules updated

デフォルトでINは全て拒否,OUTは全て許可

root@a-prxmx01:~# ufw default deny incoming
Default incoming policy changed to 'deny'
(be sure to update your rules accordingly)
root@a-prxmx01:~# ufw default allow outgoing
Default outgoing policy changed to 'allow'
(be sure to update your rules accordingly)

ログ出力レベルを設定

root@a-prxmx01:~# ufw logging medium
Logging enabled

手順④ ufwを有効化

root@a-prxmx01:~# ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup

設定したルール番号の表示確認

root@a-prxmx01:~# ufw status numbered
Status: active

     To                         Action      From
     --                         ------      ----
[ 1] 22/tcp                     ALLOW IN    192.168.100.0/24
[ 2] 8006                       ALLOW IN    192.168.100.101



以上の内容はhttps://souiunogaii.hatenablog.com/entry/proxmox9-ufw-firewallより取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14