Allow UDP traffic only via specific wan

Hello Friends,

It's been a long time since I am stuck with my requirement. Will be more satisfied with anyone's support.

I am having more than 1 WAN in my OpenWRT device, the thing is I need to allow UDP traffic to be routed only via a specific WAN which I decide.

I've used PBR for this requirement, but unfortunately, it won't well for UDP seems.
Is there any other possible to aceuve my requirement.(by iptables rule or anything else)?.

  1. mwan3 package
  2. a set of rules/routes

If Possible can you please post any example configuration?

In mwan3 it's self explanatory. To make a rule you'd have to mark the interesting traffic with iptables rule.

1 Like

Hi @trendy
As per your suggestion, I've gone through the mwan3 documentation and managed to make one rule which suits my requirement.

config rule 'wg7_wan1'
        option dest_port '51821'
        option proto 'udp'
        option use_policy 'wan1_only'

config policy 'wan1_only'
        list use_member 'bal_wan1_m1_w34'

config member 'bal_wan1_m1_w34'
        option interface 'wan1'
        option metric '1'
        option weight '34'

config interface 'wan1'
        option enabled '1'
        option initial_state 'offline'
        option family 'ipv4'
        option timeout '4'
        option up '2'
        option down '2'
        option count '1'
        option interval '10'
        option reliability '1'
        list track_ip 'inseego.com'
        list track_ip '8.8.4.4'

So here I have made a rule that all my UDP traffic with port number 51821 should go via wan1.

As you mentioned,

  1. mwan3 package
  2. a set of rules/routes ----> How my rules/routes should be as per my requirement?

I think, it is not possible, so advice from @trendy is common, but not applicable in any case (like separate just by protocol without port number).