Hello,
i need a script that copy address from the dynamic pptp-out1 from ip address to ip firewall nat and set to address
You can use ppp profiles to create on-up and on-down scripts. on-up script has a variable passed in for Local Address (Address assigned to the interface) as ‘$local-address’
So it’d be something similar to this (untested):
/ip firewall nat set [ find comment="PPTP UPDATE" ] to-address=$local-address
This will find the NAT rule with comment ‘PPTP UPDATE’ and set the to-address as the assigned address. I find comments the easiest unique way to find a rule but you can obviously change the FIND statement to identify the rule however you want.
Thank alot i get solved it ![]()
:global new
:global old
:global status
:set status [/interface get [/interface find name=(“pptp-out1”)] running]
:if ($status=true) do={
:set new [/ip address get [/ip address find dynamic=yes interface=(“pptp-out1”)] address]
:set new [:pick $new 0 ([:len $new] -3)]
:set old [/ip firewall nat get [find comment=(“Loopback”)] to-addresses]
:if (!($new=$old)) do={
/ip firewall nat set [/ip firewall nat find comment=(“Loopback”)] to-addresses=$new
}}
Better on this way:
:global status [/interface get pptp-out1 running]
:if ($status) do={
:global old [/ip firewall nat get [find where comment="Loopback"] to-addresses]
:global new [/ip address get [find where dynamic=yes and interface="pptp-out1"] address]
:set new [:pick $new 0 [:find $new "/"] ]
:if ($new != $old) do={
/ip firewall nat set [find where comment="Loopback"] to-addresses=$new
}
}
Noted with thanksssssssssssssssssssss