1

I am not sure what's wrong with my rule in the Iptables. I am actually trying to build a SSH server and following a cyberciti tutorial.

My Iptables configuration looks like this:

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

When I restart of iptables, this is the transcript:

[root@localhost raja]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules: iptables-restore: line 14 failed
                                                           [FAILED]
[root@localhost raja]#

I tried placing COMMIT at the end, but it didn't help:

[root@localhost raja]# cat /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
COMMIT
[root@localhost raja]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules: iptables-restore: line 13 failed
                                                           [FAILED]
[root@localhost raja]#

What's wrong?

I am using CentOS 32-bit.

2 Answers 2

2

The rule -A RH-Firewall-1-INPUT … adds a rule to the chain called RH-Firewall-1-INPUT, but there is no prior line that creates this chain.

This is not the output from iptables-save. I don't recommend writing an iptables rule file manually (which makes this tutorial dubious; I haven't looked at it further). Use iptables to create and manipulate rules. When you're satisfied with the state of the system, run iptables-save to save it to a file, and don't edit that file.

0

COMMIT must be at the end of the file.

1
  • I have made that edit too. please look over
    – Raja G
    Dec 28, 2013 at 2:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .