在 Ubuntu 中,iptables 是一個用于配置 Linux 內核防火墻的命令行工具。要設置用戶權限,您需要將用戶添加到 iptables 組,以便他們可以執行 iptables 命令。請按照以下步驟操作:
iptables 的新組(如果尚不存在):sudo groupadd iptables
iptables 組:sudo usermod -aG iptables <username>
將 <username> 替換為您要添加的用戶的用戶名。
為了讓更改生效,用戶需要注銷并重新登錄。這樣,他們就可以使用 iptables 命令了。
要測試用戶是否具有適當的權限,請切換到該用戶并嘗試運行 iptables 命令。例如:
sudo -i -u <username>
iptables -L
如果一切正常,您應該能夠看到 iptables 規則列表。
請注意,使用 iptables 需要 root 權限,因此請確保您在操作過程中謹慎行事,以免意外阻止自己的訪問或導致系統安全問題。