LinuxQuestions.org
Help answer threads with 0 replies.
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 05-17-2013, 08:02 PM   #1
capri_guy84
LQ Newbie
 
Registered: Mar 2009
Posts: 1

Rep: Reputation: 0
iptables for a server in colo NAT/PAT


I cannot connect with the below IPTables ruleset. Can someone proofread and point any mistakes?


My server is behind a firewall that does a PAT & NAT to the LAN address.
Code:
Internet IP: 68.1.1.23
Port: 10022

Server LAN IP: 10.1.1.23
port: 22

Allowed Internet IPs:  131.1.1.23, 132.1.1.23
/etc/sysconfig/iptables

Code:
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
#:RH-Firewall-1-INPUT - [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#-A INPUT -j RH-Firewall-1-INPUT

# ALLOW SSH
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
# ALLOW SNMP
-A INPUT -p tcp -m tcp --dport 161 -j ACCEPT
# ALLOW DNS query
-A INPUT -p udp --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT

# ALLOW ICMP
-A INPUT -p icmp -m icmp --icmp-type 8 -m recent --update --seconds 2 --hitcount 1 --name DEFAULT --rsource -j DROP
-A INPUT -p icmp -m icmp --icmp-type 8 -m recent --set --name DEFAULT --rsource

# BLOCK certain IP/Subnets
-A INPUT -s 10.2.1.254/8 -p icmp -j DROP

# DROP local ip spoofing
-A INPUT -s 127.0.0.0/8 -i !lo -j DROP
# Force SYN packet check
-A INPUT -p tcp ! --syn -m state --state NEW -j DROP
# Force Fragments pkts check
-A INPUT -f -j DROP
# LOG & DROP smurf attacks
-A INPUT -p icmp --icmp-type echo-request -m recent --set
-A INPUT -p icmp --icmp-type echo-request -m recent --update --seconds 2 --hitcount 1 -j LOG --log-prefix "IN_icmp"  --log-level 4
-A INPUT -p icmp --icmp-type echo-request -m recent --update --seconds 2 --hitcount 1 -j DROP
# DROP invalid tcp flags & log
#-A INPUT -m state --state INVALID -j LOG --log-prefix "IN_inv" --log-level 4
#-A INPUT -m state --state INVALID -j DROP
#-A OUTPUT -m state --state INVALID -j LOG --log-prefix "OUT_inv" --log-level 4
#-A OUTPUT -m state --state INVALID -j DROP
# DROP tcp flags that don't make sense
-A INPUT -p tcp --tcp-flags FIN,ACK FIN -j DROP
-A INPUT -p tcp --tcp-flags PSH,ACK PSH -j DROP
-A INPUT -p tcp --tcp-flags ACK,URG URG -j DROP
-A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
-A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
-A INPUT -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
# DROP XMAS pkts
-A INPUT -p tcp --tcp-flags ALL ALL -j DROP
# DROP NULL pkts
-A INPUT -p tcp --tcp-flags ALL NONE -j DROP
COMMIT

Thanks!
 
Old 05-18-2013, 03:24 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
You're running a default filter table INPUT chain DROP policy without explicitly allowing certain IP addresses to connect. I suggest you
0) run the default filter table INPUT chain ACCEPT policy, and
1) group your "bad traffic" rules, and
2) explicitly configure certain IP addresses to connect to certain ports, and
3) configure any IP addresses to connect to ports that need to be publicly available (that may be DNS if your machine is authoritative for one or more domains but definitely not SNMP), and
4) make a -j LOG rule precede all individual -j DROP or -j REJECT rules, and
5) end the filter table INPUT chain with a generic "-j DROP" rule.
The change of policy, rearranging rules and adding logging rules facilitate debugging so you should see where or what you block that you shouldn't. Then post your rule set for review again (that's actual 'iptables-save' output, not the static /etc/sysconfig/iptables).
 
1 members found this post helpful.
  


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
Nat Iptables Server Issue cbtshare Linux - Newbie 3 04-17-2012 03:17 PM
iptables (NAT/PAT) setup for SSH & Samba IanVaughan Linux - Networking 6 04-29-2010 07:19 PM
Security through nat/pat ninjaz Linux - Security 2 10-12-2006 04:05 PM
NAT and PAT rock69 Linux - Networking 2 10-03-2006 03:34 PM
iptables PAT/NAT mcardia Linux - Networking 1 07-14-2006 01:07 PM

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

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