Networking Forums

Networking Forums > Computer Networking > Linux Networking > real IPbehind SNAT

Reply
Thread Tools Display Modes

real IPbehind SNAT

 
 
Nelson Castillo
Guest
Posts: n/a

 
      04-27-2004, 12:14 PM
Hi.

I'd like to route a real IP behind a static NAT.

INTERNET
|
|
eth0 = REAL IP 1
ROUTER with Linux
eth1 = private IP
|
|
HUB
|
|
eth0 = REAL IP 2
SERVER 1

Can I route traffic to the REAL IP 2?
How should I do it?

REAL IP 1 and REAL IP 2 are in the same subnet.

I've read some documents but I still dont't
know how to set this up.

I guess I have to put a fake ARP entry in eth0
and add a host route in the ROUTER...

Regards,
Nelson.-
 
Reply With Quote
 
 
 
 
Christoph Scheurer
Guest
Posts: n/a

 
      04-27-2004, 06:23 PM
On 27 Apr 2004 05:14:16 -0700
(E-Mail Removed) (Nelson Castillo) wrote:

> Hi.
>
> I'd like to route a real IP behind a static NAT.
>
> INTERNET
> |
> |
> eth0 = REAL IP 1
> ROUTER with Linux
> eth1 = private IP
> |
> |
> HUB
> |
> |
> eth0 = REAL IP 2
> SERVER 1
>
> Can I route traffic to the REAL IP 2?
> How should I do it?
>
> REAL IP 1 and REAL IP 2 are in the same subnet.
>
> I've read some documents but I still dont't
> know how to set this up.
>
> I guess I have to put a fake ARP entry in eth0
> and add a host route in the ROUTER...


What do you mean with REAL_IP? Public IP? If yes, assing a private
IP to your server and do a DNAT on the router for the public IP,
that points to the private IP. eg
iptables -t nat -A PREROUTING -i eth0 -d $public_ip -j DNAT --to-destination $private_ip
and
iptables -t nat -A POSTROUTING -o eth0 -s $private_ip -j SNAT --to-source $public_ip

Allow any needed services in the FORWARD chain.

Greets
Chris

 
Reply With Quote
 
/dev/rob0
Guest
Posts: n/a

 
      04-27-2004, 08:19 PM
> On 27 Apr 2004 05:14:16 -0700
> (E-Mail Removed) (Nelson Castillo) wrote:
>> I'd like to route a real IP behind a static NAT.


Static NAT?

>> INTERNET
>> |
>> |
>> eth0 = REAL IP 1
>> ROUTER with Linux
>> eth1 = private IP
>> |


So far so good.

>> HUB
>> |
>> eth0 = REAL IP 2
>> SERVER 1


This might not work; I've never tried it though. Maybe with an arp
command on ROUTER and appropriate route table entries ... try it and
see.


>> Can I route traffic to the REAL IP 2?


ROUTER has to know to accept packets for REAL IP 2, and also have a
static route to deliver them out eth1.

>> I guess I have to put a fake ARP entry in eth0
>> and add a host route in the ROUTER...


Uh, yeah, that's it. Did you try this?

On Tue, 27 Apr 2004 20:23:09 +0200, Christoph Scheurer wrote:
> What do you mean with REAL_IP? Public IP? If yes, assing a private
> IP to your server and do a DNAT on the router for the public IP,
> that points to the private IP. eg
> iptables -t nat -A PREROUTING -i eth0 -d $public_ip -j DNAT \
> --to-destination $private_ip
> and
> iptables -t nat -A POSTROUTING -o eth0 -s $private_ip -j SNAT \
> --to-source $public_ip


This might work better, but the ROUTER needs an alias for eth0 ...
ifconfig eth0:server $REAL_IP_2
Then both machines will have private IP addresses on the internal
interface, with DNAT and SNAT rules as Chris suggests.

> Allow any needed services in the FORWARD chain.


