Dear Sirs,
I’ve been playing around with Dual Wan and looking for many scripts online but I’m really lost. There’s too many options but which suits my case.
DHCP is on with pool 192.168.0.100-192.168.0.254
WAN1 : PPPoe ( Dynamic IP) Port Name: pppoe-DialUp / ether1-gateway
WAN2: 192.168.10.1 (Static IP) Port Name: ether5-slave-local
Plz check this script will it work properly?
/interface bridge settings
set use-ip-firewall=yes
/interface bridge settings
set use-ip-firewall-for-pppoe=yes
/ip firewall mangle
add chain=prerouting dst-address=192.168.0.0/24 in-interface=bridge-local action=accept
/ip firewall mangle
add chain=input in-interface=pppoe-DialUp connection-mark=no-mark action=mark-connection new-connection-mark=WAN1 passthrough=no
add chain=input in-interface=ether5-slave-local connection-mark=no-mark action=mark-connection new-connection-mark=WAN2 passthrough=no
/ip firewall mangle
add chain=output out-interface=pppoe-DialUp connection-mark=WAN1 action=mark-routing new-routing-mark=WAN1 passthrough=no
add chain=output out-interface=ether5-slave-local connection-mark=WAN2 action=mark-routing new-routing-mark=WAN2 passthrough=no
/ip firewall mangle
add chain=prerouting connection-mark=no-mark dst-address-type=!local in-interface=bridge-local per-connection-classifier=both-addresses:2/0 action=mark-connection new-connection-mark=WAN1
add chain=prerouting connection-mark=no-mark dst-address-type=!local in-interface=bridge-local per-connection-classifier=both-addresses:2/1 action=mark-connection new-connection-mark=WAN2
/ip firewall mangle
add chain=prerouting connection-mark=WAN1 in-interface=bridge-local action=mark-routing new-routing-mark=WAN1 passthrough=no
add chain=prerouting connection-mark=WAN2 in-interface=bridge-local action=mark-routing new-routing-mark=WAN2 passthrough=no
/ip route
add dst-address=0.0.0.0/0 gateway=pppoe-DialUp routing-mark=WAN1
add dst-address=0.0.0.0/0 gateway=ether5-slave-local routing-mark=WAN2
/ip route
add dst-address=0.0.0.0/0 gateway=pppoe-DialUp distance=1
add dst-address=0.0.0.0/0 gateway=ether5-slave-local distance=2
Example for dynamic IPs:
/ip firewall nat
add chain=src-nat out-interface=pppoe-DialUp action=masquerade
add chain=src-nat out-interface=ether5-slave-local action=masquerade
Example for static IPs of 1.2.3.4 and 4.3.2.1:
/ip firewall nat
add chain=src-nat out-interface=pppoe-DialUp action=src-nat to-addresses=1.2.3.4
add chain=src-nat out-interface=ether5-slave-local action=src-nat to-addresses=4.3.2.1
Example for dynamic/Static IPs:
add chain=src-nat out-interface=pppoe-DialUp action=masquerade
add chain=src-nat out-interface=ether5-slave-local action=src-nat to-addresses=192.168.10.2
Or shall I go with this script?
#|/ip address
/ip address add address=192.168.10.2/24 network=192.168.10.0 broadcast=192.168.10.255 interface=ether2
/ip address add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=ether5 comment="default configuration"
#|/ip firewall mangle
/ip firewall mangle add chain=input in-interface=pppoe-out1 action=mark-connection new-connection-mark=ether1_conn
/ip firewall mangle add chain=input in-interface=ether2 action=mark-connection new-connection-mark=ether2_conn
/ip firewall mangle add chain=output connection-mark=ether1_conn action=mark-routing new-routing-mark=to_ether1
/ip firewall mangle add chain=output connection-mark=ether2_conn action=mark-routing new-routing-mark=to_ether2
/ip firewall mangle add chain=prerouting dst-address=192.168.1.0/24 action=accept in-interface=ether5
/ip firewall mangle add chain=prerouting dst-address=192.168.10.0/24 action=accept in-interface=ether5
/ip firewall mangle add chain=prerouting dst-address-type=!local in-interface=ether5 per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection new-connection-mark=ether1_conn passthrough=yes
/ip firewall mangle add chain=prerouting dst-address-type=!local in-interface=ether5 per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection new-connection-mark=ether2_conn passthrough=yes
/ip firewall mangle add chain=prerouting connection-mark=ether1_conn in-interface=ether5 action=mark-routing new-routing-mark=to_ether1
/ip firewall mangle add chain=prerouting connection-mark=ether2_conn in-interface=ether5 action=mark-routing new-routing-mark=to_ether2
#|/ip route
/ip route add dst-address=0.0.0.0/0 gateway=pppoe-out1 routing-mark=to_wan1 check-gateway=ping
/ip route add dst-address=0.0.0.0/0 gateway=192.168.10.1 routing-mark=to_ether2 check-gateway=ping
/ip route add dst-address=0.0.0.0/0 gateway=pppoe-out1 distance=1 check-gateway=ping
/ip route add dst-address=0.0.0.0/0 gateway=192.168.10.1 distance=2 check-gateway=ping
#|/ip firewall nat
/ip firewall nat add chain=srcnat out-interface=pppoe-out1 action=masquerade
/ip firewall nat add chain=srcnat out-interface=ether2 action=masquerade
#| DHCP server is on switch, with address pool 192.168.0.100-192.168.0.200
/ip pool add name=default-dhcp ranges=192.168.0.100-192.168.0.200
/ip dhcp-server add name=default address-pool=default-dhcp interface=ether5 disabled=no
/ip dhcp-server network add address=192.168.0.0/24 gateway=192.168.0.1 dns-server=192.168.0.1 comment="default configuration"
#| DNS
/ip dns set allow-remote-requests=yes
/ip dns static add name=router address=192.168.0.1
#| Now Configure DNS server so users can resolve hostnames,
#| Ex.cache-size=5000KiB
#| DNS Google = 8.8.8.8,8.8.4.4
#| DNS 3BB = 110.164.252.222,110.164.252.223
/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000K max-udp-packet-size=512 servers=8.8.8.8,8.8.4.4
For the unequal-speed Internet line, you can edit the code (for example speed WAN 1,2,3 4Mb speed WAN 4 and 8 Mb).
(The principle is, in the first iteration has many times. Shared Bandwidth just trying to use it as well. Or may be offset to some Link as special needs or not.
- In the first sample loops are five times 4/0 to 4/4 by trying to spread out through Link Bandwidth used all the same).
add chain = prerouting dst-address-type =! local in-interface = Local per-connection-classifier = both-addresses-and-ports: 4/0 action = mark-connection new-connection-mark = ether1_conn passthrough = yes.
add chain = prerouting dst-address-type =! local in-interface = Local per-connection-classifier = both-addresses-and-ports: 4/1 action = mark-connection new-connection-mark = ether2_conn passthrough = yes.
add chain = prerouting dst-address-type =! local in-interface = Local per-connection-classifier = both-addresses-and-ports: 4/2 action = mark-connection new-connection-mark = ether3_conn passthrough = yes.
add chain = prerouting dst-address-type =! local in-interface = Local per-connection-classifier = both-addresses-and-ports: 4/3 action = mark-connection new-connection-mark = ether4_conn passthrough = yes.
add chain = prerouting dst-address-type =! local in-interface = Local per-connection-classifier = both-addresses-and-ports: 4/4 action = mark-connection new-connection-mark = ether4_conn passthrough = yes.
I recommend copying the code stored as Word, because if you want to change the IP or the other. We can use the search function and replace it.
/ip firewall mangle add chain=prerouting dst-address=192.168.1.0/24 action=accept in-interface=ether5
This line confused me in the second script what shall I put for the PPPoe as it’s a dynamic instead the (dst-address=192.168.1.0/24) ?
I added a photo for my interfaces.