2 WAN IP on 1 interface

Hello,

I’ve been searching for a really long time, and couldn’t find something specific for my needs.

My network setup is like this:
eth0 - ISP with two IP-s 1.1.1.1 2.2.2.2
eth1 - Office network 192.168.1.0/24
eth2 - Hotspot network 10.5.0.0/24 (not important for this matter)
eth3 - Employee network 10.6.0.0/24 (not important for this matter)


Currently everything is going on internet via IP1.
and I want to keep it that way.

But I have one host on Office network with IP:
192.168.1.18 which I want to go online via IP2 with all ports open.

What I succeed so far?
Well I did some play in Firewall and I managed to make that
when somebody types ip2:22 it’ gets my SSH server on 192.168.1.18
when I type ip1:22 nothing, closed, dropped.

That is ok, works just like I want, all incoming connection on IP2 are going directly to 192.168.1.18
but the problem is, when I check “What is my IP” with machine 192.168.1.18 it says that his IP is IP1

Do you understand what bothers me?

I Think you should use a src-nat rule for that to work.

/ip firewall nat add chain=srcnat src-address=192.168.1.18 action=src-nat to-addresses=2.2.2.2

I use this for my mail server to send mail from a different IP address.

This may not work 100% for you but you can give it a go.

I’m sorry, but this doesn’t work in my case :slight_smile:
Anyway thanks for your advice

To make it short what I want.

I have 2 WAN IP addresses on one interface.
And I have 1 host in my network which I want ONLY to use 2nd IP address for incoming and outgoing traffic.

p3rad0x’s advice is correct. Make sure that your new srcnat rule comes BEFORE the default masquerade rule in your srcnat chain. Rule order in the chains is important.

Great guys!!
This saved me alot.

This is what I did:

/ip firewall nat add chain=srcnat src-address=192.168.1.18 action=src-nat to-addresses=2.2.2.2
/ip firewall nat add chain=dstnat dst-address=2.2.2.2 action=src-nat to-addresses=192.168.1.18

and in ports I have included 0-65535

My webserver on host 192.168.1.18 is successfully exposed to IP address 2.2.2.2 only!
I tried by accessing via 1.1.1.1 not possible because all other opened ports on my network I have put
dst-address to 1.1.1.1 so accessing to 1.1.1.1:22 will not go anywhere while accessing 2.2.2.2:22 will go to SSH of webhost.


Thanks guys