Hi guys,
I knew it was being discussed but I wanted to know how do I achieve this.
My ISP provides an ONR (Optical Network Router), it has 4 port, LAN1 for Internet and LAN2 for Network TV.
Currently the LAN1 is connected to my Mikrotik CHR and LAN2 is connected to my Ubiquiti USG. Both of them obtained different WAN public IP by the same ISP.
I tested both of them able to access internet, I did connect the LAN2 to my USG and configured load balance, it is working well but the speed doesn’t double up, i guess for USG it is simpleload balancing but not “stacking”.
I did some research on MikroTik and believe it can be achieved with PCC.
My WAN interfaces are named “Port 1 - WAN1” and “Port 2 - WAN2” and my LAN interface is named as “Port 5 - LAN”.
I seeking for help from anyone who can review my setting, and how do i update the “Destination Address in Mangle” and “Gateway in Routes” when the “Public IP or Gateway IP” changes
?
I refer to this post http://forum.mikrotik.com/t/howto-dual-wan-pcc-with-dynamic-ip/101969/1 the author does provide a script, how do i amend it to fit my case?
From what i self study so far, i have to create a script in “Scripts” and then use the “Scheduler” to make it runs every 5 minutes so that it will update the Destination Address and Routes when the Public IP changes.
Please let me know if my idea is feasible, open discussion and I thank you everyone for helping.
# Dynamic IP Updater by David Joyce
:local wan0name "wan0";
:local wan1name "wan1";
:global wan0address;
:global wan1address;
:local wan0ip [/ip dhcp-client get [find interface="$wan0name"] value-name=address];
:if ($wan0address != $wan0ip) do={
:global wan0address [:pick $wan0ip 0 [:find $wan0ip "/"]];
:local wan0gateway [/ip dhcp-client get [find interface="$wan0name"] value-name=gateway];
:local wan0temp [/ip address get [find interface="$wan0name"] value-name=network ]
:local wan0subnet ($wan0temp . "/" . [:pick $wan0ip ([:find $wan0ip "/"]+1) [:len $wan0ip] ] )
/ip route set [find comment="wan0"] gateway=$wan0gateway;
/ip firewall address-list set [find comment="wan0"] address=$wan0subnet;
}
:local wan1ip [/ip dhcp-client get [find interface="$wan1name"] value-name=address];
:if ($wan1address != $wan1ip) do={
:global wan1address [:pick $wan1ip 0 [:find $wan1ip "/"]];
:local wan1gateway [/ip dhcp-client get [find interface="$wan1name"] value-name=gateway];
:local wan1temp [/ip address get [find interface="$wan1name"] value-name=network ]
:local wan1subnet ($wan1temp . "/" . [:pick $wan1ip ([:find $wan1ip "/"]+1) [:len $wan1ip] ] )
/ip route set [find comment="wan1"] gateway=$wan1gateway;
/ip firewall address-list set [find comment="wan1"] address=$wan1subnet;
}
Below my configuration
# jul/21/2020 07:22:49 by RouterOS 6.45.9
# software id =
#
#
#
/interface ethernet
set [ find default-name=ether2 ] disable-running-check=no name=\
"Port 1 - WAN1"
set [ find default-name=ether3 ] disable-running-check=no name=\
"Port 2 - WAN2"
set [ find default-name=ether4 ] disable-running-check=no name="Port 5 - LAN"
/interface list
add name=WAN
add name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=pool ranges=192.168.8.201-192.168.8.210
/ip dhcp-server
add address-pool=pool interface="Port 5 - LAN" name="DHCP Server"
/interface bridge port
add disabled=yes interface="Port 2 - WAN2"
add interface="Port 1 - WAN1"
/interface list member
add interface="Port 1 - WAN1" list=WAN
add interface="Port 5 - LAN" list=LAN
add interface="Port 2 - WAN2" list=WAN
/ip address
add address=192.168.8.6/24 interface="Port 5 - LAN" network=192.168.8.0
/ip dhcp-client
add dhcp-options=clientid,hostname disabled=no interface="Port 1 - WAN1" \
use-peer-dns=no
add dhcp-options=clientid,hostname disabled=no interface="Port 2 - WAN2" \
use-peer-dns=no
/ip dhcp-server network
add address=192.168.8.0/24 dns-server=192.168.8.6 gateway=192.168.8.18 \
netmask=24
/ip dns
set allow-remote-requests=yes servers=192.168.8.18
/ip firewall mangle
add action=accept chain=prerouting disabled=yes dst-address=10.1.1.0/30 \
in-interface="Port 5 - LAN"
add action=accept chain=prerouting disabled=yes dst-address=20.1.1.0/30 \
in-interface="Port 5 - LAN"
add action=mark-connection chain=input comment=INOUT1 disabled=yes \
in-interface="Port 1 - WAN1" new-connection-mark=WAN1_conn passthrough=\
yes
add action=mark-routing chain=output connection-mark=WAN1_conn disabled=yes \
new-routing-mark=to_WAN1 passthrough=yes
add action=mark-connection chain=input comment=INOUT2 disabled=yes \
in-interface="Port 2 - WAN2" new-connection-mark=WAN2_conn passthrough=no
add action=mark-routing chain=output connection-mark=WAN2_conn disabled=yes \
new-routing-mark=to_WAN2 passthrough=yes
add action=mark-connection chain=prerouting comment=PCC1 connection-mark=\
no-mark disabled=yes dst-address-type=!local in-interface="Port 5 - LAN" \
new-connection-mark=WAN1_conn passthrough=yes per-connection-classifier=\
both-addresses:2/0
add action=mark-routing chain=prerouting connection-mark=WAN1_conn disabled=\
yes in-interface="Port 5 - LAN" new-routing-mark=to_WAN1 passthrough=yes
add action=mark-connection chain=prerouting comment=PCC2 connection-mark=\
no-mark disabled=yes dst-address-type=!local in-interface="Port 5 - LAN" \
new-connection-mark=WAN2_conn passthrough=yes per-connection-classifier=\
both-addresses:2/1
add action=mark-routing chain=prerouting connection-mark=WAN2_conn disabled=\
yes in-interface="Port 5 - LAN" new-routing-mark=to_WAN2 passthrough=yes
/ip firewall nat
add action=masquerade chain=srcnat
add action=masquerade chain=srcnat out-interface="Port 1 - WAN1" \
out-interface-list=WAN
add action=masquerade chain=srcnat out-interface="Port 2 - WAN2" \
out-interface-list=WAN
/ip route
add check-gateway=ping distance=1 gateway="Port 1 - WAN1" routing-mark=\
to_WAN1
add check-gateway=ping distance=1 gateway="Port 2 - WAN2" routing-mark=\
to_WAN2
add distance=1 gateway="Port 1 - WAN1"
add distance=2 gateway="Port 2 - WAN2"
/ip service
set telnet disabled=yes
set ftp disabled=yes
set www disabled=yes
set ssh disabled=yes
set www-ssl certificate=fullchain.pem_0 disabled=no
/ip upnp
set allow-disable-external-interface=yes enabled=yes
/ip upnp interfaces
add interface="Port 1 - WAN1" type=internal
add interface="Port 2 - WAN2" type=external
/system clock
set time-zone-name=Asia/Singapore
/system package update
set channel=long-term