Page 1 of 1

I need a script loop for nat entries

Posted: Sun Feb 05, 2017 5:28 pm
by snd1988
Can any one help me?
I need a script loop, that will add NAT entries.
#192.168.0.0/24 public pool which i want to use in 1:8 nat with 172.16.0.0/21 private pool.

for example,

/ip pool
add name=snat-pool ranges=172.16.0.0/21
add name=snat-pool-public ranges=192.168.0.0/24

/ip firewall nat
add chain=srcnat src-address=172.16.0.0/29 action=src-nat to-addresses=192.168.0.1
add chain=srcnat src-address=172.16.0.8/29 action=src-nat to-addresses=192.168.0.2
add chain=srcnat src-address=172.16.0.16/29 action=src-nat to-addresses=192.168.0.3
.
.
.
.
and so on.

Re: I need a script loop for nat entries

Posted: Wed Feb 08, 2017 11:32 am
by Chupaka
/ip firewall nat
add chain=srcnat src-address=172.16.0.0/21 action=netmap to-addresses=192.168.0.0/24

Re: I need a script loop for nat entries

Posted: Wed Feb 08, 2017 4:58 pm
by snd1988
Thanks for the reply.

Re: I need a script loop for nat entries

Posted: Wed Feb 08, 2017 7:28 pm
by snd1988
@Chupaka

netmap [creates a static 1:1 mapping of one set of IP addresses to another one. Often used to distribute public IP addresses to hosts on private networks]. how it will help me in 1:8 nat?

Re: I need a script loop for nat entries

Posted: Wed Feb 08, 2017 11:52 pm
by Chupaka
address 172.16.0.1 will be natted to 192.168.0.1
address 172.16.0.2 will be natted to 192.168.0.2
address 172.16.0.3 will be natted to 192.168.0.3
...
address 172.16.1.1 will be natted to 192.168.0.1
address 172.16.1.2 will be natted to 192.168.0.2
address 172.16.1.3 will be natted to 192.168.0.3
...
etc

Re: I need a script loop for nat entries

Posted: Sun Feb 12, 2017 9:22 pm
by rftnon
Thanks ...
This is useful and good ...

Re: I need a script loop for nat entries

Posted: Sun Feb 12, 2017 9:53 pm
by Chupaka
Thanks ...
This is useful and good ...
Please, use 'Reputation' for this, without flooding the same message in different topics

Re: I need a script loop for nat entries

Posted: Sat Feb 18, 2017 5:28 am
by snd1988
@Chupaka Thank you.