Masquerading LAN-to-LAN source IP through RNAT?

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
izua
DD-WRT Novice


Joined: 20 Oct 2014
Posts: 5

PostPosted: Mon Oct 20, 2014 10:47    Post subject: Masquerading LAN-to-LAN source IP through RNAT? Reply with quote
Hi,

How can I masquerade the source IP of a machine inside a private network while connecting by nat reflection to another machine inside the same private network?

I know NAT reflection was a problem until ~rev 19000, whereas, even if you enabled the specific option in the GUI, it would still not work.

Example network:

Code:

workstation-1:192.168.1.2
workstation-2:192.168.1.3
dd-wrt: 192.168.1.1
public ip: 1.2.3.4

public ip port forwards:
  1.2.3.4:223 -> 192.168.1.2:22
  1.2.3.4:224 -> 192.168.1.3:22

What I do right now:
workstation-1 # ssh 1.2.3.4 -p 223
connects correctly to 192.168.1.2
workstation-2 # ssh 1.2.3.4 -p 224
connects correctly to 192.168.1.3

What is my problem:
workstation-1 # last | grep 192.168.1.2
#
(nothing)

What i expect to find:
izua     pts/x       192.168.1.2        Mon Oct 20 06:00 - 09:00  (03:00)

What i actually find:
izua     pts/x       192.168.1.1        Mon Oct 20 06:00 - 09:00  (03:00)


tl;dr - when connecting from a LAN IP to another LAN IP by NAT reflection, I want the source IP from the NAT to appear as the originating IP instead of the router's IP.

There probably is a special name for this, since I can't figure out the iptables command (a forward from -i eth0 to -o eth0 would make no sense, for example).


Last edited by izua on Tue Nov 04, 2014 1:15; edited 1 time in total
Sponsor
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Mon Nov 03, 2014 8:47    Post subject: Reply with quote
I don't understand what you are trying to achieve here.
izua
DD-WRT Novice


Joined: 20 Oct 2014
Posts: 5

PostPosted: Mon Nov 03, 2014 17:40    Post subject: Reply with quote
Connect to a service (public ip:port only) from inside or outside the LAN. Have the target service see the source IP masquaraded in both cases (public IP when originating from the internet and lan ip - not the router's - when originating from inside the lan). Or in other words, route a lan-to-lan connection through the external IP and have the target service see the source IP.

I specifically need the connection to be routed through and masqueraded, and not connect directly (for example, by figuring out the IP through a network-wide nameserver).

The problem that I see is that the service sees the router's IP when accessed from inside the LAN.


Last edited by izua on Tue Nov 04, 2014 1:02; edited 1 time in total
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Mon Nov 03, 2014 19:34    Post subject: Reply with quote
Use two name servers. One for internal that give the private address for the name and another that gives the public address for clients outside the network.
izua
DD-WRT Novice


Joined: 20 Oct 2014
Posts: 5

PostPosted: Tue Nov 04, 2014 1:08    Post subject: Reply with quote
Yeah, that's what I'm currently doing, however, I want to do this by bouncing through the router.
There is also the problem that by, bypassing the router and its port forwards, I have to open the forwarded ports on the lan machines (223 and 224 in my example). Not a problem for sshd, but other apps won't like it. I could do this locally, on every machine, for every service, in iptables, though.
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Tue Nov 04, 2014 8:18    Post subject: Reply with quote
This will not work. You are asking for conflicting features.
izua
DD-WRT Novice


Joined: 20 Oct 2014
Posts: 5

PostPosted: Thu Nov 06, 2014 10:09    Post subject: Reply with quote
I'm not sure I understand. Bouncing through the router obviously works because RNAT is working and I see the source IP as the router on the destination. What makes it conflicting for the router to rewrite the source IP to one originating from the local private network, as it is already doing with packets coming from the Internet?
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Thu Nov 06, 2014 10:35    Post subject: Reply with quote
The SNAT is takes place when the packet goes from the lan to the wan.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum