Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to make a iptables firewall rule

Posted on 2014-08-01
4
Medium Priority
?
450 Views
Last Modified: 2014-08-01
Dear experts here:

I have added a rule in /etc/sysconfig/iptables file for my iptables firewall but it failed when I restarted the service.

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


The file is as below, line number 8 is what I just added.

  1 # Generated by iptables-save v1.3.5 on Sat Jan 19 11:04:49 2013
  2 *filter
  3 :INPUT ACCEPT [179065:145346048]
  4 :FORWARD ACCEPT [0:0]
  5 :OUTPUT ACCEPT [159509:132200597]
  6 -A INPUT -p tcp -m state --state NEW -m tcp --dport 8000 -j ACCEPT
  7 -A INPUT -p tcp -m state --state NEW -m tcp --dport 8000 -j ACCEPT
  8 -A INPUT -p udp -s 10.10.4.0/22 -m state --state NEW -m udp --dport 123 -j ACCEPT
  9 -A INPUT -p tcp -m state --state NEW -m tcp --dport 8000 -j DROP
 10 COMMIT
 11 # Completed on Sat Jan 19 11:04:49 2013
 12

Open in new window

0
Comment
Question by:Jason Yu
  • 3
4 Comments
 

Author Comment

by:Jason Yu
ID: 40234679
[root@titan ~]# vi /etc/sysconfig/iptables
[root@titan ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

[root@titan ~]#
0
 
LVL 21

Accepted Solution

by:
Mazdajai earned 2000 total points
ID: 40234981
What kernel are you running?

The line looks fine. Try to uncomment / comment the line and run:

service iptables reload 

Open in new window


If that did not work try using system-config-firewall-tui to add the rule.
0
 

Author Comment

by:Jason Yu
ID: 40235109
[root@titan ~]# cat /etc/*-release
CentOS release 6.3 (Final)
CentOS release 6.3 (Final)
CentOS release 6.3 (Final)
[root@titan ~]#
0
 

Author Comment

by:Jason Yu
ID: 40235117
Interesting, it's working now.

[root@titan ~]# service iptables reload
[root@titan ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:8000
2    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:8000
3    ACCEPT     udp  --  10.10.4.0/22         0.0.0.0/0           state NEW udp dpt:123
4    DROP       tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:8000

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

[root@titan ~]#
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month21 days, 6 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question