niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » *nix » Linux » networking
Basic IP Tables issue
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
Llanzlan Klazmon
*nix forums Guru Wannabe


Joined: 11 Apr 2005
Posts: 159

PostPosted: Thu Jul 20, 2006 12:22 am    Post subject: Re: Basic IP Tables issue Reply with quote

"spec" <frank@frankritchie.com> wrote in
news:1153351274.688340.70920@i42g2000cwa.googlegroups.com:

Quote:
exactly, I should have mentioned that I am totally new to IPTables and
trying to edit an existing script.

What syntax can be used to specify that only certain source addresses
are allowed to be sent to the email server?

Ok. You would replace the current line in your script for the FORWARD
chain with something like:

$IPTABLES -A FORWARD -s a1.a2.a3.a4 -d $MAIL_EXT_IP -j ACCEPT
$IPTABLES -A FORWARD -s b1.b2.b3.b4 -d $MAIL_EXT_IP -j ACCEPT
$IPTABLES -A FORWARD -s 0/0 -d $MAIL_EXT_IP -j DROP

You don't need the third line if DROP is the default policy of your
forward chain. This will allow any IP from the two source addresses a1....
b1... Of course you can define variables for the two allowed source
addresses like you did for the email server external address etc. You can
be still more specific if you want to go down to protocol and port.

For example:

$IPTABLES -A FORWARD -s $ALLOWED_IP1 -p TCP --destination-port 25 -d
$MAIL_EXT_IP -j ACCEPT


Here's a good tutorial:

http://iptables-tutorial.frozentux.net/iptables-tutorial.html

Also these:

http://www.netfilter.org/documentation/index.html#documentation-howto

Klazmon.

Quote:

Thanks
Frank

Llanzlan Klazmon wrote:
"spec" <frank@frankritchie.com> wrote in news:1153324667.626248.166340
@s13g2000cwa.googlegroups.com:

Right now there is a firewall in place for a mail server as follows:

## mail.foo.com ##
MAIL_EXT_IP="x.x.x.x"
MAIL_INT_IP="y.y.y.y"
$IPTABLES -A FORWARD -i $OUTSIDE -d $MAIL_EXT_IP -j ACCEPT

## Mail traffic will be forwarded to the mail server ##
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 22 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 25 -j DNAT --to-destination $MAIL_INT_IP
#$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 80 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 110 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 993 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 995 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p all -i $OUTSIDE -d $MAIL_EXT_IP -j
DROP

Would it be possible to modify this so that port 25 is only open for
2 incoming IP addresses
rather than forwarding all port 25 traffic?

One way would be to make your forward chain more specific. At present
your forward chain allows anything at all from the outside interface to
go to for email server.

Klazmon.




Thanks
Frank



Back to top
spec
*nix forums beginner


Joined: 19 Jun 2006
Posts: 8

PostPosted: Wed Jul 19, 2006 11:21 pm    Post subject: Re: Basic IP Tables issue Reply with quote

exactly, I should have mentioned that I am totally new to IPTables and
trying to edit an existing script.

What syntax can be used to specify that only certain source addresses
are allowed to be sent to the email server?

Thanks
Frank

Llanzlan Klazmon wrote:
Quote:
"spec" <frank@frankritchie.com> wrote in news:1153324667.626248.166340
@s13g2000cwa.googlegroups.com:

Right now there is a firewall in place for a mail server as follows:

## mail.foo.com ##
MAIL_EXT_IP="x.x.x.x"
MAIL_INT_IP="y.y.y.y"
$IPTABLES -A FORWARD -i $OUTSIDE -d $MAIL_EXT_IP -j ACCEPT

## Mail traffic will be forwarded to the mail server ##
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 22 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 25 -j DNAT --to-destination $MAIL_INT_IP
#$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 80 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 110 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 993 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 995 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p all -i $OUTSIDE -d $MAIL_EXT_IP -j
DROP

Would it be possible to modify this so that port 25 is only open for 2
incoming IP addresses
rather than forwarding all port 25 traffic?

One way would be to make your forward chain more specific. At present your
forward chain allows anything at all from the outside interface to go to
for email server.

Klazmon.




Thanks
Frank

Back to top
Llanzlan Klazmon
*nix forums Guru Wannabe


Joined: 11 Apr 2005
Posts: 159

PostPosted: Wed Jul 19, 2006 11:12 pm    Post subject: Re: Basic IP Tables issue Reply with quote

"spec" <frank@frankritchie.com> wrote in news:1153324667.626248.166340
@s13g2000cwa.googlegroups.com:

Quote:
Right now there is a firewall in place for a mail server as follows:

## mail.foo.com ##
MAIL_EXT_IP="x.x.x.x"
MAIL_INT_IP="y.y.y.y"
$IPTABLES -A FORWARD -i $OUTSIDE -d $MAIL_EXT_IP -j ACCEPT

## Mail traffic will be forwarded to the mail server ##
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 22 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 25 -j DNAT --to-destination $MAIL_INT_IP
#$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 80 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 110 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 993 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 995 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p all -i $OUTSIDE -d $MAIL_EXT_IP -j
DROP

Would it be possible to modify this so that port 25 is only open for 2
incoming IP addresses
rather than forwarding all port 25 traffic?

One way would be to make your forward chain more specific. At present your
forward chain allows anything at all from the outside interface to go to
for email server.

Klazmon.



Quote:

Thanks
Frank

Back to top
spec
*nix forums beginner


Joined: 19 Jun 2006
Posts: 8

PostPosted: Wed Jul 19, 2006 3:57 pm    Post subject: Basic IP Tables issue Reply with quote

Right now there is a firewall in place for a mail server as follows:

## mail.foo.com ##
MAIL_EXT_IP="x.x.x.x"
MAIL_INT_IP="y.y.y.y"
$IPTABLES -A FORWARD -i $OUTSIDE -d $MAIL_EXT_IP -j ACCEPT

## Mail traffic will be forwarded to the mail server ##
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 22 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 25 -j DNAT --to-destination $MAIL_INT_IP
#$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 80 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 110 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 993 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p tcp -i $OUTSIDE -d $MAIL_EXT_IP
--dport 995 -j DNAT --to-destination $MAIL_INT_IP
$IPTABLES -t nat -A PREROUTING -p all -i $OUTSIDE -d $MAIL_EXT_IP -j
DROP

Would it be possible to modify this so that port 25 is only open for 2
incoming IP addresses
rather than forwarding all port 25 traffic?

Thanks
Frank
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Thu Dec 04, 2008 2:07 am | All times are GMT
navigation Forum index » *nix » Linux » networking
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts TLS cert issue Nick Smith Postfix 3 Thu Jul 20, 2006 7:40 pm
No new posts Root relay issue Johnson, S Postfix 4 Thu Jul 20, 2006 6:50 pm
No new posts Creating a relationship between 2 tables Andyza Oracle 2 Thu Jul 20, 2006 1:11 pm
No new posts Linking Tables from 2 databases Pratik Shukla PostgreSQL 2 Wed Jul 19, 2006 5:54 pm
No new posts Weird MemoryError issue jedi200581@yahoo.co.uk python 4 Wed Jul 19, 2006 3:58 pm

Personal Injury Lawyer Los Angeles | Shares | Free Advertising | Buy PSP | Free Cingular Ringtones
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.3541s ][ Queries: 20 (0.2474s) ][ GZIP on - Debug on ]