diff --git a/bundles/wireguard/metadata.py b/bundles/wireguard/metadata.py index 573aa4e..35067d2 100644 --- a/bundles/wireguard/metadata.py +++ b/bundles/wireguard/metadata.py @@ -221,12 +221,11 @@ def snat(metadata): if not node.has_bundle('nftables') or node.os == 'arch': raise DoNotRunAgain - rules = { - 'inet filter forward iif wg0 accept', - 'inet filter forward oif wg0 accept', - } + rules = set() + for number, (peer, config) in enumerate(sorted(metadata.get('wireguard/peers', {}).items())): + rules.add(f'inet filter forward iif wg{number} accept') + rules.add(f'inet filter forward oif wg{number} accept') - for config in metadata.get('wireguard/peers', {}).values(): if 'snat_to' in config: rules.add('nat postrouting ip saddr {} ip daddr != {} snat to {}'.format( config['my_ip'],