NAT and log traffic
Hi folks..
I have made two NAT box for a special dialup server. I have create an iptables stratup script like that..
/usr/local/sbin/iptables -t nat -A POSTROUTING -s 10.20.2.0/23 -o eth0 -j SNAT --to PUBLIC-IP1 /usr/local/sbin/iptables -t nat -A POSTROUTING -s 10.20.4.0/23 -o eth0 -j SNAT --to PUBLIC-IP2 /usr/local/sbin/iptables -t nat -A POSTROUTING -s 10.20.6.0/23 -o eth0 -j SNAT --to PUBLIC-IP3 /usr/local/sbin/iptables -t nat -A POSTROUTING -s 10.20.8.0/23 -o eth0 -j SNAT --to PUBLIC-IP4 /usr/local/sbin/iptables -t nat -A POSTROUTING -s 10.20.10.0/23 -o eth0 -j SNAT --to PUBLIC-IP5 /usr/local/sbin/iptables -t nat -A POSTROUTING -s 10.20.12.0/23 -o eth0 -j SNAT --to PUBLIC-IP6 /usr/local/sbin/iptables -t nat -A POSTROUTING -s 10.20.14.0/23 -o eth0 -j SNAT --to PUBLIC-IP7
and so on..
Now.. i need to LOG all the traffic that transit over the rules.. I need to log at least PUBLIC-IPX and DESTINATION-IP.
A friend of that mailing list wrote me back and told..
change your string like that
/usr/local/sbin/iptables -t nat -A POSTROUTING -s 10.20.0.0/23 -o eth0 -j LOG --log-level debug --log-prefix "POSTRT: " /usr/local/sbin/iptables -t nat -A POSTROUTING -s 10.20.0.0/23 -o eth0 -j SNAT --to PUBLIC-IP1
I did that and added that over syslog.conf
# For NAT
*.* /var/log/nat.log
but i don't see any datas logged over that file..
See that..
75 3727
LOG all -- * eth0 10.20.0.0/23 0.0.0.0/0 LOG flags 0 level 7 prefix `POSTRT: '
75 3727
SNAT all -- * eth0 10.20.0.0/23 0.0.0.0/0 to:xxx.x.xx.x
I generated the traffic over that rule but nothing appear over the log file.
Any idea ?
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Simone Sestini [ SS971-RIPE ]
Plug IT s.p.a. - Technical Office
Via Galileo Ferraris 216
52100 Arezzo
Titles:
System and Network Administrator
Data Transmission Manager
Fax +39 199 440088
E-mail [email protected]
Web http://www.plugit.it
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Quoted 18 lines
I have made two NAT box for a special dialup server. I have create an iptables stratup script like that..
/usr/local/sbin/iptables-t nat -A POSTROUTING -s 10.20.2.0/23 -o eth0 -j SNAT --to PUBLIC-IP1/usr/local/sbin/iptables-t nat -A POSTROUTING -s 10.20.4.0/23 -o eth0 -j SNAT --to PUBLIC-IP2/usr/local/sbin/iptables-t nat -A POSTROUTING -s 10.20.6.0/23 -o eth0 -j SNAT --to PUBLIC-IP3/usr/local/sbin/iptables-t nat -A POSTROUTING -s 10.20.8.0/23 -o eth0 -j SNAT --to PUBLIC-IP4/usr/local/sbin/iptables-t nat -A POSTROUTING -s 10.20.10.0/23 -o eth0 -j SNAT --to PUBLIC-IP5/usr/local/sbin/iptables-t nat -A POSTROUTING -s 10.20.12.0/23 -o eth0 -j SNAT --to PUBLIC-IP6/usr/local/sbin/iptables-t nat -A POSTROUTING -s 10.20.14.0/23 -o eth0 -j SNAT --to PUBLIC-IP7
Quoted 2 lines
and so on..
Is that /23 or /24 ?
Quoted 10 lines
Now.. i need to LOG all the traffic that transit over the rules.. I need to log at least PUBLIC-IPX and DESTINATION-IP.
A friend of that mailing list wrote me back and told..
change your string like that
/usr/local/sbin/iptables-t nat -A POSTROUTING -s 10.20.0.0/23 -o eth0 -j
LOG --log-level debug --log-prefix
Quoted 2 lines
"POSTRT: "
/usr/local/sbin/iptables-t nat -A POSTROUTING -s 10.20.0.0/23 -o eth0 -j SNAT --to PUBLIC-IP1
I think that 10.20.0.0/23 does not cover all of 10.20.2.0/23, 10.20.4.0/23, etc...
If you're trying to capture all the nets into 1 rule then you'd need a mask of 10.20.0.0/255.255.0.0, which is 10.20.0.0/16.
Rob
On Wed, 15 Jan 2003 16:08:03 +0100,
"Rob Sterenborg" <[email protected]> wrote in message <[email protected]>:
Quoted 2 lines
I think that 10.20.0.0/23 does not cover all of 10.20.2.0/23,
10.20.4.0/23, etc...
..output of: $ ipcalc -bnmp 10.20.2.0/23
NETMASK=255.255.254.0
PREFIX=23
BROADCAST=10.20.3.255
NETWORK=10.20.2.0
Signature · 4 lines
..med vennlig hilsen = with Kind Regards from Arnt... ;-) ...with a number of polar bear hunters in his ancestry... Scenarios always come in sets of three: best case, worst case, and just in case.
Quoted 18 lines · Rob Sterenborg
Quoted 18 lines
I have made two NAT box for a special dialup server. I have create an iptables stratup script like that..
/usr/local/sbin/iptables-t nat -A POSTROUTING -s
10.20.2.0/23 -o eth0 -j SNAT --to PUBLIC-IP1/usr/local/sbin/iptables-t nat -A POSTROUTING -s
10.20.4.0/23 -o eth0 -j SNAT --to PUBLIC-IP2/usr/local/sbin/iptables-t nat -A POSTROUTING -s
10.20.6.0/23 -o eth0 -j SNAT --to PUBLIC-IP3/usr/local/sbin/iptables-t nat -A POSTROUTING -s
10.20.8.0/23 -o eth0 -j SNAT --to PUBLIC-IP4/usr/local/sbin/iptables-t nat -A POSTROUTING -s
10.20.10.0/23 -o eth0 -j SNAT --to PUBLIC-IP5/usr/local/sbin/iptables-t nat -A POSTROUTING -s
10.20.12.0/23 -o eth0 -j SNAT --to PUBLIC-IP6/usr/local/sbin/iptables-t nat -A POSTROUTING -s
10.20.14.0/23 -o eth0 -j SNAT --to PUBLIC-IP7
Quoted 8 lines
Quoted 1 line
and so on..
Is that /23 or /24 ?
I think that 10.20.0.0/23 does not cover all of 10.20.2.0/23, 10.20.4.0/23, etc...
If you're trying to capture all the nets into 1 rule then you'd need a mask of 10.20.0.0/255.255.0.0, which is 10.20.0.0/16.
This will work for what he appears to be trying to do. He's trying to capture 512 addresses in each rule. A network defined as 10.20.2.0/23 will catch 10.20.2.0-10.20.2.255 and 10.20.3.0-10.20.3.255. /24 would specify that the first three numbers must match exactly. /23 means that the third can vary in only the least significant bit, IE .128 and .129, .16 and .17.
http://www.wildpackets.com/products In the lower-right they have a free subnet calculator for Windows (which I see you're emailing from) and also one for PalmOS. Really handy, that PalmOS one is.
Apart from that, a quick Google will find several subnet mask calculators, several platform-independant online ones.
As Arnt Karlsen added in his reply:
Quoted 5 lines
..output of: $ ipcalc -bnmp 10.20.2.0/23
NETMASK=255.255.254.0
PREFIX=23
BROADCAST=10.20.3.255
NETWORK=10.20.2.0
And to this I have to add that the same results derive from 10.20.3.0/23
j
Quoted 37 lines · Simone Sestini
Hi folks..
I have made two NAT box for a special dialup server. I have create an iptables stratup script like that..
/usr/local/sbin/iptables-t nat -A POSTROUTING -s 10.20.2.0/23 -o eth0 -j SNAT --to PUBLIC-IP1/usr/local/sbin/iptables-t nat -A POSTROUTING -s 10.20.4.0/23 -o eth0 -j SNAT --to PUBLIC-IP2and so on..
Now.. i need to LOG all the traffic that transit over the rules.. I need to log at least PUBLIC-IPX and DESTINATION-IP.
A friend of that mailing list wrote me back and told..
change your string like that
/usr/local/sbin/iptables-t nat -A POSTROUTING -s 10.20.0.0/23 -o eth0 -j LOG --log-level debug --log-prefix "POSTRT: "/usr/local/sbin/iptables-t nat -A POSTROUTING -s 10.20.0.0/23 -o eth0 -j SNAT --to PUBLIC-IP1I did that and added that over syslog.conf
# For NAT
*.*/var/log/nat.logbut i don't see any datas logged over that file..
See that..
75 3727 LOG all -- * eth0 10.20.0.0/23 0.0.0.0/0 LOG flags 0 level 7 prefix `POSTRT: ' 75 3727
Quoted 7 lines
SNAT all -- * eth0 10.20.0.0/23 0.0.0.0/0
to:xxx.x.xx.xI generated the traffic over that rule but nothing appear over the log file.
Any idea ?
The log by default goes to /var/log/messages with other kernel logging. You CAN redirect it, but with the LOG target all you can do is specify the log-level, and then redirect ALL kernel logs of that level with changes to syslog.conf. Usually 'debug' is tolerably empty of other logging, so his suggestion of rules is reasonable. (although you could improve it by having the log-prefix itself indicate which rule matched, rather than even having to read the log data itself) However, the syslog.conf change you made doesn't make sense to me.
Try 'man syslog.conf' for info, but using the *.* will redirect ALL logging of EVERYTHING to the destination file. In order to redirect kernel debug logging ONLY, you need something like:
kernel.=debug /var/log/natlog
to specify that ONLY debug level of kernel logs go to the specified file. Also, I believe you will need to restart syslogd in order for the change to be effective.
BTW, You might want to consider adding "-m state state NEW" to your logging rules. This will log ONLY new connections, rather than every single packet that goes out. As long as all you are interested in is the fact that a connection was initiated, and the source and destination, this will be MUCH easier on your system. If you really need to gather information on EVERYTHING, then I suggest you look into a ULOG accounting package, which will gather information directed to it through the ULOG target and compile whatever information you need without creating massive logfiles.
j
Quoted 16 lines
Simone Sestini [ SS971-RIPE ]
Plug IT s.p.a. - Technical Office
Via Galileo Ferraris 216
52100 ArezzoTitles:
System and Network Administrator
Data Transmission ManagerFax +39 199 440088
E-mail [email protected]
Web http://www.plugit.it