I make an script to add rule in Firewall and NAT
It's simple and was Working fin until not :S
Firs Ask for the IP, External port, Internal port and Last a Name for rules
The problem is in the part that get the Network IP
# This line was working fine but now only print blank, i don't know why.
#I check and the name of interface "bridge" is fine, My temp Solution is comment that line and create a new one, puting the network ( :local LaRed 192.168.1.0 )
Code: Select all
:local LaRed ([:pick [/ip address print as-value where interface="bridge"] 0]->"network")
:local LaRed 192.168.1.0
I let here the entire script
Code: Select all
:local input do={:put $1;:return}
:local LaIP [$input "IP"]
:local ElPuertoExterno [$input "Puerto Externo"]
:local ElPuertoInterno [$input "Puerto Interno"]
:local Comentario [$input "Nombre"]
#:local LaRed ([:pick [/ip address print as-value where interface="bridge"] 0]->"network")
:local LaRed 192.168.1.0
#:put "Login is [$LaIP] and password is [$LaIP]"
/ip firewall nat add action=dst-nat chain=dstnat comment="$Comentario_$ElPuertoExterno" dst-address-type=local dst-port=$ElPuertoExterno in-interface=all-ppp in-interface-list=!LAN protocol=tcp to-addresses=$LaIP to-ports=$ElPuertoInterno
/ip firewall nat add action=masquerade chain=srcnat dst-address="$LaRed/24" dst-port=$ElPuertoExterno out-interface=bridge protocol=tcp src-address="$LaRed/24"
/ip firewall nat add action=dst-nat chain=dstnat dst-address="!$LaRed/24" dst-address-type=local dst-port=$ElPuertoExterno protocol=tcp to-addresses=$LaIP to-ports=$ElPuertoInterno
/ip firewall nat add action=dst-nat chain=dstnat dst-address-type=local dst-port=$ElPuertoExterno in-interface=all-ppp in-interface-list=!LAN protocol=udp to-addresses=$LaIP to-ports=$ElPuertoInterno
/ip firewall nat add action=masquerade chain=srcnat dst-address="$LaRed/24" dst-port=$ElPuertoExterno out-interface=bridge protocol=udp src-address="$LaRed/24"
/ip firewall nat add action=dst-nat chain=dstnat dst-address="!$LaRed/24" dst-address-type=local dst-port=$ElPuertoExterno protocol=udp to-addresses=$LaIP to-ports=$ElPuertoInterno
/ip firewall filter add action=accept chain=forward dst-port=$ElPuertoExterno in-interface=all-ppp protocol=udp comment="$Comentario_$ElPuertoExterno" place-before=1
/ip firewall filter add action=accept chain=forward dst-port=$ElPuertoExterno in-interface=all-ppp protocol=tcp place-before=2
Thank you!!