Community discussions

MikroTik App
 
snd1988
just joined
Topic Author
Posts: 5
Joined: Sun Feb 05, 2017 4:38 pm

I need a script loop for nat entries

Sun Feb 05, 2017 5:28 pm

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.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: I need a script loop for nat entries

Wed Feb 08, 2017 11:32 am

/ip firewall nat
add chain=srcnat src-address=172.16.0.0/21 action=netmap to-addresses=192.168.0.0/24
 
snd1988
just joined
Topic Author
Posts: 5
Joined: Sun Feb 05, 2017 4:38 pm

Re: I need a script loop for nat entries

Wed Feb 08, 2017 4:58 pm

Thanks for the reply.
 
snd1988
just joined
Topic Author
Posts: 5
Joined: Sun Feb 05, 2017 4:38 pm

Re: I need a script loop for nat entries

Wed Feb 08, 2017 7:28 pm

@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?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: I need a script loop for nat entries

Wed Feb 08, 2017 11:52 pm

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
 
rftnon
newbie
Posts: 29
Joined: Fri Feb 28, 2014 6:34 pm

Re: I need a script loop for nat entries

Sun Feb 12, 2017 9:22 pm

Thanks ...
This is useful and good ...
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: I need a script loop for nat entries

Sun Feb 12, 2017 9:53 pm

Thanks ...
This is useful and good ...
Please, use 'Reputation' for this, without flooding the same message in different topics
 
snd1988
just joined
Topic Author
Posts: 5
Joined: Sun Feb 05, 2017 4:38 pm

Re: I need a script loop for nat entries

Sat Feb 18, 2017 5:28 am

@Chupaka Thank you.

Who is online

Users browsing this forum: Mosfet and 50 guests