LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-19-2010, 02:01 PM   #16
negativeground
LQ Newbie
 
Registered: Mar 2010
Location: Portland, OR
Posts: 13

Original Poster
Rep: Reputation: 0

Ugh. I figured out how to uninstall the app with a rpm -e <rpm name> command. I then deleted the /etc/rc.firewall config file that it created. Now the iptables service won't start (even after a reboot). service iptables start doesn't do anything, and a service iptables status just reads: Firewall is stopped.

Is there a log file I can look at to see what might be broken?

-Evan
 
Old 03-19-2010, 02:05 PM   #17
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Rep: Reputation: 148Reputation: 148
is it not running as a service? i think if you stop the guarddog service it will flush all the firewall rules which are imposed by guarddog
 
Old 03-19-2010, 02:06 PM   #18
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by negativeground View Post
Ugh. I figured out how to uninstall the app with a rpm -e <rpm name> command. I then deleted the /etc/rc.firewall config file that it created. Now the iptables service won't start (even after a reboot). service iptables start doesn't do anything, and a service iptables status just reads: Firewall is stopped.

Is there a log file I can look at to see what might be broken?

-Evan
What does iptables -nvL show now?

It doesn't sound like anything is broken, it sounds like it was properly set back into default.

Last edited by win32sux; 03-19-2010 at 02:13 PM.
 
Old 03-19-2010, 02:25 PM   #19
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
I'm on my way out, so I won't get your reply until later today. But I wanted to leave this script here with you. Basically, execute it and it'll populate your /etc/sysconfig/iptables file for you. You should then be able to reboot and see that the port 1521/TCP rule is loaded, with logging enabled. You can then proceed to confirm it works by doing a port scan.
Code:
#!/bin/sh

IPT="/sbin/iptables"

$IPT -P INPUT ACCEPT
$IPT -P FORWARD ACCEPT
$IPT -P OUTPUT ACCEPT

$IPT -t nat -P PREROUTING ACCEPT
$IPT -t nat -P POSTROUTING ACCEPT
$IPT -t nat -P OUTPUT ACCEPT

$IPT -t mangle -P PREROUTING ACCEPT
$IPT -t mangle -P INPUT ACCEPT
$IPT -t mangle -P FORWARD ACCEPT
$IPT -t mangle -P OUTPUT ACCEPT
$IPT -t mangle -P POSTROUTING ACCEPT

$IPT -t raw -P PREROUTING ACCEPT
$IPT -t raw -P OUTPUT ACCEPT

$IPT -F
$IPT -F -t nat
$IPT -F -t mangle
$IPT -F -t raw

$IPT -X
$IPT -X -t nat
$IPT -X -t mangle
$IPT -X -t raw

$IPT -A INPUT -p TCP -i eth0 --dport 1521 -j LOG --log-prefix "INPUT DROP: "
$IPT -A INPUT -p TCP -i eth0 --dport 1521 -j DROP

$IPT -Z
$IPT -Z -t nat
$IPT -Z -t mangle
$IPT -Z -t raw

$IPT-save > /etc/sysconfig/iptables
With this method, you don't need to add any commands to your startup scripts.
 
1 members found this post helpful.
Old 03-19-2010, 02:53 PM   #20
negativeground
LQ Newbie
 
Registered: Mar 2010
Location: Portland, OR
Posts: 13

Original Poster
Rep: Reputation: 0
Chain INPUT (policy ACCEPT 2336 packets, 2050K bytes)
pkts bytes target port opt in out source destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target port opt in out source destination

Chain OUTPUT (policy ACCEPT 2526 packets, 2536K bytes)
pkts bytes target port opt in out source destination

----
Looks like this is a normal "clean" config, correct?

Thanks so much for the script!! And thanks for adding the logging setting too! I'll run that today. What is the process for adding new "deny" ports? Just go into /etc/sysconfig/iptables and add a new line, using the same syntax as the ones you listed?

Cheers,

-Evan
 
Old 03-19-2010, 03:03 PM   #21
negativeground
LQ Newbie
 
