Community discussions

MikroTik App
 
uscallesen
just joined
Topic Author
Posts: 15
Joined: Sun Sep 19, 2010 4:43 pm

Use seperate subnet for NAT source adresses (Solved)

Fri Jun 03, 2011 11:09 am

Hi I cant for the life of me figure out how to do this properly :)

Apart from my WAN IP I have a /29 subnet that I'd like to use as source addresses for my outgoing NAT'ed trafic. How on earth does I do that ? I assume creating an adresslist containing the addresses is step 1 - but now I miss a loopback interface or something similar to 'bind' the IP adressses to ?!?

Gear is RB750G running R.OS 5.4
Last edited by uscallesen on Sat Jun 04, 2011 3:14 pm, edited 1 time in total.
 
Feklar
Forum Guru
Forum Guru
Posts: 1724
Joined: Tue Dec 01, 2009 11:46 pm

Re: Use seperate subnet for NAT source adresses

Fri Jun 03, 2011 5:01 pm

What are you looking to do? You have a full /29, is that routed to you, or only available on your WAN?

If it's routed to you, you can just have that subnet on the LAN of your router and hand out those IPs there. However if it is only available on the WAN, that means you need to assign all of the IP addresses you own to the WAN and set up NAT rules for whatever you want to do.

There are several ways to do this, you can play around with the PCC firewall matcher, netmap, or a few other options depending on your needs.
 
uscallesen
just joined
Topic Author
Posts: 15
Joined: Sun Sep 19, 2010 4:43 pm

Re: Use seperate subnet for NAT source adresses

Fri Jun 03, 2011 11:36 pm

What are you looking to do? You have a full /29, is that routed to you, or only available on your WAN?

If it's routed to you, you can just have that subnet on the LAN of your router and hand out those IPs there. However if it is only available on the WAN, that means you need to assign all of the IP addresses you own to the WAN and set up NAT rules for whatever you want to do.

There are several ways to do this, you can play around with the PCC firewall matcher, netmap, or a few other options depending on your needs.
The /29 subnet is routed to my WAN IP. What I'm trying to do is source-nat some of my outgoing traffic with one or more of the /29 addresses as the new source IP's.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Use seperate subnet for NAT source adresses

Sat Jun 04, 2011 12:11 am

You can just source NAT to it. No need to assign the IP to an interface or anything. The main reason you need to bind IPs to interfaces for source NAT purposes is when they are IPs on a network directly connected to the ISP, so that the router responds to that IP when the other end ARPs for it. If the ISP router can't ARP a directly connected IP it doesn't know where to send the packets, so it drops them. If the IPs are already routed your way it knows where to send traffic via a next hop route and not a directly connected route, so you're good.

If you do want to emulate a loopback though you can just create a bridge interface and not add ports to it, and then assign the IP as a /32 to the bridge interface:
/interface bridge
add name=loopback
/ip address
add address=a.b.c.d/32 interface=loopback
You can use address lists to easily determine who to NAT to what, but it isn't strictly necessary.

So basically if you want to use routed IP a.b.c.d for source NAT for networks 10.1.0.0/24 and 172.16.1.0/24 it would look something like this:
/ip firewall nat 
add chain=srcnat out-interface=WAN src-address=10.1.0.0/24 action=src-nat to-address=a.b.c.d
add chain=srcnat out-interface=WAN src-address=172.16.1.0/24 action=src-nat to-address=a.b.c.d
or with address lists:
/ip firewall address-list
add list=to-a.b.c.d address=10.1.0.0/24
add list=to-a.b.c.d address=172.16.1.0/24
/ip firewall nat 
add chain=srcnat out-interface=WAN src-address-list=to-a.b.c.d action=src-nat to-address=a.b.c.d
 
uscallesen
just joined
Topic Author
Posts: 15
Joined: Sun Sep 19, 2010 4:43 pm

Re: Use seperate subnet for NAT source adresses

Sat Jun 04, 2011 3:13 pm

Thanks alot fewi - works like a charmp with a new firewall nat rule - simply didnt't think it would be this simple to set up :)

Who is online

Users browsing this forum: glushkoo, net4gyh, ocular, Oliver96 and 49 guests