Difference between revisions of "UPnP Multi-WAN"

From MikroTik Wiki
Jump to: navigation, search
(Created page with "The following script will clone UPnP entries from WAN1 to WAN2: Schedule NAT entry cloning every few minutes: (set <WAN2 IP> manually) :foreach i in=([/ip fi nat find dynamic...")
 
m
Line 1: Line 1:
The following script will clone UPnP entries from WAN1 to WAN2:
+
1. Make the simplest UPnP config for just WAN1.
  
 +
2. Add the following script: will clone UPnP NAT entries from WAN1 as normal NAT entries for WAN2:
 +
(Schedule every few minutes)
 +
(set <WAN2 IP> manually)
  
Schedule NAT entry cloning every few minutes:
 
  
(set <WAN2 IP> manually)
+
:foreach i in=([/ip fi nat find dynamic]) do={/ip fi nat add chain=dst-nat dst-address="<WAN2 IP>" protocol=[/ip fi nat get $i protocol] to-addresses=[/ip fi nat get $i to-addresses] to-ports=[/ip fi nat get $i to-ports] action=dst-nat dst-port=[/ip fi nat get $i dst-port] comment="UPnP_Cloned"}
 +
 
  
:foreach i in=([/ip fi nat find dynamic]) do={/ip fi nat add chain=dst-nat dst-address="<WAN2 IP>" protocol=[/ip fi nat get $i protocol] to-addresses=[/ip fi nat get $i to-addresses] to-ports=[/ip fi nat get $i to-ports] action=dst-nat dst-port=[/ip fi nat get $i dst-port] comment="UPnP_Cloned"}
+
NOTE: A fix is needed to clone only new Dynamic NAT entries
  
  
Schedule cloned NAT entry removing every other night:
+
3. Schedule cloned NAT entry removing every other night:
  
 
/ip firewall nat remove [/ip firewall nat find comment="UPnP_Cloned"]
 
/ip firewall nat remove [/ip firewall nat find comment="UPnP_Cloned"]

Revision as of 13:27, 17 May 2014

1. Make the simplest UPnP config for just WAN1.

2. Add the following script: will clone UPnP NAT entries from WAN1 as normal NAT entries for WAN2: (Schedule every few minutes) (set <WAN2 IP> manually)


foreach i in=([/ip fi nat find dynamic]) do={/ip fi nat add chain=dst-nat dst-address="<WAN2 IP>" protocol=[/ip fi nat get $i protocol] to-addresses=[/ip fi nat get $i to-addresses] to-ports=[/ip fi nat get $i to-ports] action=dst-nat dst-port=[/ip fi nat get $i dst-port] comment="UPnP_Cloned"}


NOTE: A fix is needed to clone only new Dynamic NAT entries


3. Schedule cloned NAT entry removing every other night:

/ip firewall nat remove [/ip firewall nat find comment="UPnP_Cloned"]