大网数据广告活动
服务器运维问答

How to apply proxmox firewall rules to VMs?

· 52CE 我爱测

This is my current scenario: I have a proxmox server in the cloud. I installed 2 VMs, that have different IPs (not on the same subnet as the main proxmox server — see THIS to understand why). On the proxmox machine itself, I have…

问题原文

原帖链接 · Aaron Ullal · CC BY-SA 4.0

This is my current scenario:

I have a proxmox server in the cloud. I installed 2 VMs, that have different IPs (not on the same subnet as the main proxmox server — see THIS to understand why).

On the proxmox machine itself, I have setup a list of iptables rules that work perfectly.

# Allow localhostinterface
/sbin/iptables -A INPUT -i lo -j ACCEPT

#icmp
/sbin/iptables -A INPUT -p ICMP -j ACCEPT

#home network
/sbin/iptables -A INPUT -s xx.xx.xx.xx -j ACCEPT

# Allow already established connections
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

# Set default policies
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT ACCEPT

#LOG IPTABLES
/sbin/iptables -N LOGGING
/sbin/iptables -A INPUT -j LOGGING
/sbin/iptables -A LOGGING -m limit --limit 2/min -j LOG --log-prefix "IPTables-Dropped: " --log-level 4
/sbin/iptables -A LOGGING -j DROP

However, for some reason, these rules do not apply to the virtual machines, which are out in the wild with no security at all. Is there a way to apply the same rules valid on the proxmox server to the vms?

已采纳解答

原帖链接 · Tim · CC BY-SA 3.0

I had exactly the same problem this morning, then I also found your question.

According to this documentation, we can only set VM-wide rules using a PVE firewall, by creating a Security Group with global rules for all machines, then adding it to every VM on the node. This way, once the security group is modified, changes will affect all VMs that use it.

I find it a little bit inconvenient, because I think any rules defined in /etc/pve/nodes/<nodename>/host.fw should affect its VM's as well, since there is already an existing overlaying zone called 'Datacenter' (or 'cluster', since rules in /etc/pve/firewall/cluster.fw appear exactly in the GUI's Datacenter section) and I also suspect that it's an architectural issue, that will be fixed/changed in the near future.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-09-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0 / CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。