Community discussions

MikroTik App
 
LP006688
just joined
Topic Author
Posts: 11
Joined: Tue Mar 19, 2013 9:44 am

A trivial task, but no info at all

Fri Apr 03, 2015 12:40 pm

Hello everyone,

I have faced a weird situation as if I am the only one in the world, who tries to settle that kind of problem. An external server changes its address. Client software connects to it via IP, not FQDN. How might I perform a destination address substitute in order not to reconfigure hundreds of client computers?

I tried all possible kinds of dstnat, netmap, mark routing -- RouterOS either does nothing, or refuses to accept a rule at all. Does that mean that it cannot do destination address spoofing at all?

Yours faithfully, Vadim.
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: A trivial task, but no info at all

Fri Apr 03, 2015 2:04 pm

This is doable. In my example command, LAN = the lan interface (ether1, ether2, etc)

/ip firewall nat add chain=dstnat in-interface=LAN dst-address=old.ip.address action=dst-nat to-addresses=new.ip.address

If you have multiple LAN interfaces and only one WAN, you should change the in-interface to =!WAN in stead of =LAN
 
LP006688
just joined
Topic Author
Posts: 11
Joined: Tue Mar 19, 2013 9:44 am

Re: A trivial task, but no info at all

Fri Apr 03, 2015 3:01 pm

Thank you so much for the prompt response. Will try that next week.
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 3060
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: A trivial task, but no info at all

Fri Apr 03, 2015 3:29 pm

If you connect from LAN to WAN, where the external server lives, then IMHO you should set "fake" static local IP in your router and configure all clients to connect to this address. Then you should set rule like ZeroByte suggested
/ip firewall nat add chain=dstnat dst-address=LOCAL_IP action=dst-nat to-addresses=current.server.ip.address
Why IMHO it is better way ?
1. The local IP will be constant forever for your client stations. Easy to mantain no matter what is current address of server. You do not need to remember previous IPs...same configuration regardless current server IP. No problem at all.

2. Rule proposed by ZeroByte masks an old IP which COULD host now services we want to access.

3. If you do not track current stations' configurations for each address change you need new rule for all old server's IPs and the current one.

4. If you want to configure clients accessing server from WAN side, you just need to have static public IP, maybe the same as you have, and set the second rule
/ip firewall nat add chain=dstnat dst-address=ACCESS_WAN_IP action=dst-nat to-addresses=current.server.ip.address
Voila
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: A trivial task, but no info at all

Fri Apr 03, 2015 3:42 pm

BartoszP, you raise a valid point that the old IP could potentially being offering some new service that would be inaccessible to the customers.

I think the OP's stated purpose was to avoid re-configuring the hundreds of clients' configurations, so I think he's going to be stuck translating the oldIP.

If the rule needs to be a little more flexible, it could be adapted to use dst-address-list in stead of a specific destination.
This way it would be easy for scripts to add and remove addresses from the list. :)
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 3060
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: A trivial task, but no info at all

Fri Apr 03, 2015 3:46 pm

I think the OP's stated purpose was to avoid re-configuring the hundreds of clients' configurations, so I think he's going to be stuck translating the oldIP.
But the future could be easier.
 
LP006688
just joined
Topic Author
Posts: 11
Joined: Tue Mar 19, 2013 9:44 am

Re: A trivial task, but no info at all

Thu Apr 09, 2015 10:52 pm

Thank you so much, ZeroByte. Your method works perfectly. The problem is solved :D
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: A trivial task, but no info at all

Fri Apr 10, 2015 12:04 am

Bartoz did raise a good point though - that the previous IP could now be hosting something that a customer may actually want to go to.

Interestingly - you can now use the old OR the new IP to reach the service. (nat can do interesting things)

You could also NAT a local address --> the new server IP in addition to the old IP, and then gradually re-configure the clients until they're all using the new local NAT address, and then you can remove the old IP from NAT once nobody is using it anymore.
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 3060
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: A trivial task, but no info at all

Fri Apr 10, 2015 12:28 am

When you switch off (or set it to "nowhere") NAT for an old IP you will know which computers are misconfigured without.
You can add rule to add SRC address to the list for all computers trying to use this NAT rule and you will have all "bad" computers listed.
 
troffasky
Member
Member
Posts: 436
Joined: Wed Mar 26, 2014 4:37 pm

Re: A trivial task, but no info at all

Sat Apr 11, 2015 1:18 pm

I would configure a DNS entry for this host on a local DNS server [eg your Mikrotik router] and reconfigure the clients to use the hostname. If you application doesn't support hostnames.....then you have my commiserations!