Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
iptables question
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
ba747heavy
Apprentice
Apprentice


Joined: 11 Aug 2003
Posts: 216
Location: New Mexico, USA

PostPosted: Wed Aug 20, 2003 3:03 am    Post subject: iptables question Reply with quote

I tried searching this forum for 'iptables', and I gave up after I read the 4th page of results(of 30 or so...)

Anyway, my first question is: Where can I find a good tutorial for iptables thing? I have tried linuxdoc.org and I could only find something on ipchains

And my second question is, how would you accomplish the following goals of my firewall?

1) I run a mail server(IMAP and pop) on my box. I want to allow all related traffic.
2) Allow all ftp and http traffic.
3) I run AMSN, and I want to open any ports(if any) that the MSN protocol uses.
4) Block the rest of the traffic

I would assume some very simple rules would accomplish this. Am I missing some things in my proposed 'openings'?
_________________
Fred Clausen
"leet [speak] is a cry for help from a shallow mind" - Doomwookie Jan 05
Back to top
View user's profile Send private message
Decibels
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1630
Location: U.S.A.

PostPosted: Wed Aug 20, 2003 3:10 am    Post subject: Reply with quote

Here are some links:

There is a script near the end on there you should be able to figure out fairly easy:
http://webpages.charter.net/decibelshelp/LinuxHelp_IPtables.html#ip_masq

Then at the bottom is some links to iptables info I found useful.
Back to top
View user's profile Send private message
ba747heavy
Apprentice
Apprentice


Joined: 11 Aug 2003
Posts: 216
Location: New Mexico, USA

PostPosted: Wed Aug 20, 2003 3:11 am    Post subject: Reply with quote

Thanks!
_________________
Fred Clausen
"leet [speak] is a cry for help from a shallow mind" - Doomwookie Jan 05
Back to top
View user's profile Send private message
To
Veteran
Veteran


Joined: 12 Apr 2003
Posts: 1145
Location: Coimbra, Portugal

PostPosted: Wed Aug 20, 2003 9:17 am    Post subject: Reply with quote

Try also www.netfilter.org on the user docs part, the howto's are great. Rusty's has donne a great work :wink:


_________________

------------------------------------------------
Linux Gandalf 3.2.35-grsec
Gentoo Base System version 2.2
------------------------------------------------
Back to top
View user's profile Send private message
ba747heavy
Apprentice
Apprentice


Joined: 11 Aug 2003
Posts: 216
Location: New Mexico, USA

PostPosted: Wed Aug 20, 2003 2:14 pm    Post subject: Reply with quote

Thanks! I will check this out :D
_________________
Fred Clausen
"leet [speak] is a cry for help from a shallow mind" - Doomwookie Jan 05
Back to top
View user's profile Send private message
ba747heavy
Apprentice
Apprentice


Joined: 11 Aug 2003
Posts: 216
Location: New Mexico, USA

PostPosted: Wed Aug 20, 2003 5:52 pm    Post subject: Reply with quote

Using the example script that I found in a link in post #2, I find that some sites are now refusing to load up. For instance, forums.gentoo.org is refusing to load up in opera unless I cycle the firewall off and then back on. Several other sites are that way as well. Here is the relevant part of my firewall script(I made some changes).
Code:

iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -N myfilter
iptables -A myfilter -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A myfilter -m state --state NEW -i ! $CABLEE -j ACCEPT
iptables -A myfilter -m state --state INVALID -j LOG --log-prefix "INVALID:" --log-level warning
iptables -A myfilter -p tcp -j REJECT --reject-with tcp-reset
iptables -A myfilter -j REJECT --reject-with icmp-port-unreachable
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -i $CABLEE -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o $CABLEE -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i $CABLEE -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o $CABLEE -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i $CABLEE -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o $CABLEE -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i $CABLEE -p tcp --sport 25 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o $CABLEE -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p icmp -i $CABLEE --icmp-type echo-request -m limit --limit 1/minute -j LOG --log-prefix "PING:" -- log-level notice
iptables -A INPUT -p icmp -i $CABLEE --icmp-type echo-request -m limit --limit 2/second -j ACCEPT
if [ "$FRWD" -eq 1 ]
then
  iptables -A FORWARD -j myfilter
fi
if [ "$FRWD" -eq 1 ]
then
{
  iptables -A FORWARD -i $CABLEE -o $LANE -m state --state ESTABLISHED,RELATED -j ACCEPT
  #iptables -A FORWARD -i $LANE -o $CABLEE -j ACCEPT
  iptables -A FORWARD -j LOG
  iptables -t nat -A POSTROUTING -o $CABLEE -j MASQUERADE
}
fi
iptables -A INPUT -i $CABLEE -p tcp --dport 137:139 -j ACCEPT


Thanks gentlemen!
_________________
Fred Clausen
"leet [speak] is a cry for help from a shallow mind" - Doomwookie Jan 05
Back to top
View user's profile Send private message
vert
Apprentice
Apprentice


Joined: 07 May 2002
Posts: 214
Location: Delft, The Netherlands

PostPosted: Thu Aug 21, 2003 1:30 pm    Post subject: Reply with quote

Take a look at your logs (kernel or iptables log) and see if you can find packets that belong to those sites that are dropped and what rule causes it.
Also, I recently started using fwbuilder (www.fwbuilder.org). This tool allows you to create a firewall by drag-and-drop in an object oriented gui. There's an ebuild for it.
Back to top
View user's profile Send private message
ba747heavy
Apprentice
Apprentice


Joined: 11 Aug 2003
Posts: 216
Location: New Mexico, USA

PostPosted: Thu Aug 21, 2003 10:07 pm    Post subject: Reply with quote

Thanks, I will do that!
_________________
Fred Clausen
"leet [speak] is a cry for help from a shallow mind" - Doomwookie Jan 05
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum