All of lore.kernel.org
 help / color / mirror / Atom feed
* iptables DNAT algorithm -- another way?
@ 2014-12-12 23:55 John Miller
  2014-12-13  0:50 ` Neal Murphy
  0 siblings, 1 reply; 8+ messages in thread
From: John Miller @ 2014-12-12 23:55 UTC (permalink / raw)
  To: netfilter

Hi folks,

We're running a server that scan local systems for installed SSL 
certificates.  Problem is, the tool truly means local -- RFC1918 private
ranges only, please.  Being a university, we have quite a few things 
located in public IP space that aren't necessarily world-accessible
(development servers and the like).

My solution thus far has been to use DNAT to trick our scanning program
into thinking it's using local addresses.

iptables -t nat -A OUTPUT -d 172.16.x.y -j DNAT \
     --to-destination 129.64.x.y

Trouble is that I want a direct correspondence: the third and fourth 
octets need to be the same for source and destination.  I can certainly 
set ranges for initial and final destination address, but the NAT 
algorithm picks the destination at random.  Is there a way to accomplish 
this in iptables?  With another netfilter tool?  I'd like to avoid running

#!/bin/sh
for third_octet in {0..255}; do
     for fourth_octet in {0..255}; do
         iptables -t nat -A OUTPUT \
             -d 172.16.${third_octet}.${fourth_octet} -j DNAT \
             --to-destination 129.64.${third_octet}.${fourth_octet}
     done
done

and ending up with 2^16 separate iptables rules.

John
-- 
John Miller
Systems Engineer
Brandeis University
johnmill@brandeis.edu


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

end of thread, other threads:[~2014-12-14  3:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-12 23:55 iptables DNAT algorithm -- another way? John Miller
2014-12-13  0:50 ` Neal Murphy
2014-12-13  1:06   ` John Miller
2014-12-13  1:26     ` Neal Murphy
2014-12-13  9:21   ` Pascal Hambourg
2014-12-13 19:52     ` John Miller
2014-12-13 21:30       ` Pascal Hambourg
2014-12-14  3:30         ` John Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.