static NAT with iptables

This is a discussion on static NAT with iptables within the Linux Networking forums, part of the Linux Forums category; Using iptables like this: iptables -t nat -A POSTROUTING -j SNAT -s 10.0.0.0/24 --to-source 172....


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-16-2004
RR
 
Posts: n/a
Default static NAT with iptables

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
  #2 (permalink)  
Old 02-17-2004
David Cutting
 
Posts: n/a
Default Re: static NAT with iptables

"RR" <newspaper.20.broom@spamgourmet.com> wrote in message
news:BcaYb.62863$Wa.49234@news-server.bigpond.net.au...
> 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
  #3 (permalink)  
Old 02-20-2004
RR
 
Posts: n/a
Default Re: static NAT with iptables


"David Cutting" <dcutting@spambuster.purplepixie.org> wrote in message
news:c0u0od$a9g$1$8300dec7@news.demon.co.uk...
>
> 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
  #4 (permalink)  
Old 02-20-2004
David Cutting
 
Posts: n/a
Default Re: static NAT with iptables

"RR" <newspaper.20.broom@spamgourmet.com> wrote in message
news:IxeZb.67418$Wa.13757@news-server.bigpond.net.au...
>
> "David Cutting" <dcutting@spambuster.purplepixie.org> wrote in message
> news:c0u0od$a9g$1$8300dec7@news.demon.co.uk...
> >
> > 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
  #5 (permalink)  
Old 02-26-2004
The Free Electron
 
Posts: n/a
Default Re: static NAT with iptables



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

"David Cutting" <dcutting@spambuster.purplepixie.org> wrote in message
news:c0u0od$a9g$1$8300dec7@news.demon.co.uk...
| "RR" <newspaper.20.broom@spamgourmet.com> wrote in message
| news:BcaYb.62863$Wa.49234@news-server.bigpond.net.au...
| > 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
  #6 (permalink)  
Old 02-28-2004
Cameron Kerr
 
Posts: n/a
Default Re: static NAT with iptables

The Free Electron <srambyte@cvol.net> 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
cameron.kerr@paradise.net.nz : http://nzgeeks.org/cameron/
Empowered by Perl!
Reply With Quote
  #7 (permalink)  
Old 03-04-2004
Aaron
 
Posts: n/a
Default Re: static NAT with iptables

"RR" <newspaper.20.broom@spamgourmet.com> wrote in message news:<IxeZb.67418$Wa.13757@news-server.bigpond.net.au>...
> "David Cutting" <dcutting@spambuster.purplepixie.org> wrote in message
> news:c0u0od$a9g$1$8300dec7@news.demon.co.uk...
> >
> > 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 Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:19 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0