From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rob Sterenborg" Subject: RE: Iptables Date: Tue, 28 Sep 2004 07:25:28 +0200 Sender: netfilter-bounces@lists.netfilter.org Message-ID: <20040928052524.ABB11E2C@sterenborg.info> References: Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: netfilter-bounces@lists.netfilter.org Content-Type: text/plain; charset="us-ascii" To: 'Contact' , netfilter@lists.netfilter.org. netfilter-bounces@lists.netfilter.org wrote: > Hi, > > I'm new to iptables and having a problem grasping the concept as well > as the syntax. I have read a lot of sites on this but just not > getting it. First - running rules. From what I can gather I need to > have an rc.firewall file with the various rules and such in it - and The filename depends on your system and/or what you define to be a startup script. > have this started at boot. Am I close? Second - the syntax. I want > to be able to allow my local LAN full access to the Linux box > (Slackware 10). I also have a website which I want to allow everyone Ah. Slack. Yes, if you put a rc.firewall file in /etc/rc.d and do a "chmod 700 rc.firewall" there, it will start at boot (if I read rc.inet2 correctly). > - except for a few domains and IP's, SSH which I want to allow only > certain IP's or domains, and Samba which I want to allow only my > local LAN. This is where I'm really confused putting this all > together. If someone could explain this in plain english - or put me > on to a really easy iptables for dummies type site, it would be > appreciated. > > This box is behind attached to a Linksys router and does not act as a > NAT. It is just a simple little setup on a p166. Okay. You want to close your box as much as possible : iptables -P INPUT DROP iptables -P FORWARD DROP iptables -P OUTPUT ACCEPT # because in the beginning it will cause \ # you headaches if you DROP this Next, allow related and established connections : iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT Allow full access from LAN : iptables -A INPUT -i -s -j ACCEPT Allow access to website (running on the firewall box I assume) : iptables -A INPUT -i -s -p tcp --dport 80 \ -j DROP ...Repeat for any disallowed host... iptables -A INPUT -i -p tcp --dport 80 -j ACCEPT Allow access to SSH : iptables -A INPUT -i -s -p tcp \ --dport 22 -j ACCEPT ...Repeat for any allowed host... You already opened up your box for your LAN. That includes Samba so you don't need a rule for this. Do you also want internet access for your LAN clients ? iptables -A FORWARD -i -o -s \ -j ACCEPT iptables -t nat -A POSTROUTING -o -s \ -j SNAT --to-source A good reading site includes Oskar's : http://iptables-tutorial.frozentux.net/iptables-tutorial.html Gr, Rob