-
Notifications
You must be signed in to change notification settings - Fork 119
/
PCC Load Balancing (DHCP 2 WAN).txt
135 lines (112 loc) · 4.98 KB
/
PCC Load Balancing (DHCP 2 WAN).txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
###########################################################################
# PCC Load Balancing (DHCP 2 WAN)
# This script is suitable for the same internet speed of both ISPs such as
# ISP1 -> Download Speed: 300 Mbps, Upload Speed: 200 Mbps
# ISP2 -> Download Speed: 300 Mbps, Upload Speed: 200 Mbps
###########################################################################
# Model: hAP ac², RouterOS 7.3.1 (Stable)
# Ether1 -> Connect To ISP1 using DHCP-Client medthod (ISP GW: 192.168.12.1)
# Ether2 -> Connect To ISP2 using DHCP-Client medthod (ISP GW: 192.168.21.1)
# Ether3 - Ether5 -> Give IP Address to PC-Client 172.16.0.0/24
# 1. Create Bridge and assign ports to the bridge
/interface bridge
add name=Bridge-ALL-PORTs
/interface bridge port
add bridge=Bridge-ALL-PORTs interface=ether4
add bridge=Bridge-ALL-PORTs interface=ether3
add bridge=Bridge-ALL-PORTs interface=ether5
#############################################
# 2. Assign IP Gateway to Interface
# IP > Addresses > Press "+"
# Address: 172.16.0.1/24
# network: 172.16.0.0
# Interface: Bridge-ALL-PORTs
#############################################
# 3. Assign DNS Server to MikroTik Router
# IP > DNS
# 1.1.1.1, 1.0.0.1
# Make sure to uncheck "Allow remote request"
# Press "Apply" and "OK"
#############################################
# 4. Connected To ISP
# IP > DHCP-Client
# For Connect To ISP1,
# Press "+"
# Interface: ether1
# Uncheck "Use peer DNS"
# Uncheck "Use peer NTP"
# Add Default Route: no
#
# For Connect to ISP2,
# Press "+"
# Interface: ether2
# Uncheck "Use peer DNS"
# Uncheck "Use peer NTP"
# Add Default Route: no
#############################################
# 5. Create DHCP Server to Bridge
# IP > DHCP Server > Press "DHCP Setup"
# DHCP Server Interface: Bridge-ALL-PORTs
# And press the next button until finished
#############################################
# 6. Make NAT
# IP > Firewall > NAT
# For make NAT ISP1,
# Press "+"
# Chain: srcnat
# Src. Address: 172.16.0.0/24
# Out. Interface: ether1
# Action: masquerade
#
# For make NAT ISP2,
# Press "+"
# Chain: srcnat
# Src. Address: 172.16.0.0/24
# Out. Interface: ether2
# Action: masquerade
#############################################
# 7. Create Tables Routing
# Routing > Tables
# For table routing ISP1
# Press "+"
# Name: via-ISP1
# Make sure to check "FIB"
# Press "OK"
#
# For table routing ISP2
# Press "+"
# Name: via-ISP2
# Make sure to check "FIB"
# Press "OK"
#############################################
# 8. Script PCC Load Balancing
/ip firewall mangle
add action=accept chain=prerouting dst-address=192.168.12.0/24
add action=accept chain=prerouting dst-address=192.168.21.0/24
add action=accept chain=prerouting dst-address=172.16.0.0/24
add action=mark-connection chain=prerouting in-interface=Bridge-ALL-PORTs new-connection-mark=ISP1-Conn passthrough=yes per-connection-classifier=both-addresses:2/0
add action=mark-connection chain=prerouting in-interface=Bridge-ALL-PORTs new-connection-mark=ISP2-Conn passthrough=yes per-connection-classifier=both-addresses:2/1
add action=mark-routing chain=prerouting connection-mark=ISP1-Conn in-interface=Bridge-ALL-PORTs new-routing-mark=via-ISP1 passthrough=no
add action=mark-routing chain=prerouting connection-mark=ISP2-Conn in-interface=Bridge-ALL-PORTs new-routing-mark=via-ISP2 passthrough=no
add action=mark-connection chain=prerouting in-interface=ether1 new-connection-mark=ISP1-Conn passthrough=yes
add action=mark-connection chain=prerouting in-interface=ether2 new-connection-mark=ISP2-Conn passthrough=yes
add action=mark-routing chain=output connection-mark=ISP1-Conn new-routing-mark=via-ISP1 passthrough=no
add action=mark-routing chain=output connection-mark=ISP2-Conn new-routing-mark=via-ISP2 passthrough=no
#############################################
# 9. Create 2 routes to ISP1 and ISP2 with the mark routing that you have just created
/ip route
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.12.1 pref-src="" routing-table=via-ISP1 scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.21.1 pref-src="" routing-table=via-ISP2 scope=30 suppress-hw-offload=no target-scope=10
#############################################
# 10. For failover, create a route to ISP1 with the mark via-ISP2 and give it a distance of 2
/ip route
add disabled=no distance=2 dst-address=0.0.0.0/0 gateway=192.168.12.1 pref-src="" routing-table=via-ISP2 scope=30 suppress-hw-offload=no target-scope=10
#############################################
# 11. For failover, create a route to ISP2 with the mark via-ISP1 and give it a distance of 2
/ip route
add disabled=no distance=2 dst-address=0.0.0.0/0 gateway=192.168.21.1 pref-src="" routing-table=via-ISP1 scope=30 suppress-hw-offload=no target-scope=10
#############################################
# 12. Set NTP-Client to MikroTik Router
# System > NTP Client > check Enabled
# NTP Servers: Input IP Address of NTP Server (Up to you choose)
#############################################