Networking Forums

Networking Forums > Computer Networking > Linux Networking > static NAT with iptables

Reply
Thread Tools Display Modes

static NAT with iptables

 
 
RR
Guest
Posts: n/a

 
      02-16-2004, 08:01 PM
Using iptables like this:

iptables -t nat -A POSTROUTING -j SNAT -s 10.0.0.0/24 --to-source
172.16.1.0-172.16.1.255 -o ppp0

This works, but not the way I want. The NATing occurs using "random" IP
addresses in the given range.

What I want is:
10.0.0.1 -> 172.16.1.1
10.0.0.2 -> 172.16.1.2
etc.

This is for a VPN and if I can get iptables to do this, then FTP will work
in passive mode across the link.

This is a basic static NAT setup, but it seems iptables wants to be too
clever.

Any idea how to do what I want?

tia,
RR


 
Reply With Quote
 
 
 
 
David Cutting
Guest
Posts: n/a

 
      02-17-2004, 08:23 PM
"RR" <(E-Mail Removed)> wrote in message
news:BcaYb.62863$(E-Mail Removed)...
> Using iptables like this:
>
> iptables -t nat -A POSTROUTING -j SNAT -s 10.0.0.0/24 --to-source
> 172.16.1.0-172.16.1.255 -o ppp0
>
> This works, but not the way I want. The NATing occurs using "random" IP
> addresses in the given range.
>
> What I want is:
> 10.0.0.1 -> 172.16.1.1
> 10.0.0.2 -> 172.16.1.2
> etc.
>
> This is for a VPN and if I can get iptables to do this, then FTP will work
> in passive mode across the link.

[snip]

I don't think there is a way unless of course --to-dest 172.17.1.0/24
works which I doubt ;o)

I would have a little shell script that went from .1 to .254 and added
a line for each host to map to the other host for what it's worth.

Cheers,

Dave.


 
Reply With Quote
 
RR
Guest
Posts: n/a

 
      02-20-2004, 01:46 AM

"David Cutting" <(E-Mail Removed)> wrote in message
news:c0u0od$a9g$1$(E-Mail Removed)...
>
> I would have a little shell script that went from .1 to .254 and added
> a line for each host to map to the other host for what it's worth.
>


Yes, that's what I had done - was looking for a better solution.

Thanks for your reply.

RR


 
Reply With Quote
 
David Cutting
Guest
Posts: n/a

 
      02-20-2004, 06:57 AM
"RR" <(E-Mail Removed)> wrote in message
news:IxeZb.67418$(E-Mail Removed)...
>
> "David Cutting" <(E-Mail Removed)> wrote in message
> news:c0u0od$a9g$1$(E-Mail Removed)...
> >
> > I would have a little shell script that went from .1 to .254 and added
> > a line for each host to map to the other host for what it's worth.
> >

>
> Yes, that's what I had done - was looking for a better solution.


Ah! That puts us in the same boat then. I'll monitor any
other replies you get and see if there's a better way ;o)

Cheers,

Dave.


 
Reply With Quote
 
The Free Electron
Guest
Posts: n/a

 
      02-26-2004, 07:14 PM


/* An Infinite Number Of Primates, Pounded A Million Keyboards, And Came
Up With Microsoft Code */

"David Cutting" <(E-Mail Removed)> wrote in message
news:c0u0od$a9g$1$(E-Mail Removed)...
| "RR" <(E-Mail Removed)> wrote in message
| news:BcaYb.62863$(E-Mail Removed)...
| > Using iptables like this:
| >
| > iptables -t nat -A POSTROUTING -j SNAT -s
10.0.0.0/24 --to-source
| > 172.16.1.0-172.16.1.255 -o ppp0
| >
| > This works, but not the way I want. The NATing occurs using
"random" IP
| > addresses in the given range.
| >
| > What I want is:
| > 10.0.0.1 -> 172.16.1.1
| > 10.0.0.2 -> 172.16.1.2
| > etc.
| >
| > This is for a VPN and if I can get iptables to do this, then FTP
will work
| > in passive mode across the link.
| [snip]
|
| I don't think there is a way unless of course --to-dest 172.17.1.0/24
| works which I doubt ;o)
|
| I would have a little shell script that went from .1 to .254 and added
| a line for each host to map to the other host for what it's worth.
|
| Cheers,
|
| Dave.
|
Have been having similar "problems" with passive ftp ports.
From "Noi" @ linux.redhat.misc :
#Allow passive ftp
-A INPUT -p tcp --sport 1024: --dport 1024: -m state --state
ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp --sport 1024: --dport 1024: -m state --state
ESTABLISHED,RELATED -j ACCEPT

May be what you are looking for (?)
HTH
Don

 
Reply With Quote
 
Cameron Kerr
Guest
Posts: n/a

 
      02-27-2004, 11:52 PM
The Free Electron <(E-Mail Removed)> wrote:

> Have been having similar "problems" with passive ftp ports.
> From "Noi" @ linux.redhat.misc :
> #Allow passive ftp
> -A INPUT -p tcp --sport 1024: --dport 1024: -m state --state
> ESTABLISHED -j ACCEPT
> -A OUTPUT -p tcp --sport 1024: --dport 1024: -m state --state
> ESTABLISHED,RELATED -j ACCEPT


What on earth does port 1024 have to do with FTP.

--
Cameron Kerr
(E-Mail Removed) : http://nzgeeks.org/cameron/
Empowered by Perl!
 
Reply With Quote
 
Aaron
Guest
Posts: n/a

 
      03-04-2004, 07:35 PM
"RR" <(E-Mail Removed)> wrote in message news:<IxeZb.67418$(E-Mail Removed)>...
> "David Cutting" <(E-Mail Removed)> wrote in message
> news:c0u0od$a9g$1$(E-Mail Removed)...
> >
> > I would have a little shell script that went from .1 to .254 and added
> > a line for each host to map to the other host for what it's worth.
> >

>
> Yes, that's what I had done - was looking for a better solution.
>
> Thanks for your reply.
>
> RR


There is a better solution. there is a patchomatic solution called
netmap which will let you do exactly what you want DNATing the whole
class c.
 
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
How do I set-up static IP Travis M. Network Routers 2 10-01-2006 06:05 AM
Is there any static ARP concept for static IP network? linux.lover2004@gmail.com Linux Networking 6 05-19-2005 01:40 PM
Looking for iptables applications code (iptables.c) to run some rules to forward packets tvnaidu@yahoo.com Linux Networking 2 01-17-2005 05:01 PM
Static Ip's and BT - I have just recieved A BT router with 5 static IP Addresses. However, I want 5 computers in the office to use only one of the addresses. ery Difficult Question Nattasian Broadband 3 07-13-2004 08:55 AM
iptables "can't initialize iptables table `filter'" pete Linux Networking 1 10-10-2003 03:44 AM



1 2 3 4 5 6 7 8 9 10 11