LinuxQuestions.org
Help answer threads with 0 replies.
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-13-2013, 08:56 PM   #1
mkools
LQ Newbie
 
Registered: Oct 2004
Posts: 15

Rep: Reputation: 0
iptables locks me out, but only on one server


This is weird, I have 2 VPS servers, OpenVZ, both CentOS 6.4 x64, they're exactly the same.
This is the iptables script I'm using (Purpose: allow all outgoing, restrict mysql, allow SSH)

Code:
#!/bin/bash --
LANG=C; LC_ALL=C; export LANG LC_ALL
iptables -F; iptables -X

# List policies first
iptables -P INPUT DROP; iptables -P FORWARD DROP; iptables -P OUTPUT ACCEPT

# Always allow loopback
iptables -A INPUT -i lo -j ACCEPT

# Performance-wise let this back in early:
iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT

# Allow public services
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

# Allow MySQL only from specific networks
iptables -A INPUT -m state --state NEW -m tcp -p tcp -s 1.1.1.1/24 --dport 3306 -j ACCEPT
iptables -A INPUT -m state --state NEW -m tcp -p tcp -s 2.2.2.2/24 --dport 3306 -j ACCEPT

# No traffic should reach this line
iptables -A INPUT -j LOG --log-prefix "IN_LEFTOVERS "
iptables -A OUTPUT -j ACCEPT

# Always end a script the right way
exit 0
Now, I run this on one machine and everything is fine. Everything works. When I run it on the other machine the system locks me out completely and I have to flush the rules to regain access, SSH, MySQL everything gets blocked.

What am I doing wrong?

Thanks!
 
Old 07-14-2013, 01:32 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,334

Rep: Reputation: Disabled
Having both -m tcp and -p tcp seems redundant. Other than that it looks fine.

Actually, the man pages list the syntax for the "tcp" match as -m tcp --protocol tcp, which should be equivalent to -p tcp. Could it be that the problematic server has a version of iptables that chokes on -m tcp -p tcp? That would certainly explain why you get locked out, as the remaining rules don't allow anything but connections matching the ESTABLISHED condition.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
rsync hangs and locks server lylemwood Linux - Software 4 08-25-2010 04:26 AM
iptables rules for web server email server,ftp and ssh,please help lightwing Linux - Networking 1 03-25-2009 08:58 PM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM
X-Server error locks up keyboard after restart Cloud Nine Linux - Software 1 10-15-2005 07:18 PM
[IPTABLES] open ext access to web server on GW server kozaki Linux - Networking 3 08-27-2005 05:11 PM

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

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