University people suffer campus network for a long time! Are you bothered by the speed limit of hundreds of kilobytes/s on campus networks? Have you ever had the idea of doubling your campus speed? This article can help you! (Long Warning)
One. Preparation materials:
One router (OpenWrt firmware)
Computer (mobile phone also available)
Campus Network
Two. Preparations:
Make sure the router is networked
The computer enters the OpenWrt background web page
A certain amount of patience and knowledge of computer networks (bushi)
Three. Talk less nonsense, start now!
First make sure your PC is connected to the router, which is connected to the campus network.
Then open the terminal and ssh enters the router background.
3.1 Add a virtual NIC
Install macvlan
Create and enable a virtual NIC
Where eth0.2 is the corresponding physical network card in my network interface, the firmware with VLAN enabled is generally eth0.x, and x is determined according to the VLAN division. You can view it directly to the network → interface.
The above method is a temporarily created virtual NIC, after the reboot of the virtual NIC invalid, you can use the following methods to create a permanent virtual NIC:
At this time, enter ifconfig to check whether the addition is successful:
3.2 Create an interface
Go to the background of the openwrt webpage and click the network → interface
It is recommended to delete the wan port that has been bound to the above eth0.2 or set it to not start when booting, so as to avoid the virtual NIC not being able to obtain the IP address.
To add a new interface, the device selects the virtual NIC veth0, and then creates the interface.
Set the gateway hop, just one value, but don't duplicate it with other wans.
Firewall select wan
The other settings remain at default and save the app.
Check whether the IP is obtained normally
The IP address corresponds to the IP address of the campus network self-service system, indicating that it has been successfully connected to the campus network through the virtual network card.
Then log in to the campus network and check whether the network is normal (each school has a different login method, omit a screenshot here).
3.3 Create another interface
Create another vNIC vwan2 in the same way. At this time, vwan2 has not yet connected to the campus network, but automatically obtained the IP address.
It should be noted here that our vwan2 is not used immediately after creation, and at this time, the login interface of the campus network still shows that it has logged in, because the current traffic is vwan1.
Four. Load balancing
So how to let the traffic go vwan2, so that vwan2 can board the campus network?
At this time, the load balancing plugin mwan3 is used.
Install the mwan3 and luci interfaces
After installation, go to the network → the load balancing interface and delete the configuration of the interface, members, policies, and rules.
Add vwan1 to the interface, the name should be the same as the interface name added on the network → interface, otherwise the interface cannot be matched.
Tick Enable, fill in the tracked IP, and the interface will ping this IP to check whether it is online. Other configurations remain on default.
Add another vwan, save, go back to the interface, and see a configuration like this.
It should be noted that the metric is not a numeric value, and the display "-" is either the metric of the interface is not specified, and the interface is re-specified → the network, or the interface name is not corresponding. There is also whether the number of hops is different between different interfaces.
4.1 Member Configuration
The name is recommended to use "Interface_Metric_Weight" to facilitate the resolution when configuring the policy.
Routes take precedence to interfaces with small hop values. Interfaces with the same metric value are routed by weight walk. If you are using the same number, the same network speed, the same number of hops is recommended, the weight is 1:1, and you can do it at your own discretion.
4.2 Policy Configuration
Add a balanced policy balancing strategy balancing, add all the previous members in, and then add vwan1 and vwan2 separate policies, one policy corresponds to one interface, and it is useful for a separate policy to log in to the campus network in the back.
4.3 Rule Configuration
The big play is here, this step to achieve the specified interface to use to log on to the campus network, that is, the login_net rules in the above figure.
The destination address is filled in with the address of the campus network webpage login, the protocol is all, and the finally assigned policy is selected as a separate policy, so that all the traffic that lands on the campus network can be controlled to go to the interface assigned to it. Each individual policy selects a save application and then logs in, and there are as many vwan ports as there are.
4.4 Final Check
After logging in, check whether all interfaces are online, the status → Load Balancing
Switch to Details and check that the policy is assigned correctly
I added an extra vwan3 port after me, so the average load balancer is 33% of the traffic per port.
The case of the two ports should be 50% per port, and the configurations assigned are different here, which is also shown differently.
Five. Velocity
At this point, in theory, multiple dials have been realized, the speed of multiple lines will be doubled, and practice is the only criterion for testing truth.
Note that tools for multi-threaded speed measurement such as speedtest.cn default multithreading are selected, while speedtest.net need to select multithreading
Not over-dialed:
Download is very slow
Multi-dial:
ohhhhhhhhhh
It can be clearly seen that my multi-dial (three-port) download rate is 3 times faster than that of single dial, and the upload has also improved to a certain extent (the campus network limits downloads without limit upload).
Don't ask me why I only use three ports, ask is that the campus network limit can only board 3 devices. If you don't limit it, add more is no problem, the total network speed = single number network speed * the number of network ports, of course, add too much then the router performance may become a bottleneck, test yourself.
Six. Actual combat
Since there are three ports, that one can not be idle here simulates multiple terminal devices playing videos online at the same time (two B stations, one movie), and three videos playing at the same time without a card.
OpenWrt real-time traffic, veth0, veth1, veth2 are the three virtual NICs added earlier, load balancing divides the traffic very reasonably, and each link is fully utilized.
veth0
veth1
veth2
Seven. Advanced
If your router has LEDs, you can also monitor the speed of each link with custom LED events. The system → LED configuration.
The blinking of the light indicates that the link has data transmission, and the faster the flashing, the faster the data transmission.
Eight. illustrate
It should also be noted that the method of multi-dialing can only theoretically increase bandwidth, not speed up network response time. That is, web page loading speed, ping, etc., because the response time depends on the bandwidth factors such as domain name resolution. If you want to speed up the network response time, you can go to understand the DNS-related content, OpenWRT also has related plug-ins such as smartDNS, here is not too much to repeat.
Thanks
This article was written after the completion of the computer network course, without the knowledge of the network, there is no successful practice of this time, thanks to my computer network course Wu teacher, and thanks to this thickest textbook I have read since entering the university, as well as the above reference article.
This article is compiled from Ku'an @ Xiaomi insiders.
Here is Pegasus Technology, sharing a variety of dry goods, looking forward to your attention.