[Routing][Tutorial]OpenWrt policy routing & specify WAN egress

1 Introduction

Now there are the following needs

I(Internet)1, I2 are two public IP addresses, C(Client)1, C2, and Cx are all devices mounted under the current route, and Cx means other devices. Among them, C2 only needs to use the IP of I2 as the exit, and other devices use the IP of I1 as the exit.

Satisfying this requirement requires policy routing.

image-20230111160655341

2. Set policy routing

There are two different public network IPs in VWAN1 and VWAN2 in the tutorial, referring to I1 and I2 in the first figure

image-20230111161225946

Entering load balancing, there are three tabs related to policy routing: members, policies, and rules

image-20230111161337688

2.1 Set members

"Member" is used to set the hop count (that is, interface priority) and proportion of each MWAN interface.

In human terms, the member is the exit. If a "policy" matched by a request points to two exits, then the exit with the highest hop count is selected according to the set hop count. If the hop count is the same, the weight is determined.

A member should not use the same name as any setting item in an interface, policy, or rule.

Among them, OpenWrt has configured a member for one of our interfaces, and we do not need to change the tab of the member

image-20230111161621106

2.2 Setting Policy

"Policies" group members and tell MWAN how to distribute traffic using this policy in "rules"

Renhua is used to specify the exit when going out, but this exit can be grouped. If only one member is set in the policy, then go out according to this exit, if more than one is set, decide which exit to take according to the hop count and weight ratio set in "Member".

I have created two new policies here, one policy has only one exit, respectively bound members vwan1_m1_w1, vwan2_m1_w1, corresponding to vwan1 and vwan2

Let’s talk about the BALANCED strategy here. This strategy is the default routing strategy. A request is assigned to the BALANCED strategy, but the strategy contains many exits. At this time, it is determined according to the hops and weights set in the "Member" exit out.

If there is only one member like the two policies I created, when the request comes, it will not decide which exit to go out from, because there is only one exit.

image-20230111161912925

2.3 Setting rules

"Rules are used to specify which traffic will use a particular MWAN policy"

Human words are entrance matching, which traffic should go which way (strategy).

Each flow is matched from top to bottom. If a rule is matched, the rules below it will be ignored . Therefore, we should advance the rules we want to perform special splitting.

Here are two new rules, SHENIAO1_RULE is the C2 mentioned at the beginning, its intranet IP is 192.168.6.157, you can see that its "assigned strategy" column is assigned to WAN2_COMBINE, and the WAN2_COMBINE strategy has only one vwan2_m1_w1 member, so Exit from vwan2_m1_w1, and vwan2_m1_w1 is bound to VWAN2, that is, exit from VWAN2. Since the rule below will be ignored after the rule is matched, I advance it to ensure that all the traffic of C2 comes out of VWAN2. VWAN1_COMBINE_RULE does not specify the source address, all other traffic matches, as above, you can see that it finally exits from VWAN1

image-20230111162753476

2.4 Save application

It seems a little slow to save the application, sometimes it can keep turning sometimes, it should be a BUG, ​​it is recommended to restart after setting. .

3. User experience

After a few days of experience, what does the OP say, the number of connections is fine, but if the number of external network users has a lot of connections, it is recommended to switch to ikuai. The OP seems to be a little bit unable to support it. . . After finishing the tutorial, I’m ready to switch to a soft router. The OP only needs to do WIFI access.

4. Reference

OPENWRT-PandoraBox (Pandora)-designate WAN export tutorial after multiple dials

Tiantang Xingyuan/Tiantang CDN multi-dial and distribution settings, specify export IP

[Solved] The scheme of specifying a device to use the specified vwan after single-line multi-dial

The single WAN port of the router is transformed into dual WAN ports to realize dual broadband superposition and split according to the strategy

Guess you like

Origin blog.csdn.net/qq_38844263/article/details/128647331