Yes, and of course in either case:
echo 1 > /proc/sys/net/ipv4/ip_forward
--
/dev/rob0 - preferred_email=i$((28*28+28))@softhome.net
or put "not-spam" or "/dev/rob0" in Subject header to reply

 
Reply With Quote
 
P Gentry
Guest
Posts: n/a

 
      04-27-2004, 08:44 PM
(E-Mail Removed) (Nelson Castillo) wrote in message news:<(E-Mail Removed). com>...
> Hi.
>
> I'd like to route a real IP behind a static NAT.
>
> INTERNET
> |
> |
> eth0 = REAL IP 1
> ROUTER with Linux
> eth1 = private IP <<< this must be on same subnet as REAL IP 2
> |
> |
> HUB <<< this is just a signal re-generator,

everything in will go out all ports
> |
> |
> eth0 = REAL IP 2 <<< both ends must be on same subnet
> SERVER 1
>
> Can I route traffic to the REAL IP 2?
> How should I do it?


This is what a dmz is for -- a subnet you host to offer public (real
IP) services.

> REAL IP 1 and REAL IP 2 are in the same subnet.


A dmz capable router _may_ make more sense for your situation. With
Linux, you need a third (dmz) nic installed to keep the public segment
separate from the private lan segment.

> I've read some documents but I still dont't
> know how to set this up.


That's the first sign that this is not a good setup to deploy. Nics
are so cheap these days that it doesn't make sense to avoid the $20.
And it's a _whole_ lot easier to set up and maintain. Your proposed
setup offers _no_ advantages and lots of headaches.

> I guess I have to put a fake ARP entry in eth0
> and add a host route in the ROUTER...


And a bunch of other tricky entries as well. All the "tricks" you
perform to get it up, you will have to maintain and troubleshoot
around. I wouldn't think of doing it this way unless someone was
paying me. You would certainly learn a lot and might have this going
smoothly by Christmas -- assuming you don't have any surprises.

> Regards,
> Nelson.-


I'm not saying, "you _cannot_ do this, Grasshopper", but it would be
_very_ much easier to set up a "standard" configuration.

inet ----- (e0)Linux router (e2)----- private lan (hub or switch)
|
(e1 to public dmz)
|
public server

Make your life easier -- you deserve it.

hth,
prg
email above disabled
 
Reply With Quote
 
P Gentry
Guest
Posts: n/a

 
      04-28-2004, 04:17 AM
(E-Mail Removed) (Nelson Castillo) wrote in message news:<(E-Mail Removed). com>...
> Hi.
>
> I'd like to route a real IP behind a static NAT.
>
> INTERNET
> |
> |
> eth0 = REAL IP 1
> ROUTER with Linux
> eth1 = private IP
> |
> |
> HUB
> |
> |
> eth0 = REAL IP 2
> SERVER 1
>
> Can I route traffic to the REAL IP 2?
> How should I do it?
>
> REAL IP 1 and REAL IP 2 are in the same subnet.
>
> I've read some documents but I still dont't
> know how to set this up.
>
> I guess I have to put a fake ARP entry in eth0
> and add a host route in the ROUTER...
>
> Regards,
> Nelson.-


Just following up my own screwed up ascii art -- least that's how
looks on Google. Sorry, I'm terrible with ascii art -- any kind
actually.

inet
|
|
(eth0 -- public IP)
-----------------
linux router | (eth1 -- public IP) ---->dmz--->public server
-----------------
(eth2 -- private IP)
|
hub
|
private lan -- private IPs

prg
email above disabled
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to snat merrittr Linux Networking 0 10-17-2007 08:59 PM
Racoon with SNAT Can2002 Linux Networking 1 08-10-2005 05:25 PM
SNAT Kevin Brown Linux Networking 1 07-06-2005 09:30 PM
bridging fw and snat Wolfgang Kohnen Linux Networking 1 06-20-2005 06:31 PM
how to set SNAT? cranium.2003@gmail.com Linux Networking 0 05-09-2005 02:51 PM



1 2 3 4 5 6 7 8 9 10 11