Loading custom iptables rule on startup with post-up fails

martin2089

Member
May 8, 2021
8
2
8
Hello everyone

I have a custom firewall rule for a few VMs that I can't enter in the GUI.
The most elegant way would be to load it directly at startup by "post-up" in the /etc/network/interfaces file.

The rule looks like this:
ip6tables --insert tap181i0-IN -m mac ! --mac-source 06:45:0c:4e:93:9a -j DROP

Unfortunately, I get the following message at startup: (journalctl -b | grep vmbr4)

Code:
Feb 06 08:12:16 he01-pve networking[1565]: warning: vmbr4: post-up cmd '/usr/sbin/ip6tables --insert tap181i0-IN -m mac ! --mac-source 06:45:0c:4e:93:9a -j DROP' failed: returned 1 (ip6tables: No chain/target/match by that name.

It looks like no rule chain is created by Proxmox when the network is loaded, so of course the command fails.
Reloading the Interfaces later with ifreload -a does apply the rule.

How do you handle such special rules? Theoretically, it would be enough to apply the rule when the VM is starting.
 
For the sake of completeness:
I have switched to passing the rules of the relevant VMs via hook script.
The rule is transferred in the "post-start" phase.
It's just a pity that hook scripts cannot be submitted via GUI. At least they are displayed...
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!