i need a script for changing an IP address in firewall-->NAT rule. I have DDNS script yet with an "ddnslastip" variable, and PPPoE on the WAN port (i have ADSL input) Can i use that variable to change the IP address in the firewall rule? In other words, the script seen also at the time (Mikrotik RouterOS v3.10):
Code: Select all
:log info "DDNS: IP cím frissítésének kezdte"
:global ddnsuser "USERNAME"
:global ddnspass "PASSWORD"
:global ddnshost "USERNAME.changeip.net"
:global ddnsinterface "pppoe-out"
:global ddnslastip
:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface] address ]
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip 0.0.0.0/0 }
:if ([ :typeof $ddnsip ] = nil ) do={
:log info ("DDNS: Nincs ip cím a " . $ddnsinterface . ", ellenőrizd!!!.")
} else={
:if ($ddnsip != $ddnslastip) do={
:log info "DDNS: FRISSÍTÉS!!!"
:log info [ /tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip "/"] ] key-name=$ddnsuser key=$ddnspass ]
:global ddnslastip $ddnsip
} else={
:log info "DDNS: Nincs változás!"
}
}
:log info "DDNS: Vége"
The NAT rule:
Code: Select all
/ip firewall nat
add action=dst-nat chain=dstnat comment="" disabled=yes dst-address=\
"[color=#FF0000]i need IP address from ddnslastip variable here[/color]" dst-port=3600-3800 in-interface=pppoe-out protocol=tcp \
to-addresses=192.168.1.199 to-ports=3600-3800
add action=dst-nat chain=dstnat comment="" disabled=yes dst-address=\
"[color=#FF0000]i need IP address from ddnslastip variable here[/color]" dst-port=3600-3800 in-interface=pppoe-out protocol=udp \
to-addresses=192.168.1.199 to-ports=3600-3800