找不到/etc/sysconfig/iptables文件,解决方法 您所在的位置:网站首页 iptables配置文件没有 找不到/etc/sysconfig/iptables文件,解决方法

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

2024-02-11 18:34| 来源: 网络整理| 查看: 265

linux防火墙规则链是写在/etc/sys

config/iptables文件下。

之所以出现这篇博文,是因为个人需要搭建ntp服务所以需要写入规则链,可是没有发现这个文件,查了些资料。。。。

首先当需要查看这个文件时,没发现这个文件

[root@ex /]# cat /etc/sysconfig/iptables cat: /etc/sysconfig/iptables: No such file or directory 不信邪,进去目录找找 [root@ex /]# cd /etc/sysconfig/ && ls auditd   crond  ip6tables-config  keyboard    networking       rsyslog    sshd cbq      grub   iptables-config   modules     network-scripts  sandbox    udev clock    i18n   kdump             netconsole  raid-check       saslauthd console  init   kernel            network     readonly-root    selinux

没有这个文件了怎么办呢,不要着急,耐心往下看~

或许你会想到自己创建一个iptables文件,这个想法其实是对的。。。

但是iptables这个文件当你自己随便写入规则时并保存这条规则,那么这个文件就会自动生成。

下面我因为搭建ntp服务就自己把规则写下了、、、

[root@ex /]# iptables -A INPUT -m state --state NEW -m udp -p udp --dport 123 -j ACCEPT

然后保存这条规则链、

[root@ex /]# service iptables save iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

再去看看iptables文件内容吧

[root@ex /]# cat /etc/sysconfig/iptables # Generated by iptables-save v1.4.7 on Mon Aug  3 17:48:10 2015 *filter :INPUT ACCEPT [84:5990] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [46:5080] -A INPUT -p udp -m state --state NEW -m udp --dport 123 -j ACCEPT  -A INPUT -p udp -m state --state NEW -m udp --dport 123 -j ACCEPT  COMMIT # Completed on Mon Aug  3 17:48:10 2015

文件呢

[root@ex /]# cd /etc/sysconfig/ && ls auditd   i18n              kernel      network-scripts  selinux cbq      init              keyboard    raid-check       sshd clock    ip6tables-config  modules     readonly-root    udev console  iptables          netconsole  rsyslog crond    iptables-config   network     sandbox grub     kdump             networking  saslauthd

搞定,收工,继续搭ntp服务了~~~~



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有