firewall: configure NAT from NetBox data
This is dynamic NAT for (mostly) physical networks. NAT for custom prefixes can still be defined in the app.
This commit is contained in:
		
							parent
							
								
									457ab7d3b7
								
							
						
					
					
						commit
						8a9d47f176
					
				
					 1 changed files with 13 additions and 0 deletions
				
			
		|  | @ -108,12 +108,25 @@ table ip nat { | |||
|     map netmap-in { type ipv4_addr : interval ipv4_addr; flags interval; } | ||||
|     map netmap-out { type ipv4_addr : interval ipv4_addr; flags interval; } | ||||
| 
 | ||||
|     map nat { | ||||
|         type ipv4_addr : interval ipv4_addr; flags interval | ||||
|         elements = { | ||||
| {% for prefix in vrf_prefixes | selectattr('family.value', '==', 4) | selectattr('custom_fields.nat') %} | ||||
|             {{ prefix.prefix }} : {{ prefix.custom_fields.nat.address | ipmath(0) }} | ||||
|             {{- '' if loop.last else ',' }} # {{ prefix.vlan.name }} | ||||
| {% endfor %} | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     chain postrouting { | ||||
|         type nat hook postrouting priority srcnat | ||||
| 
 | ||||
|         iif @inside oif @outside snat ip prefix to ip saddr map @netmap-out \ | ||||
|         comment "Static source NAT for 1:1 mapped addresses" | ||||
| 
 | ||||
|         iif @inside oif @outside snat to ip saddr map @nat \ | ||||
|         comment "Dynamic NAT for private IPv4 networks" | ||||
| 
 | ||||
|         include "/etc/nftables.d/nat.nft*" | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue