LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-02-2011, 05:10 AM   #31
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600

I think part of the problem stems from inexperience and you giving us incomplete information to start with:
- for instance the "/lib64/xtables/libipt_accept.so" warning shows you didn't realize Linux is case sensitive (it's "-j ACCEPT"),
- the fact /etc/sysconfig/iptables doesn't exist means it's either deleted (make backups!) or never initialized (see 'system-config-securitylevel'),
- the iptables commands you use each time result in an incomplete rule set and
- the "Chain TALLOW" reference indicates that, for whatever undisclosed reason, you chose to installed and use APF instead of the /etc/sysconfig/iptables rule set (so modifying the latter doesn't make sense).
- Besides that you run some blocking tools that, since you don't list iptables rules the proper way (easiest is to use 'iptables-save > /path/to/savefile'), may block things easily if ill configured.

I suggest you revisit your decision and use the Netfilter interface you are most comfortable with, uninstall anything that covers your "3) Installed few firewalls" in your initial post and then use the chosen tools or Centos documentation in conjunction with http://www.frozentux.net/documents/iptables-tutorial/.


For clarity this is a more default /etc/sysconfig/iptables:
Code:
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
COMMIT

...and this sums up much of what you want:
Code:
*filter
# [0]
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT
# [1]
-A INPUT -p icmp --icmp-type any -j ACCEPT
# [2]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# [3]
-A INPUT -m conntrack --ctstate INVALID -m limit --limit 1/minute --limit-burst 3 -j LOG --log-prefix "INVALID "
-A INPUT -m conntrack --ctstate INVALID -j REJECT --reject-with icmp-admin-prohibited
# [4]
-A INPUT -p tcp -m multiport --dports 80,8080 -m state --state NEW -j ACCEPT
-A INPUT -p tcp --dport 21 -m state --state NEW -j ACCEPT
-A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT
# [5]
-A INPUT -m limit --limit 1/minute --limit-burst 3 -j LOG --log-prefix "REJECT "
-A INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
0. Your requirement of "block everything, except.." is a policy thing. I also changed the input chain name because a) IMO "RH-Firewall-1-INPUT" is too long and b) I only edit the rule set by hand.
1. Rule below should actually contain only the type:code pairs you allow for ping and traceroute diagnostics.
2. Possibly tune rule order afterwards watching
Code:
watch -n 1 "/sbin/iptables -nvx --line-numbers -t filter -L INPUT|grep ^[0-9]|sort -bgrk 2"
for some time.
3. The most important thing to know wrt any troubleshooting is watchihng the logs. Iptables allows you to create rules that log traffic.
4. There's lots of modules for iptables to use. To get help on default modules you can always '/sbin/iptables -m modulename --help' or 'man iptables'.
5. Dropping anything else provides remote hosts an indication of what is denied.

YMMV(VM) so test the rule set before using it: save the above code as /etc/sysconfig/iptables then run 'service iptables start'.


HTH

Last edited by unSpawn; 12-03-2011 at 06:59 AM. Reason: // Replace RH-Firewall-1-INPUT with INPUT
 
Old 12-02-2011, 05:20 AM   #32
agriz
Member
 
Registered: Nov 2011
Posts: 197

Original Poster
Rep: Reputation: Disabled
Quote:
#iptables -F
#service iptables save

#service iptables restart
Quote:
iptables -P INPUT DROP
After this line, I am not able to access server
 
Old 12-02-2011, 05:58 AM   #33
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Please quote the appropriate post because I don't know who you are replying to. I'm certain it wasn't mine though. I never told you to issue the commands you posted and I told you to test the rule set before using it. The latter implies running it elsewhere, locally or say on a virtualization guest, before using it in production.
 
Old 12-02-2011, 08:02 AM   #34
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by unSpawn View Post
Please quote the appropriate post because I don't know who you are replying to. I'm certain it wasn't mine though. I never told you to issue the commands you posted and I told you to test the rule set before using it. The latter implies running it elsewhere, locally or say on a virtualization guest, before using it in production.
agriz says there is no

Code:
/etc/sysconfig/iptables
in his system

@agriz

I think after
Code:
#service iptables save
I asked you to check the output

Code:
#iptables -L
whether all the rules are deleted or still there...
why you are using

Code:
#iptables -P INPUT DROP
Try this to check for your config file as I have shown for mine

Code:
[root@server ~]# rpm -qa | grep iptables
iptables-1.3.5-1.2.1
iptables-ipv6-1.3.5-1.2.1

[root@server ~]# rpm -ql iptables-1.3.5-1.2.1
/etc/rc.d/init.d/iptables
/etc/sysconfig/iptables-config
/lib/iptables
 
Old 12-02-2011, 08:09 AM   #35
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by deep27ak View Post
agriz says there is no
Code:
/etc/sysconfig/iptables
in his system
No need for scratching heads: just read my post again (line 3). Other than that I'll leave you to it wrestling with iptables, APF and whatever else the OP seems to have installed. Good luck!
 
Old 12-02-2011, 08:32 AM   #36
klearview
Member
 
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
Quote:
Originally Posted by unSpawn View Post
No need for scratching heads: just read my post again (line 3). Other than that I'll leave you to it wrestling with iptables, APF and whatever else the OP seems to have installed. Good luck!
https://www.linuxquestions.org/quest...1/#post4538898
 
