Hey folks -
I'm in the process of converting a lot of my infrastructure at home to FreeBSD. Next on the list is my router, which has been running Linux for years. It's a simple Atom-based system with 3 Ethernet interfaces on it:
Anyway, I think I can easily create the bridge interface, and write the appropriate ipfw rules to match what I'm currently doing with my Linux router. My question centers around selective source NATing. Specifically: the third Ethernet interface services my private VLAN. I want to make sure that any packet FROM that LAN to my public VLAN isn't NATed. I also want to make sure the public VLAN can route natively to the private VLAN without being DNATed. The only time I want packets NATed is if they originate from the private VLAN and exit the Ethernet interface facing the ONT.
The rule I use with Linux's IPTables to accomplish this is:
The important bits:
I'm in the process of converting a lot of my infrastructure at home to FreeBSD. Next on the list is my router, which has been running Linux for years. It's a simple Atom-based system with 3 Ethernet interfaces on it:
- Connected to the Verizon FIOS ONT
- Connected to public VLAN
- Connected to private VLAN
Anyway, I think I can easily create the bridge interface, and write the appropriate ipfw rules to match what I'm currently doing with my Linux router. My question centers around selective source NATing. Specifically: the third Ethernet interface services my private VLAN. I want to make sure that any packet FROM that LAN to my public VLAN isn't NATed. I also want to make sure the public VLAN can route natively to the private VLAN without being DNATed. The only time I want packets NATed is if they originate from the private VLAN and exit the Ethernet interface facing the ONT.
The rule I use with Linux's IPTables to accomplish this is:
Code:
-t nat -A POSTROUTING -m iprange -s [private VLAN IP block] ! --dst-range [IP Range clipped] -o br0 -j SNAT --to [IP clipped]
The important bits:
- The public IP range - VZ is dumb in that they don't use CIDR blocks but just a range (of almost-CIDR-blocks... idiots). So I can't do real CIDR notation there. That's fine because ipfw supports ranges. I assume ipnat does as well?
- The NAT IP - I specifically NAT all of the outbound traffic to a certain IP, not to my router's public IP. Is that doable with ipnat?
- ! - This tells iptables to not NAT for anything in that --dst-range. I looked around for examples of ipnat, and I didn't see anything about a negating operator. Might there be some other way to accomplish this?