LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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-03-2016, 11:37 PM   #1
lzande
LQ Newbie
 
Registered: Jul 2016
Posts: 2

Rep: Reputation: Disabled
iptables help for centos 6.8


Hello all. Sorry if this has been posted before. I'm new to iptables and I'm having an issue with them. My iptables when on, are blocking yum and wget. Can anyone help me? Below is my current /etc/sysconfig/iptables file:

Code:
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [124:7812]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT

#allow outside users to Ping us
-A INPUT -p icmp --icmp-type echo-request -j ACCEPT

#ssh
-A INPUT -p tcp -m tcp --dport 2927 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22  -m state --state NEW,ESTABLISHED -j ACCEPT

#apache
-A INPUT -p tcp -m tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT

#loopback
-A INPUT -i lo -j ACCEPT

#dns
-A INPUT -p udp -i eth0 --sport 53 -j ACCEPT

#sendmail
-A INPUT -i eth0 -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT

#prevent the Denial of Service (DoS)
-A INPUT -p tcp --dport 80 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT

#allow outside users to Ping us
-A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT

#ssh out
-A OUTPUT -p tcp -m tcp --sport 2927 -m state --state ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT

#apache out
-A OUTPUT -o eth0 -p tcp -m tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
-A OUTPUT -o eth0 -p tcp -m tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT

#loopback out
-A OUTPUT -o lo -j ACCEPT

#dns out
-A OUTPUT -p udp -o eth0 --dport 53 -j ACCEPT

#sendmail out
-A OUTPUT -o eth0 -p tcp --sport 25 -m state --state ESTABLISHED -j ACCEPT

#unknown rules
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -p icmp -j ACCEPT

COMMIT
 
Old 07-05-2016, 12:01 PM   #2
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Rules are read top to bottom. As such some things you have are not required or not working as you would have expected them too.

Because of this rule:

Code:
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
You don't have to add ESTABLISHED to your other rules.

This rule
Code:
-A INPUT -p icmp -j ACCEPT
Makes this rule useless
Code:
-A INPUT -p icmp --icmp-type echo-request -j ACCEPT
This rule should always be the fist rule in every chain:
Code:
-m state --state RELATED,ESTABLISHED -j ACCEPT
You can try the fllowing rules which should do what you wanted to do and allow your outbound connections:
Code:
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [124:7812]
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p icmp --icmp-type echo-request -j ACCEPT
-A INPUT -p tcp -m tcp --dport 2927 -m conntrack --ctstate NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22  -m conntrack --ctstate NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW -m limit --limit 25/minute --limit-burst 100 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -m conntrack --ctstate NEW -m limit --limit 25/minute --limit-burst 100 -j ACCEPT
# If you are running a DNS server then uncomment the following line
#-A INPUT -p udp -m udp --sport 53 -m conntrack --ctstate NEW -j ACCEPT
# If you are running a mail server then uncommant the following
#-A INPUT -p tcp -m tcp --dport 25 -m conntrack --ctstate NEW -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A OUTPUT -m conntrack --ctstate NEW,RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
You should read this IPTABLES TUTORIAL to help you out.
 
Old 07-05-2016, 05:01 PM   #3
lzande
LQ Newbie
 
Registered: Jul 2016
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks for all the help lazydog. Your rule set worked. How did you get so good at iptables.
 
Old 07-07-2016, 11:55 AM   #4
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Reading that tutorial listed above along with trial and error
 
  


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
IPtables PortMirroring Centos 6.4 gdizzle Linux - Networking 3 07-23-2013 01:43 AM
iptables on centOS Niso Linux - Distributions 1 03-28-2013 03:17 AM
CentOS 6.3, disable iptables piyush.sharma Linux - Server 5 11-27-2012 08:44 AM
[SOLVED] CentOS 5.5 - iptables keeps clearing markbad311 Linux - Newbie 1 01-05-2012 06:48 PM
CentOS Iptables joncruz Linux - Newbie 1 09-29-2009 07:39 PM

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

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