Registered: Mar 2010
Location: Portland, OR
Posts: 13

Original Poster
Rep: Reputation: 0
Script ran fine. I can see the settings in /etc/sysconfig/iptables. But when I do a service iptables start I get:

Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter nat mangle raw [FAILED]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]

Any ideas? Or is this OK?

-Evan
 
Old 03-19-2010, 03:41 PM   #22
negativeground
LQ Newbie
 
Registered: Mar 2010
Location: Portland, OR
Posts: 13

Original Poster
Rep: Reputation: 0
Is this what is going on with the script? http://bugs.centos.org/view.php?id=1676
 
Old 03-19-2010, 07:27 PM   #23
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Yeah, that looks like the bug that's biting you. In fact, Red Hat themselves have a bug number assigned to this issue. The patch seems simple enough if you wanna go for it. Needless to say, backup the file before you edit it!

As for adding ports, I'd suggest editing the script and then re-executing it. This way your /etc/sysconfig/iptables file gets populated by the iptables-save binary itself, reducing the risk of human error.

Last edited by win32sux; 03-19-2010 at 07:28 PM.
 
Old 03-22-2010, 03:17 PM   #24
negativeground
LQ Newbie
 
Registered: Mar 2010
Location: Portland, OR
Posts: 13

Original Poster
Rep: Reputation: 0
Hey Thanks again. I'm trying to install that patch, but it doesn't include instructions for how to install the ".diff" attachement that they let you download. I tried just running it straight from a command line (like a .sh file) but it didn't work. Probably something easy I'm missing? This is the content of the file:

--- iptables.init 2004-09-17 11:41:31.000000000 +0100
+++ iptables.init.raw 2008-06-02 12:06:58.000000000 +0100
@@ -120,6 +120,11 @@
for i in $tables; do
echo -n "$i "
case "$i" in
+ raw)
+ $IPTABLES -t raw -P PREROUTING $policy \
+ && $IPTABLES -t raw -P OUTPUT $policy \
+ || let ret+=1
+ ;;
filter)
$IPTABLES -t filter -P INPUT $policy \
&& $IPTABLES -t filter -P OUTPUT $policy \





Cheers,

-Evan
 
Old 03-22-2010, 03:24 PM   #25
negativeground
LQ Newbie
 
Registered: Mar 2010
Location: Portland, OR
Posts: 13

Original Poster
Rep: Reputation: 0
Also, you've already helped a lot, and I don't want to bug you, but...

Why do I need the "nat", "mangle", and "raw" entries in there anyways? What purpose do they serve?
 
Old 03-22-2010, 04:13 PM   #26
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
A diff is intended to be applied using the patch command. In this case, however, the diff is so small that you could easily do it by hand (it's still a good idea for you to learn to use the patch command later on, though). Basically, the lines begining with a plus sign mean that the line is to be added. The lines without a plus (or minus) sign are there to provide context, so you can know what the chunk you need to edit looks like. In this case, you're basically inserting this:
Code:
raw)
$IPTABLES -t raw -P PREROUTING $policy \
&& $IPTABLES -t raw -P OUTPUT $policy \
|| let ret+=1
;;
...right before the "filter)" line.

Those tables are included in the script I posted in order to make sure absolutely everything is clean and pristine, which is something I consider to be a good habit.

Last edited by win32sux; 03-22-2010 at 04:23 PM.
 
  


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
Chromium doesn't save "default browser"+ Desktop isn't "snappy" ohadbasan Arch 1 01-25-2010 08:07 PM
Getting this error "Unable to set LC_ALL to default locale" Nabeel Mandriva 3 12-16-2009 04:33 AM
IPTables "Best Practice" default rule set robinBones Linux - Networking 2 01-09-2008 08:11 AM
Permanently set "route add" -host and default gw sacants Linux - Newbie 1 07-18-2003 04:04 AM
Set "default browser" Satriani Linux - Newbie 6 05-17-2003 07:11 AM

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

All times are GMT -5. The time now is 01:53 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