In a MultiWAN configuration, FreshTomato can make use of multiple Internet connections simultaneously. It is also possible to make a service hosted on the local network accessible from the Internet through multiple WAN interfaces, using a single FQDN (Fully Qualified Domain Name).
This can be achieved by combining Dynamic DNS (DDNS) with DNS round-robin.
Normally, a DDNS hostname is associated with a single IP address. Whenever the WAN IP address changes, FreshTomato updates the corresponding DNS record at the DDNS provider.
Some DDNS providers, however, allow multiple A records to share the same hostname while pointing to different IP addresses.
By configuring an independent DDNS update for each WAN interface, multiple dynamic IP addresses can be associated with the same FQDN.
For example:
| FQDN | WAN interface | Public IP address |
|---|---|---|
| server.example.com | WAN0 | 203.0.113.10 |
| server.example.com | WAN1 | 198.51.100.20 |
When an Internet client resolves server.example.com, both IP addresses can be returned by the DNS provider. The client can then establish a connection using either IP address.
This technique is commonly referred to as DNS round-robin or DNS-based load sharing.
Although this example makes use of two WAN interfaces, the technique is not limited to two WANs. Additional WAN interfaces can participate, provided that the DDNS provider supports the corresponding number of independently updated A records and the FreshTomato build supports the required DDNS configurations.
Not all DDNS providers support this configuration.
The DDNS provider must support:
Providers offering relevant functionality include:
Compatibility may depend on the subscription, update protocol and implementation of the DDNS client.
FreeDNS is particularly suitable for this purpose because each DNS record can be updated using its own unique update token (hash), rather than using only the hostname as the record identifier.
Refer to the FreeDNS FAQ for further details.
The following example makes use of FreeDNS and two WAN interfaces.
On the DDNS provider's website:
Next, in the /Basic/DDNS menu:
Each WAN interface will now independently update its corresponding A record whenever its public IP address changes.
The hostname remains the same regardless of which WAN IP address is updated.
An Internet client contacting the FQDN in question will now be served a random IP from the ones you linked to it on your DDNS provider account configuration.
DDNS only provides name resolution. It does not automatically make a service accessible through all WAN interfaces.
If a service is hosted on a device connected to the LAN, the relevant port must be forwarded on every participating WAN interface.
Depending on the FreshTomato version and configuration, the standard /Port Forwarding/Basic menu may not provide the required MultiWAN port forwarding functionality.
Additional port forwarding rules can be implemented using a Firewall script.
In this example:
To additionally forward incoming TCP port 80 traffic on WAN1, add the following commands to the Firewall field in the /Administration/Scripts menu:
For the sake of this example we'll assume WAN1 is server via vlan3 and we have a webserver on the LAN reponding to port TCP 80.
iptables -t nat -I PREROUTING -i vlan3 -p tcp --dport 80 -j DNAT --to-destination 192.168.1.100:80 iptables -I FORWARD -i vlan3 -p tcp -d 192.168.1.100 --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
The first command redirects incoming TCP port 80 traffic on vlan3 to the internal web server.
The second command allows the corresponding traffic to pass through the firewall.
Adjust the interface name, destination IP address and port number according to your configuration.
Note that vlan3 is used here as an example. The actual WAN interface name may differ depending on the hardware, VLAN configuration and WAN connection type (e.g. PPPoE).
Additional rules can be added for other WAN interfaces and/or services as required.
Return traffic must leave through the same WAN interface through which the connection was originally established. Verify that the existing MultiWAN routing configuration handles this correctly.
Refer to the /Advanced/MultiWAN Routing menu for further information.
Important: Port forwarding exposes the destination service to the Internet. Ensure that the service is appropriately secured. HTTPS is recommended for web services.
From a computer, resolve the configured FQDN using a DNS lookup tool.
For example:
nslookup server.example.com
The result should contain the public IP addresses associated with the participating WAN interfaces.
Next, from a device outside the local network, verify that the service is accessible independently through each WAN IP address.
For example:
curl --resolve server.example.com:80:203.0.113.10 http://server.example.com/ curl --resolve server.example.com:80:198.51.100.20 http://server.example.com/
Testing from outside the local network avoids potential complications associated with NAT loopback.
Also verify that a change to the IP address of one WAN updates only its corresponding DNS record.
Automatic DNS-based failover would require an additional mechanism capable of detecting WAN unavailability and removing or replacing the corresponding DNS record.
Standard DDNS updates and DNS round-robin alone do not provide this functionality.