Bug 1459673 - iptables init script doesn't support /etc/sysctl.d/
Summary: iptables init script doesn't support /etc/sysctl.d/
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: iptables
Version: 6.9
Hardware: x86_64
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Phil Sutter
QA Contact: Tomas Dolezal
Ioanna Gkioka
URL:
Whiteboard:
Keywords: Reopened
Depends On:
Blocks: 1374441 1461138 1506394
TreeView+ depends on / blocked
 
Reported: 2017-06-07 18:48 UTC by Davide F Bragalone
Modified: 2018-06-19 05:09 UTC (History)
8 users (show)

(edit)
The _iptables-services_ package now support `/etc/sysctl.d`

With this update, the init scripts of the `iptables` or `ip6tables` services now recognize the configuration files in the `/etc/sysctl.d` directory as well as the `/etc/sysctl.conf` file itself. As a result, the user-provided sysctl settings stored in `/etc/sysctl.d/` are now correctly taken into account when the `iptables` service is restarted.
Clone Of:
(edit)
Last Closed: 2018-06-19 05:08:46 UTC


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:1859 None None None 2018-06-19 05:09 UTC

Description Davide F Bragalone 2017-06-07 18:48:39 UTC
Description of problem:

The init script for iptables /etc/init.d/iptables doesn't support /etc/sysctl.d .

load_sysctl() {
    # load matched sysctl values
    if [ -n "$IPTABLES_SYSCTL_LOAD_LIST" ]; then
        echo -n $"Loading sysctl settings: "
        ret=0
        for item in $IPTABLES_SYSCTL_LOAD_LIST; do
            fgrep $item /etc/sysctl.conf | sysctl -p - >/dev/null    <=========
            let ret+=$?;
        done
        [ $ret -eq 0 ] && success || failure
        echo
    fi
    return $ret
}

That means that if you edit a kernel parameter related to iptables via /etc/sysctl.d/foo.conf , this won't be applied on iptables restart.


Version-Release number of selected component (if applicable):
kernel 2.6.32-696.3.1.el6.x86_64
iptables-1.4.7-16.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. edit parameter net.nf_conntrack_max via /etc/sysctl.d/iptables.conf 
2. restart iptables
3. verify if /proc/sys/net/nf_conntrack_max has been modified

Actual results:
never updated

Expected results:
always updated

Comment 2 Davide F Bragalone 2017-06-07 19:01:18 UTC
I've forgot this in the bugzilla's description:

initscripts-9.03.58-1.el6_9.1.x86_64

Comment 4 Lukáš Nykrýn 2017-06-08 08:20:25 UTC
The mentioned code is inside a initscript provided by the iputils package.

Comment 5 Carlos Peón 2017-06-08 11:22:00 UTC
(In reply to Lukáš Nykrýn from comment #4)
> The mentioned code is inside a initscript provided by the iputils package.

I think it's provided by iptables package.

Comment 6 Carlos Peón 2017-06-08 11:25:58 UTC
This patch work for us:

--- iptables.old        2017-06-08 13:18:26.680973312 +0200
+++ iptables    2017-06-08 13:18:39.896022411 +0200
@@ -187,7 +187,7 @@
         echo -n $"Loading sysctl settings: "
         ret=0
         for item in $IPTABLES_SYSCTL_LOAD_LIST; do
-            fgrep $item /etc/sysctl.conf | sysctl -p - >/dev/null
+            fgrep -hs $item /etc/sysctl.conf /etc/sysctl.d/*.conf | sysctl -p - >/dev/null
             let ret+=$?;
         done
         [ $ret -eq 0 ] && success || failure


The same code exists in rhel7, iptables-services package, /usr/libexec/iptables/iptables.init file.

Comment 7 Sergi Jimenez Romero 2017-06-08 15:31:31 UTC
(In reply to Carlos Peón from comment #5)
> (In reply to Lukáš Nykrýn from comment #4)
> > The mentioned code is inside a initscript provided by the iputils package.
> 
> I think it's provided by iptables package.

I confirm that:

$ rpm -qf /etc/init.d/iptables 
iptables-1.4.7-16.el6.x86_64

Comment 11 Phil Sutter 2017-10-06 11:25:21 UTC
Already fixed in RHEL7 via bz#1402021. Same solution applies here with one exception: RHEL6 doesn't ship a symlink from /etc/sysctl.d/99-sysctl.conf to /etc/sysctl.conf, so the grep command needs to explicitly search /etc/sysctl.conf as well.

Comment 24 errata-xmlrpc 2018-06-19 05:08:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:1859


Note You need to log in before you can comment on or make changes to this bug.