Old 12-02-2011, 08:36 AM   #37
agriz
Member
 
Registered: Nov 2011
Posts: 197

Original Poster
Rep: Reputation: Disabled
Right now, I am not able to access the server. Please kindly stay with me to help me on this.
I will soon get access. I shouldn't have entered the drop rule.
 
Old 12-02-2011, 12:17 PM   #38
agriz
Member
 
Registered: Nov 2011
Posts: 197

Original Poster
Rep: Reputation: Disabled
Hi, I got the access again. IPTABLES is stopped now.
 
Old 12-03-2011, 12:31 AM   #39
agriz
Member
 
Registered: Nov 2011
Posts: 197

Original Poster
Rep: Reputation: Disabled
Quote:
iptables -L
I Enabled IPTABLES

Quote:
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
Quote:
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
Quote:
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
Quote:
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
Quote:
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:webcache
ACCEPT tcp -- anywhere anywhere tcp dpt:xx
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Am i good to enter
Quote:
iptables -P INPUT DROP
?!?!
 
Old 12-03-2011, 02:12 AM   #40
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
No. As per the "default" config given by Unspawn here, you are missing the defaults. If you DROP by default there, any outbound connection you make won't be allowed back in etc. http://www.linuxquestions.org/questi...ml#post4540053

I would say stop iptables and recreate the sysconfig/iptables file. I'll admit I've no experience with APF though, so I'm unclear how any config you've got from installing that (why did you install it?) might affect the loading of the normal config file. Running a "service iptables save", does the etc/sysconfig/iptables file get created with the few lines you've added? if so I presume it's safe to replace that file with the default (plus your additions) OR Unspawns first draft of a finished rulebase and start iptables up again.
 
Old 12-03-2011, 02:35 AM   #41
agriz
Member
 
Registered: Nov 2011
Posts: 197

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by acid_kewpie View Post
No. As per the "default" config given by Unspawn here, you are missing the defaults. If you DROP by default there, any outbound connection you make won't be allowed back in etc. http://www.linuxquestions.org/questi...ml#post4540053

I would say stop iptables and recreate the sysconfig/iptables file. I'll admit I've no experience with APF though, so I'm unclear how any config you've got from installing that (why did you install it?) might affect the loading of the normal config file. Running a "service iptables save", does the etc/sysconfig/iptables file get created with the few lines you've added? if so I presume it's safe to replace that file with the default (plus your additions) OR Unspawns first draft of a finished rulebase and start iptables up again.
APF is settings have been disabled.
etc/sysconfig/iptables - I can see this file now.

Where is default file located?
If i replace, Should i block and unblock the required ports?
 
Old 12-04-2011, 05:15 AM   #42
agriz
Member
 
Registered: Nov 2011
Posts: 197

Original Poster
Rep: Reputation: Disabled
Hi I just fixed the iptables issues.

Site is loading.
But I am not able to use wget to download files, yum to install.

The settings are


Quote:
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP

Quote:
iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT

# 5. Allow incoming HTTPS
iptables -A INPUT -i eth0 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT
I think it is because of OUTPUT is only ESTABLISHED, Not NEW

Is it secured setting?
Will it run the site properly?

Thanks for your helps.

[I was blocked last time because i didn't allow the ssh port and denied all the ports. very funny mistake!]
 
Old 12-04-2011, 08:27 AM   #43
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by agriz View Post
Hi I just fixed the iptables issues.
You did, eh?


Quote:
Originally Posted by agriz View Post
The settings are
...dead wrong.


Quote:
Originally Posted by agriz View Post
very funny mistake!
For you it may be but for those who are (still) trying to help you it is not. You say "Yes, I agree" when cautioned but I wonder if you really understand what agreeing actually means. You have been given advice, documents to read and examples to boot and yet you blithely ignore about everything. If there is a language barrier or a lack of basic Linux knowledge or if you are just not that interested then please say so.
 
Old 12-04-2011, 08:29 AM   #44
agriz
Member
 
Registered: Nov 2011
Posts: 197

Original Poster
Rep: Reputation: Disabled
I did read documents!
After that only i created those new rules.

I didn't post the sshd port rule here. I have changed the sshd port to 22 to something else.
Why do you say it is wrong?
 
Old 12-04-2011, 08:38 AM   #45
agriz
Member
 
Registered: Nov 2011
Posts: 197

Original Poster
Rep: Reputation: Disabled
It really hurts when you tell that i am not interested!
With my one week linux knowledge, I am trying my best to secure the site.

I don't know why do you say i am not interested
 
  


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
Loading website problem surfer41 Debian 3 12-02-2006 08:11 PM
Problem loading website LetMeTryToo Linux - Software 2 11-23-2006 03:31 AM
wierd loading of website titanium_geek LQ Suggestions & Feedback 3 06-02-2005 10:16 AM
Not sure where to post for help with website loading AndeAnderson Linux - Newbie 5 04-15-2005 07:07 AM
Images not loading in website robojerk Linux - Newbie 1 02-17-2005 09:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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