netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* NAT question
@ 2012-01-25 15:54 Stephen Clark
  2012-01-25 16:47 ` richard -rw- weinberger
  2012-01-25 16:52 ` Eric Dumazet
  0 siblings, 2 replies; 4+ messages in thread
From: Stephen Clark @ 2012-01-25 15:54 UTC (permalink / raw)
  To: Linux Kernel Network Developers

Can iptables do a network to network nat without having to write out a 
bunch of nat rules.
In other words translate  192.168.198.0/24 to 172.16.10.0/24 without 
having to write out
256 rules.

Also can iptables handle 1000 nat rules like above if they have to be 
written out on
a 1.66ghz intel dual core atom with 1gb of mem.

I know this isn't appropriate question for devel list but I didn't find 
anything googling.

Thanks,

-- 

"They that give up essential liberty to obtain temporary safety,
deserve neither liberty nor safety."  (Ben Franklin)

"The course of history shows that as a government grows, liberty
decreases."  (Thomas Jefferson)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: NAT question
  2012-01-25 15:54 NAT question Stephen Clark
@ 2012-01-25 16:47 ` richard -rw- weinberger
  2012-01-25 16:52 ` Eric Dumazet
  1 sibling, 0 replies; 4+ messages in thread
From: richard -rw- weinberger @ 2012-01-25 16:47 UTC (permalink / raw)
  To: sclark46; +Cc: Linux Kernel Network Developers

On Wed, Jan 25, 2012 at 4:54 PM, Stephen Clark <sclark46@earthlink.net> wrote:
> Can iptables do a network to network nat without having to write out a bunch
> of nat rules.
> In other words translate  192.168.198.0/24 to 172.16.10.0/24 without having
> to write out
> 256 rules.
>

Maybe the NETMAP target is the right thing for you.

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: NAT question
  2012-01-25 15:54 NAT question Stephen Clark
  2012-01-25 16:47 ` richard -rw- weinberger
@ 2012-01-25 16:52 ` Eric Dumazet
  2012-01-25 17:28   ` Stephen Clark
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2012-01-25 16:52 UTC (permalink / raw)
  To: sclark46; +Cc: Linux Kernel Network Developers

Le mercredi 25 janvier 2012 à 10:54 -0500, Stephen Clark a écrit :
> Can iptables do a network to network nat without having to write out a 
> bunch of nat rules.
> In other words translate  192.168.198.0/24 to 172.16.10.0/24 without 
> having to write out
> 256 rules.
> 
> Also can iptables handle 1000 nat rules like above if they have to be 
> written out on
> a 1.66ghz intel dual core atom with 1gb of mem.
> 
> I know this isn't appropriate question for devel list but I didn't find 
> anything googling.
> 
> Thanks,
> 

If you are forced to use 256 rules, you could split them into 16 tables
of 16 rules and do a hash split.

Since these rules are run only for new connections, it might be OK
performance wise, depending on rate of connection establishment.

If not, you can try NETMAP :)

# iptables -t nat -A POSTROUTING -s 192.168.198.0/24 -j NETMAP --to 172.16.10.0/24

# iptables -t nat -nvL POSTROUTING
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 NETMAP     all  --  *      *       192.168.198.0/24     0.0.0.0/0           172.16.10.0/24

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: NAT question
  2012-01-25 16:52 ` Eric Dumazet
@ 2012-01-25 17:28   ` Stephen Clark
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Clark @ 2012-01-25 17:28 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Linux Kernel Network Developers

On 01/25/2012 11:52 AM, Eric Dumazet wrote:
> Le mercredi 25 janvier 2012 à 10:54 -0500, Stephen Clark a écrit :
>    
>> Can iptables do a network to network nat without having to write out a
>> bunch of nat rules.
>> In other words translate  192.168.198.0/24 to 172.16.10.0/24 without
>> having to write out
>> 256 rules.
>>
>> Also can iptables handle 1000 nat rules like above if they have to be
>> written out on
>> a 1.66ghz intel dual core atom with 1gb of mem.
>>
>> I know this isn't appropriate question for devel list but I didn't find
>> anything googling.
>>
>> Thanks,
>>
>>      
> If you are forced to use 256 rules, you could split them into 16 tables
> of 16 rules and do a hash split.
>
> Since these rules are run only for new connections, it might be OK
> performance wise, depending on rate of connection establishment.
>
> If not, you can try NETMAP :)
>
> # iptables -t nat -A POSTROUTING -s 192.168.198.0/24 -j NETMAP --to 172.16.10.0/24
>
> # iptables -t nat -nvL POSTROUTING
> Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
>   pkts bytes target     prot opt in     out     source               destination
>      0     0 NETMAP     all  --  *      *       192.168.198.0/24     0.0.0.0/0           172.16.10.0/24
>
>    
Thanks Eric,

I assume I need an additional rule like this to translate in the other 
direction?
iptables -t nat -A POSTROUTING -s 172.16.10.0/24 -j NETMAP --to 
198.168.198.0/24

iptables -t nat -nvL POSTROUTING
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
  pkts bytes target     prot opt in     out     source               
destination

    15  2535 NETMAP     all  --  *      *       192.168.198.0/24     
0.0.0.0/0           172.16.10.0/24
     0     0 NETMAP     all  --  *      *       172.16.10.0/24       
0.0.0.0/0           198.168.198.0/24


Also now that I am clued to NETMAP I found this example:
iptables -t mangle -A PREROUTING -s 192.168.1.0/24 -j NETMAP --to 
10.5.6.0/24

using mangle and PREROUTING - does it matter?

"They that give up essential liberty to obtain temporary safety,
deserve neither liberty nor safety."  (Ben Franklin)

"The course of history shows that as a government grows, liberty
decreases."  (Thomas Jefferson)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-25 17:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-25 15:54 NAT question Stephen Clark
2012-01-25 16:47 ` richard -rw- weinberger
2012-01-25 16:52 ` Eric Dumazet
2012-01-25 17:28   ` Stephen Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).