Skip to content

Commit

Permalink
randomize source ports during masquerading (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwennrich authored May 2, 2024
1 parent f2edbfc commit fac1b8a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pkg/netconf/testdata/nftrules
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ table inet nat {
}
chain postrouting {
type nat hook postrouting priority 0; policy accept;
oifname "vlan104009" ip saddr 10.0.16.0/22 counter masquerade comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan104010" ip saddr 10.0.16.0/22 counter masquerade comment "snat (networkid: mpls-nbg-w8101-test)"
oifname "vlan104009" ip saddr 10.0.16.0/22 counter masquerade random comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan104010" ip saddr 10.0.16.0/22 counter masquerade random comment "snat (networkid: mpls-nbg-w8101-test)"
}
}
4 changes: 2 additions & 2 deletions pkg/netconf/testdata/nftrules_accept_forwarding
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ table inet nat {
}
chain postrouting {
type nat hook postrouting priority 0; policy accept;
oifname "vlan104009" ip saddr 10.0.16.0/22 counter masquerade comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan104010" ip saddr 10.0.16.0/22 counter masquerade comment "snat (networkid: mpls-nbg-w8101-test)"
oifname "vlan104009" ip saddr 10.0.16.0/22 counter masquerade random comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan104010" ip saddr 10.0.16.0/22 counter masquerade random comment "snat (networkid: mpls-nbg-w8101-test)"
}
}
4 changes: 2 additions & 2 deletions pkg/netconf/testdata/nftrules_dmz
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ table inet nat {
}
chain postrouting {
type nat hook postrouting priority 0; policy accept;
oifname "vlan104009" ip saddr 10.0.16.0/22 ip daddr != 185.1.2.3 counter masquerade comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan104009" ip saddr 10.0.20.0/22 ip daddr != 185.1.2.3 counter masquerade comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan104009" ip saddr 10.0.16.0/22 ip daddr != 185.1.2.3 counter masquerade random comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan104009" ip saddr 10.0.20.0/22 ip daddr != 185.1.2.3 counter masquerade random comment "snat (networkid: internet-vagrant-lab)"
}
}
4 changes: 2 additions & 2 deletions pkg/netconf/testdata/nftrules_ipv6
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ table inet nat {
}
chain postrouting {
type nat hook postrouting priority 0; policy accept;
oifname "vlan104009" ip6 saddr 2002::/64 ip6 daddr != 2a02:c00:20::1 counter masquerade comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan104010" ip6 saddr 2002::/64 counter masquerade comment "snat (networkid: mpls-nbg-w8101-test)"
oifname "vlan104009" ip6 saddr 2002::/64 ip6 daddr != 2a02:c00:20::1 counter masquerade random comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan104010" ip6 saddr 2002::/64 counter masquerade random comment "snat (networkid: mpls-nbg-w8101-test)"
}
}
4 changes: 2 additions & 2 deletions pkg/netconf/testdata/nftrules_shared
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ table inet nat {
}
chain postrouting {
type nat hook postrouting priority 0; policy accept;
oifname "vlan3982" ip saddr 10.0.18.0/22 counter masquerade comment "snat (networkid: storage-net)"
oifname "vlan104009" ip saddr 10.0.18.0/22 ip daddr != 185.1.2.3 counter masquerade comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan3982" ip saddr 10.0.18.0/22 counter masquerade random comment "snat (networkid: storage-net)"
oifname "vlan104009" ip saddr 10.0.18.0/22 ip daddr != 185.1.2.3 counter masquerade random comment "snat (networkid: internet-vagrant-lab)"
}
}
4 changes: 2 additions & 2 deletions pkg/netconf/testdata/nftrules_vpn
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ table inet nat {
}
chain postrouting {
type nat hook postrouting priority 0; policy accept;
oifname "vlan104009" ip saddr 10.0.16.0/22 counter masquerade comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan104010" ip saddr 10.0.16.0/22 counter masquerade comment "snat (networkid: mpls-nbg-w8101-test)"
oifname "vlan104009" ip saddr 10.0.16.0/22 counter masquerade random comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan104010" ip saddr 10.0.16.0/22 counter masquerade random comment "snat (networkid: mpls-nbg-w8101-test)"
}
}
4 changes: 2 additions & 2 deletions pkg/netconf/testdata/nftrules_with_rules
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ table inet nat {
}
chain postrouting {
type nat hook postrouting priority 0; policy accept;
oifname "vlan104009" ip saddr 10.0.16.0/22 counter masquerade comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan104010" ip saddr 10.0.16.0/22 counter masquerade comment "snat (networkid: mpls-nbg-w8101-test)"
oifname "vlan104009" ip saddr 10.0.16.0/22 counter masquerade random comment "snat (networkid: internet-vagrant-lab)"
oifname "vlan104010" ip saddr 10.0.16.0/22 counter masquerade random comment "snat (networkid: mpls-nbg-w8101-test)"
}
}
4 changes: 2 additions & 2 deletions pkg/netconf/tpl/nftrules.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ table inet nat {
{{- $outspec:=.OutIntSpec }}
{{- range .SourceSpecs }}
{{- if and $outspec.Address (eq $outspec.AddressFamily .AddressFamily) }}
oifname "{{ $out }}" {{ .AddressFamily }} saddr {{ .Address }} {{ .AddressFamily }} daddr != {{ $outspec.Address }} counter masquerade comment "{{ $cmt }}"{{ else }}
oifname "{{ $out }}" {{ .AddressFamily }} saddr {{ .Address }} counter masquerade comment "{{ $cmt }}"
oifname "{{ $out }}" {{ .AddressFamily }} saddr {{ .Address }} {{ .AddressFamily }} daddr != {{ $outspec.Address }} counter masquerade random comment "{{ $cmt }}"{{ else }}
oifname "{{ $out }}" {{ .AddressFamily }} saddr {{ .Address }} counter masquerade random comment "{{ $cmt }}"
{{- end }}
{{- end }}
{{- end }}
Expand Down

0 comments on commit fac1b8a

Please sign in to comment.