Prerequisites and Network Identification
Before modifying router settings, you need two critical pieces of information from your TrueNAS Scale system: the local IP address and the specific ports you wish to expose. It is essential that your TrueNAS server has a static local IP address assigned via its network configuration. If the IP changes due to DHCP renewal, your port forwarding rules will break, resulting in lost connectivity. Navigate to Network in the TrueNAS web UI, then select Interfaces. Locate your active interface (typicallyeth0 or similar) and ensure the IPv4 address is set statically rather than via DHCP. Note this IP address down. Additionally, determine which services require remote access. Common examples include port 445 for SMB file sharing, port 22 for SSH, or port 80/443 if you are exposing the TrueNAS web interface directly, though exposing the web UI externally is generally discouraged for security reasons.
Configuring Router Port Forwarding
Access your router’s administrative panel by entering its gateway IP address into a web browser. The exact steps vary by manufacturer, but the logic remains consistent across most consumer-grade routers. Look for a section labeled Port Forwarding, NAT, Virtual Server, or Applications & Gaming. Create a new service entry with the following parameters:- Service Name: A descriptive label such as "TrueNAS-SMB" or "TrueNAS-SSH".
- External Port: The port number your ISP or remote client expects. For example, use
445for standard SMB. - Internal Port: Usually the same as the external port, unless you are mapping an external port to a different internal one.
- Protocol: Select TCP, UDP, or BOTH. SMB typically requires TCP, while some discovery protocols may need UDP.
- Local IP Address: Enter the static IP address of your TrueNAS Scale server identified earlier.
Verifying External Connectivity
Once the rule is saved, you need to verify that the port is actually open to the internet. Do not rely solely on pinging the public IP, as many ISPs block ICMP traffic. Instead, use online port checking tools or command-line utilities from an external network (not your home network). From a device outside your home network, run a test against your public IP address. For Linux or macOS users, thenc (netcat) command is effective:
nc -zv [Your_Public_IP] [Port_Number]
If the connection succeeds, you will see a message indicating the port is open. If it times out or refuses, the firewall or router rule is still blocking traffic. You can also check your router’s status page to see if the port forward rule is listed as active.
It is crucial to understand that your public IP address may change if your ISP uses dynamic addressing. Most modern routers support Dynamic DNS (DDNS) services. Configure DDNS in your router to automatically update a hostname (e.g., mynas.ddns.net) whenever your IP changes. This allows you to connect using a domain name instead of remembering numerical IP addresses.
For users behind Carrier-Grade NAT (CGNAT), typical port forwarding will not work because you do not have a unique public IP. In such cases, you cannot simply forward ports on the router. You must explore alternative methods such as VPN tunnels or specialized tunneling services. See our guide on How to Open Ports (TCP/UDP) Behind CGNAT 5G Router for solutions applicable to mobile hotspots or fiber connections that hide your IP behind a shared network.
Security Best Practices
Exposing services to the internet increases your attack surface. Never expose unnecessary ports. If you only need file sharing, do not open SSH (port 22) or the web interface (port 80/443) unless absolutely necessary. Use strong, complex passwords for all accounts on TrueNAS. Consider changing the external port to a non-standard high-numbered port (e.g., mapping external port 2222 to internal port 22) to reduce automated bot scans, although this is not true security through obscurity. Always keep your TrueNAS Scale system updated to the latest version to patch known vulnerabilities. Enable Two-Factor Authentication (2FA) for any exposed services that support it, such as SSH or specific applications running on the NAS. Regularly monitor the TrueNAS logs for suspicious login attempts or unusual network activity.Troubleshooting Connection Issues
If you have configured port forwarding correctly but still cannot connect from outside, check the following:- Firewall Rules: Ensure TrueNAS itself is not blocking incoming connections. Check the Firewall section in the TrueNAS UI to confirm that inbound traffic on the specified ports is allowed.
- ISP Blocking: Some residential ISPs block common ports like 80, 443, or 25. Try using alternative ports if you encounter timeouts.
- Double NAT: If you have multiple routers (e.g., modem/router combo plus a secondary router), you must configure port forwarding on both devices, or set the secondary router to Bridge Mode.
Frequently Asked Questions
Can I expose the TrueNAS web interface to the internet?
While technically possible, it is strongly discouraged due to significant security risks. Exposing the web UI invites brute-force attacks and potential exploitation of web server vulnerabilities. Instead, use a VPN or SSH tunneling to access the management interface securely.
What should I do if my ISP blocks port 80 and 443?
If your ISP blocks standard web ports, you can map external traffic on a different high-numbered port (like 8080 or 8443) to the internal TrueNAS ports. You will need to specify the port number when accessing the site remotely, such as http://your-ip:8080.
Does TrueNAS Scale have a built-in firewall?
Yes, TrueNAS Scale includes a firewall feature accessible from the web UI. Ensure that your inbound rules allow traffic on the ports you have forwarded. By default, TrueNAS may deny incoming connections that are not explicitly permitted, so check these rules if external access fails.
How do I find my public IP address?
You can find your public IP by visiting a site like whatismyipaddress.com from any device connected to your home network. Alternatively, check the WAN status page in your router’s administration panel. This IP is what you will use in your port forwarding rules and when connecting remotely.
Is port forwarding safe for SMB file sharing?
Directly exposing SMB (port 445) to the internet is risky due to historical vulnerabilities in the SMB protocol. It is safer to use SFTP over SSH (port 22) or a dedicated VPN solution like WireGuard or OpenVPN, which encrypts the traffic and authenticates the client before granting access to the file shares.