LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-07-2008, 01:00 PM   #1
wag2639
LQ Newbie
 
Registered: Mar 2008
Posts: 7

Rep: Reputation: 0
iptables port forwarding logging


After looking up numerous forums, including here, I got my port forwarding to work. It's something like this:

echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 22022 -j DNAT --to 123.123.123.23:22
/sbin/iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 22023 -j DNAT --to 123.123.123.54:22
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/sbin/iptables -A FORWARD -p tcp --dport 22 -j ACCEPT


Now my question is, how do I log these port forwards to a specific place, something like /var/logs/portfowards.log?

Thanks
 
Old 07-07-2008, 11:12 PM   #2
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
You can put a rule with a LOG target into the NAT table with the same conditions as the DNAT rule. eg
Code:
 /sbin/iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 22022 -j LOG --log-prefix PortForward:
Put this just before the corresponding DNAT rule, and you will get stuff in the /var/log/messages file by default. To put them into another file, you have limited choices with the standard syslog facilities. A better scheme uses syslog-ng, which gives you more flexibility in sorting and routing log messages.
 
Old 07-08-2008, 10:15 AM   #3
wag2639
LQ Newbie
 
Registered: Mar 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks. I can't seem to figure out how to use the syslog. I'm using a Fedora 9. I have an rsyslog but I don't know how to use that.
 
Old 07-08-2008, 10:41 AM   #4
tbergfeld
LQ Newbie
 
Registered: Jun 2008
Posts: 5

Rep: Reputation: 0
Hi
I know it's a bit late...
but try looking at this link...perhaps you will find something can help you:
http://www.rsyslog.com/doc
 
  


Reply

Tags
forwarding, iptables, log, logging, port



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 On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables port forwarding _kure_ Linux - Networking 7 01-16-2012 04:19 AM
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
iptables port forwarding abdul_zu Linux - General 1 02-05-2006 03:39 AM
port forwarding with iptables kkennedy Linux - Networking 1 09-01-2005 06:48 PM
iptables port forwarding jefmwols Linux - Networking 9 05-20-2005 04:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration