LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 07-09-2004, 02:47 PM   #1
sdpnme3
LQ Newbie
 
Registered: Jul 2004
Posts: 2

Rep: Reputation: 0
Help with IPTABLES -


I'm one of those newbie guys so I apologize upfront for asking a simple question, but
all I want to do is run a Nessus server which is connected directly to the internet for
external vulnerability scans of all my networks.

So:

I want the server to basically not respond to any requests except for two unique ip addresses that will connect to the server on 1241:tcp and 22:tcp. Because this server will be on the Internet, I don't trust eth0, however the server will need to be able to initiate outbound session on all ports, afterall it is going to be scanning ports 0-1024 and other specific ports

Running RH Entv3 - and thought this could be handled running lokkit, but when I review the IPTABLES -list, my read on the rules says I don't have this setup correctly. Lokkit doesn't allow me to setup specific source addresses to restrict comms to either. Then again, today is the first day I've ever looked at a set of IPTABLES rules - so as stated I apologize for being so clueless.

Below is the IPTABLES as currently listed..

Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere
(THIS SEEMS TO SAY ALLOW EVERYTHING INBOUND FROM ETH0)

Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere
(MY BOX IS NOT A ROUTER, ALTHOUGH IT DOES HAVE TWO ETH INTERFACES
ONLY ONE IS ACTIVE)

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

(WHAT'S UP WITH THIS - NO OUTBOUND PACKETS ALLOWED ?)

Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
(DOESN'T THIS RULE ALLOW EVERYTHING ?)
ACCEPT icmp -- anywhere anywhere icmp any
ACCEPT ipv6-crypt-- anywhere anywhere
ACCEPT ipv6-auth-- anywhere anywhere
ACCEPT all -- anywhere anywhere state RELATED,ESTABL ISHED
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:12 41
REJECT all -- anywhere anywhere reject-with icmp-hos t-prohibited

Appreciate any feedback - I think I'm going to need some specific details on IPTABLES command lines to get me started....Hope you are up to the challenge.
 
Old 07-09-2004, 03:38 PM   #2
fataldata
Member
 
Registered: Jun 2002
Location: Breckenridge, Colorado
Distribution: Ubuntu Hardy 8.04
Posts: 101

Rep: Reputation: 15
Well it's been awhile but I'll try a couple of your Q's.

<<<Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere
(THIS SEEMS TO SAY ALLOW EVERYTHING INBOUND FROM ETH0)>>>

This Chain is set to a default policy of ACCEPT, so if something is not covered by "RH-Firewall-1-INPUT" then it is accepted.

<<<Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere
(MY BOX IS NOT A ROUTER, ALTHOUGH IT DOES HAVE TWO ETH INTERFACES
ONLY ONE IS ACTIVE)>>>

Change this policy to REJECT if you are concerned.
cmd: iptables -P FORWARD REJECT

<<<Chain OUTPUT (policy ACCEPT)
target prot opt source destination

(WHAT'S UP WITH THIS - NO OUTBOUND PACKETS ALLOWED ?)>>>

No, the default policy is to ACCEPT. Meaning that if there is no rule then it will accept packets from the kernel that are OUTBOUND.

<<<
Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
(DOESN'T THIS RULE ALLOW EVERYTHING ?)
>>>

Yes. I'm not sure how the rules are traversed. For instance I thought that once the packet matched a rule, then it exited the firewall and stopped comparing to the following rules. But as I said it's been a while and I need to read up on this myself.
 
Old 07-09-2004, 04:07 PM   #3
Capt_Caveman
Senior Member
 
Registered: Mar 2003
Distribution: Fedora
Posts: 3,658

Rep: Reputation: 69
Re: Help with IPTABLES -

Lokkit doesn't allow me to setup specific source addresses to restrict comms to either.
Lokkit isn't really useful for setting up anything but fairly basic firewalls. If you need more complex rules, then you really need to use iptables directly.

Then again, today is the first day I've ever looked at a set of IPTABLES rules - so as stated I apologize for being so clueless.
No need to apologize. We've all been clueless about it at some point and iptables syntanx isn't very straight forward.

The best way to get an idea of the state of the firewall is to use "iptables -n -L -v" (you'll see why in a sec.)
Code:
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere  
(THIS SEEMS TO SAY ALLOW EVERYTHING INBOUND FROM ETH0)

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere
(MY BOX IS NOT A ROUTER, ALTHOUGH IT DOES HAVE TWO ETH INTERFACES
ONLY ONE IS ACTIVE)
What is going on here with the INPUT and FORWARD chains is that lokkit creates a custom user-defined chain called "RH-Firewall-1-INPUT" which is where lokkit does all the packet filtering. For the packets to get passed to this filtering chain, the above rules are basically taking all INPUT and FORWARD packets (all incoming packets) and loads them all into the top of the RH-Firewall-1-INPUT chain. The packets then move through that chain and are compared to all the rules in that chain and are dropped/accepted/etc to each of the rules.

Code:
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

(WHAT'S UP WITH THIS - NO OUTBOUND PACKETS ALLOWED ?)
Since the default rule for the OUTPUT chain is ACCEPT (see the part that says "policy ACCEPT " above), all outbound packets will allowed out. So basically no egress filtering is done, which isn't the most secure thing in the world, but does prevent the firewall from interfering with applications you are running.

Code:
Chain RH-Firewall-1-INPUT (2 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
(DOESN'T THIS RULE ALLOW EVERYTHING ?)
If you do the iptables -n -L -v command, I'm pretty sure you'll see that this rule applies only to the loopback adapter interface which should be only handling local traffic on the machine.

Code:
ACCEPT     icmp --  anywhere             anywhere           icmp any 
ACCEPT     ipv6-crypt--  anywhere             anywhere
ACCEPT     ipv6-auth--  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABL ISHED
ACCEPT     tcp  --  anywhere             anywhere           state NEW tcp dpt:12 41
REJECT     all  --  anywhere             anywhere           reject-with icmp-hos t-prohibited
The first rule in this block of rules allows icmp (ping) traffic, which you may or may not want. There in bold is the rule for nessus. Your actually only allowing NEW connections, but the line before it allows all ESTABLISHED and RELATED traffic, so that should do the trick. So up to this point, you've only allowed ping, some ipv6 traffic, traffic you initiate and nessus traffic. The last rule is going to reject any other inbound traffic. Bear in mind that REJECT is not the samething as drop, so your machine will technically respond to incoming traffic (it will respond with an icmp host-prohibited message), which again may not be what you want.

As far as limiting the nessus traffic to 2 source IPs goes. I don't think lokkit can do that, but the iptables rules would be fairly straight forward:

iptables -I INPUT -s X.X.X.X -p tcp --dport 1241 -j ACCEPT

where X.X.X.X is the IP you want to allow. You can then remove the lokkit rule you've added.

Last edited by Capt_Caveman; 07-09-2004 at 04:11 PM.
 
Old 07-15-2004, 09:38 PM   #4
sdpnme3
LQ Newbie
 
Registered: Jul 2004
Posts: 2

Original Poster
Rep: Reputation: 0
You guys rock, thanks for the great responses. They got me out of the jam.

Thanks a million.
 
Old 07-18-2004, 09:27 AM   #5
jcliburn
Member
 
Registered: Dec 2003
Location: Mississippi, USA
Distribution: Fedora
Posts: 435

Rep: Reputation: 33
sdpnme3,

You mentioned your use of Nessus at the top of this thread. I've been playing with it for the past few days to get a completely clean Nessus scan (using the out-of-the-box default scan settings) and thought I'd offer this heads-up...

If you use the default Nessus scan parameters, it may identify a couple of low-risk issues that you can solve with the following iptables rules. (I typed these from my handwritten notes, so forgive me if I whacked the syntax. They give you the right idea, though, I think...)

# mitigate against the nessus tcp SYN-FIN warning
iptables -A INPUT -p tcp --tcp-flags ALL SYN,FIN -j DROP

# mitigate against the nessus icmp timestamp warning
iptables -A INPUT -p icmp -icmp-type timestamp-request -j DROP
iptables -A OUTPUT -p icmp -icmp-type timestamp-reply -j DROP
 
  


Reply



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
An error occured getting IPtables status from the command /etc/rc.d/init.d/iptables s CrazyMAzeY Linux - Newbie 10 08-12-2010 05:25 AM
Iptables - Couldn't load target `ACCPET':/lib/iptables/libipt_ACCPET.so: z00t Linux - Security 3 01-26-2004 02:24 AM
IPtables Log Analyzer from http://www.gege.org/iptables/ brainlego Linux - Software 0 08-11-2003 06:08 AM
iptables book wich one can you pll recomment to be an iptables expert? linuxownt Linux - General 2 06-26-2003 04:38 PM
My iptables script is /etc/sysconfig/iptables. How do i make this baby execute on boo ForumKid Linux - General 3 01-22-2002 07:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 12:47 AM.

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