Community discussions

MikroTik App
 
pedja
Long time Member
Long time Member
Topic Author
Posts: 684
Joined: Sat Feb 26, 2005 5:37 am

IP used for outgoing connections

Wed Nov 03, 2010 6:38 am

On one ocasion I assigned sevral public IP addresses to single interface. There was no ptroblem with incoming connections to that IP addressses.

But, all outgoing addresses were using just one IP. That was not a problem. Problem was I could not find a way to set which one to use.

Is there a way to do that?
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: IP used for outgoing connections

Wed Nov 03, 2010 5:11 pm

Needs more details for an answer.

Are you trying to have the router itself use different IPs? The services that support that have an option for setting the source address.
Are you trying to have different clients use different IPs for NAT? Use an action of src-nat and specify the to-address rather than have an action of masquerade always pick (the same) IP automatically. The wiki manual on NAT has all the relevant details.
 
Feklar
Forum Guru
Forum Guru
Posts: 1724
Joined: Tue Dec 01, 2009 11:46 pm

Re: IP used for outgoing connections

Wed Nov 03, 2010 6:47 pm

By default the router will use the preferred source for a subnet to send traffic out of from itself and a masquerade rule. This is often the first IP address that comes up when it is rebooted or the first IP address that you added to that interface. You can change it by disabling all IP addresses except for the one you want to have it use. I have a script that runs at startup and disables all IP addresses with a comment of "ISP NAT" and re-enables them a couple of seconds latter to get around this.
 
xxiii
Member Candidate
Member Candidate
Posts: 234
Joined: Wed May 31, 2006 12:55 am

Re: IP used for outgoing connections

Wed Nov 03, 2010 7:05 pm

You can also change it by editing the relevent route (0.0.0.0/0 for instance) and explicitly setting the Pref. Source. This can also be set using a routing filter for dynamic routes. It is a good idea for the router to have a loopback, and use the loopback's IP, for this sort of thing.
 
pedja
Long time Member
Long time Member
Topic Author
Posts: 684
Joined: Sat Feb 26, 2005 5:37 am

Re: IP used for outgoing connections

Thu Nov 04, 2010 6:18 pm

What I want to achieve is to set two web servers in lan, and assign each one with separate public IP using NAt on router. That works fine, but when bothe server try to establish connections to outside world, they use the same IP address.

Your explantions seem reasonable, I will try with that to-address trick in masquarade.

Thanks.

Pedja
 
Feklar
Forum Guru
Forum Guru
Posts: 1724
Joined: Tue Dec 01, 2009 11:46 pm

Re: IP used for outgoing connections

Thu Nov 04, 2010 6:34 pm

If you have static IPs, use action=src-nat and define the src-address in the NAT rule, instead of masquerade in that case. You can define what IP address the servers specifically use to make connections to the outside world that way.

Who is online

Users browsing this forum: BrianTob, consoletotherescue, hex2bin, mstanciu and 57 guests