当前位置: > CentOS > CentOS故障 >

/etc/sysconfig/下找不到iptables文件解决方法

时间:2014-12-19 01:27来源:linux.it.net.cn 作者:IT

本想做些防火墙策略。防火墙策略都是写在/etc/sysconfig/iptables文件里面的。可我发现我也没有这个文件。

[root@iZ23gx7o02aZ /]# cd /etc/sysconfig/
[root@iZ23gx7o02aZ sysconfig]# ls
atd         firstboot         irqbalance  network-scripts  rhn            sysstat
auditd      grub              kdump       ntpd             rngd           sysstat.ioconf
authconfig  htcacheclean      kernel      ntpdate          rsyslog        system-config-firewall
cbq         httpd             keyboard    prelink          sandbox        system-config-firewall.old
clock       i18n              modules     quota_nld        saslauthd      udev
console     init              netconsole  raid-check       selinux
cpuspeed    ip6tables-config  network     readahead        smartmontools
crond       iptables-config   networking  readonly-root    sshd
[root@iZ23gx7o02aZ sysconfig]# 

解决办法:

1. 随便写一条iptables命令配置个防火墙规则。如:iptables -P OUTPUT ACCEPT。

[root@iZ23gx7o02aZ /]# cd /etc/sysconfig/
[root@iZ23gx7o02aZ sysconfig]# iptables -P OUTPUT ACCEPT

2. service iptables save进行保存。

[root@iZ23gx7o02aZ sysconfig]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[root@iZ23gx7o02aZ sysconfig]# ls
atd         firstboot         iptables-config  networking       readonly-root  sshd
auditd      grub              irqbalance       network-scripts  rhn            sysstat
authconfig  htcacheclean      kdump            ntpd             rngd           sysstat.ioconf
cbq         httpd             kernel           ntpdate          rsyslog        system-config-firewall
clock       i18n              keyboard         prelink          sandbox        system-config-firewall.old
console     init              modules          quota_nld        saslauthd      udev
cpuspeed    ip6tables-config  netconsole       raid-check       selinux
crond       iptables          network          readahead        smartmontools
[root@iZ23gx7o02aZ sysconfig]# 

3. service iptables restart命令重启:

[root@iZ23gx7o02aZ sysconfig]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
[root@iZ23gx7o02aZ sysconfig]# 
 


(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容