Jump to content
Калькуляторы

SNAT --persistent определить соответствие IP

Доброго времени!

 

Есть нат сервер:

 

-A POSTROUTING -s 10.140.0.0/14 -j SNAT --to-source 1.2.3.1-1.2.3.254 --persistent

-A POSTROUTING -s 10.144.0.0/14 -j SNAT --to-source 1.2.3.1-1.2.3.254 --persistent

-A POSTROUTING -s 10.0.0.0/8 -j SNAT --to-source 1.2.4.1-1.2.4.254 --persistent

 

Есть список ип адресов, в разных сетях.

 

Как определить, по этому списку, и вводным данным какой у каждого локального ип будет внешний адрес?

 

 

Спасибо.

Share this post


Link to post
Share on other sites

только из логов NAT-трансляций

 

Если раньше запросы приходили в виде "кто заходил на ип такойто порт такой-то в такое-то время", то сейчас не заморачиваются.

 

"Кто ковырялся в контактиках в с такого-то вашего ип, во времена такого-то ига ".

Адрес трансляции остается стабильным, значит формула таки есть. Может кто ковырял? Или выгребалка и сохранялка готовая есть?

Share this post


Link to post
Share on other sites

До kernel 3.3 было по формуле, сырцы для поиска серых по белому есть на форуме, потом запилили туда рандом и теперь только сливать трансляции

Share this post


Link to post
Share on other sites

ipt_netflow, кстати, умеет NEL:

 

* NAT translations events (from conntrack) using NetFlow Event Logging (NEL).

This is standardized way for v9/IPFIXr, but module export such events even

for v5 collectors via specially crafted pseudo-records.

..

Configure script allows to enable or disable optional features:

 

--enable-natevents

enables natevents (NEL) support

 

 

...

6. If you want to account NAT events (NEL):

 

# sysctl net.netflow.natevents=1

 

Note that natevents feature is completely independent from traffic accounting

(it's using so called conntrack events), thus you don't need to set or change

any iptables rules to use that. You may need to enable kernel config option

CONFIG_NF_CONNTRACK_EVENTS though (if it isn't already enabled).

For details on how they are exported for different protocol versions see

below.

 

...

natevents=1

- Collect and send NAT translation events as NetFlow Event Logging (NEL)

for NetFlow v9/IPFIX, or as dummy flows compatible with NetFlow v5.

Default is 0 (don't send).

 

For NetFlow v5 protocol meaning of fields in dummy flows are such:

Src IP, Src Port is Pre-nat source address.

Dst IP, Dst Port is Post-nat destination address.

- These two fields made equal to data flows catched in FORWARD chain.

Nexthop, Src AS is Post-nat source address for SNAT. Or,

Nexthop, Dst AS is Pre-nat destination address for DNAT.

TCP Flags is SYN+SCK for start event, RST+FIN for stop event.

Pkt/Traffic size is 0 (zero), so it won't interfere with accounting.

 

Natevents are compilation disabled by default, to enable you will need to

add --enable-natevents option to ./configure script.

 

For techical description of NAT Events see:

http://tools.ietf.or...-nat-logging-04

 

 

 

Мы используем в netflow v5, очень удобная штука.

Edited by Dyr

Share this post


Link to post
Share on other sites

ipt_netflow, конечно же. Думаю про одно, пишу другое. )

ТС нужно как раз именно это, поскольку из его ТЗ вытекает необходимость сообщить о такой привязке за какую-то дату. Зачем изобретать велосипед с собственным сборщиком этой информации, если есть стандартизованный инструмент?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.