Hands-on tutorial

Tutorials · Routing & Internet

How to Use Policy-Based Routing to Send Traffic Over Different Internet Links

Send VoIP and business apps over the fibre link, guests over the backup line, and keep failover working, with policy-based routing rules on the gateway.

Intermediate10 min6 steps

Before you start

  • A gateway with two WAN links
  • The subnets or VLANs of each user group
  • The addresses or ports of the applications you want to steer

Step by step

  1. Decide the policy

    Write it as plain rules first: staff VLAN uses WAN1, guest VLAN uses WAN2, VoIP to the provider's servers uses WAN1, backups at night use WAN2.

  2. Create one routing table per link

    Each WAN gets its own route table with its own default route, so rules can point at a table.

  3. Add rules from specific to general

    Rules are checked in order. Put application rules first, then per-VLAN rules, then the default.

    ip rule add from 192.168.50.0/24 table wan2 priority 100
    ip rule add to 203.0.113.10/32 table wan1 priority 90
    
  4. Keep failover

    Each rule must fall back to the other link if its link is down. Use the gateway's link monitoring so a dead link is removed from all tables.

  5. Handle NAT and return traffic

    Each link needs its own NAT. Sessions must leave and return on the same link, or remote servers will drop them.

  6. Test each rule

    From a client in each group, check the public IP address and run a traceroute. Then unplug one link and check that everything moves to the other.

    curl -s https://ifconfig.co
    traceroute 9.9.9.9
    

Commands are generic, industry-standard examples. Exact syntax and menu names vary by model and firmware; check your device's manual on the Documentation page.

Pro tips

  • Keep the rule list short and commented.
  • Steering by domain name is less reliable than by address or port, because cloud services change addresses.
  • Remember that VPN tunnels should follow the link they were built on.