Network Address Translation (NAT) is a fundamental feature in pfSense that allows private networks to communicate with the internet using a single public IP address. This section will guide you through the basic steps of configuring NAT in pfSense.
Understanding NAT:
- Purpose: NAT translates private IP addresses into public IP addresses, enabling multiple devices on a private network to share a single public IP address.
- Types of NAT: There are three main types of NAT: static, dynamic, and port address translation (PAT).
- Static NAT: In static NAT, a specific private IP address is always translated to a specific public IP address.
- Dynamic NAT: In dynamic NAT, private IP addresses are randomly translated to available public IP addresses.
- PAT: PAT allows multiple private IP addresses to be translated to the same public IP address using different port numbers.
Configuring Basic NAT:
- Access the NAT Rules Page: Navigate to the “Firewall” section and select the “NAT” submenu.
- Create a New Rule: Click the “Add” button to create a new NAT rule.
- Select the NAT Type: Choose the appropriate NAT type based on your requirements (static, dynamic, or PAT).
- Configure Source and Destination: Specify the source and destination IP addresses or networks for the NAT rule.
- Set Interface: Select the interface through which the traffic will be translated.
- Specify External IP: If using static or dynamic NAT, specify the external (public) IP address.
- Configure Port Mappings (for PAT): If using PAT, configure port mappings to associate specific private ports with public ports.
- Save the Rule: Click the “Save” button to apply the NAT rule.
Example: Basic NAT for a Home Network:
To allow devices on a home network to access the internet, you can configure a dynamic NAT rule:
- Source: 192.168.1.0/24 (private network)
- Destination: Any
- Interface: wan
- NAT Type: Dynamic
- External IP: Your public IP address
This rule will automatically translate private IP addresses in the 192.168.1.0/24 network to your public IP address, allowing devices on the network to access the internet.
Additional Considerations:
- NAT Reflection: If you need to allow external traffic to reach specific services on your private network, you may need to configure NAT reflection.
- Port Forwarding: To allow specific external ports to be forwarded to internal services, use port forwarding rules.
- NAT Traversal: For applications that require direct communication between devices on different networks, you may need to configure NAT traversal techniques.