LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-09-2019, 03:03 PM   #1
edier88
LQ Newbie
 
Registered: May 2011
Posts: 12

Rep: Reputation: Disabled
Iptables adding rules to itself automagically on Fedora 29


Hi everyone, I have a tricky problem here in Fedora 29.
I uninstalled Firewalld for education purposes and I have only iptables. I'm configuring it directly without any Frontend.

I have it all configured but when I restart my PC I'm seeing that other rules have been added to IPtables and I don't know what's the source of those rules updates, more specifically it is adding rules for port 53 (DNS) and 67 (DHCP server) in every restart, plus some rules in FORWARD chain and it also adds rules for port 68 (DHCP client).
Yes, plus other rules in nat table and mangle table, here is the capture of the filter table:
-
--
---
-----
-------------------------------------------------------------------------------

[root@edier88 edier88]# iptables -t filter -nL --line-numbers

Chain INPUT (policy DROP)
num target prot opt source destination
1 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
3 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
5 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
6 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
7 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
8 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
9 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
10 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
11 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
12 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
13 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
14 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
15 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
16 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
17 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
18 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
19 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
20 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
21 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
22 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
23 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
24 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
25 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
26 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
27 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
28 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
29 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
30 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
31 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
32 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
33 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
34 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
35 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
36 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
37 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
38 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
39 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
40 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
41 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW,RELATED,ESTABLISHED tcp dpt:80
42 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW,RELATED,ESTABLISHED tcp dpt:443
43 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:80
44 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp spt:80
45 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:443
46 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:53
47 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp spt:53
48 ACCEPT udp -- 192.168.1.0/24 0.0.0.0/0 udp dpt:53
49 ACCEPT tcp -- 192.168.1.0/24 0.0.0.0/0 tcp dpt:53
50 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:80
51 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
52 ACCEPT tcp -- 192.168.1.0/24 0.0.0.0/0 tcp dpt:137
53 ACCEPT tcp -- 192.168.1.0/24 0.0.0.0/0 tcp dpt:138
54 ACCEPT tcp -- 192.168.1.0/24 0.0.0.0/0 tcp dpt:139
55 ACCEPT tcp -- 192.168.1.0/24 0.0.0.0/0 tcp dpt:445

Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
2 ACCEPT all -- 192.168.122.0/24 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
6 ACCEPT all -- 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
7 ACCEPT all -- 192.168.122.0/24 0.0.0.0/0
8 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
9 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
10 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
11 ACCEPT all -- 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
12 ACCEPT all -- 192.168.122.0/24 0.0.0.0/0
13 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
14 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
15 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
16 ACCEPT all -- 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
17 ACCEPT all -- 192.168.122.0/24 0.0.0.0/0
18 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
19 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
20 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
21 ACCEPT all -- 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
22 ACCEPT all -- 192.168.122.0/24 0.0.0.0/0
23 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
24 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
25 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
26 ACCEPT all -- 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
27 ACCEPT all -- 192.168.122.0/24 0.0.0.0/0
28 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
29 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
30 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
31 ACCEPT all -- 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
32 ACCEPT all -- 192.168.122.0/24 0.0.0.0/0
33 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
34 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
35 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
36 ACCEPT all -- 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
37 ACCEPT all -- 192.168.122.0/24 0.0.0.0/0
38 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
39 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
40 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
41 ACCEPT all -- 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
42 ACCEPT all -- 192.168.122.0/24 0.0.0.0/0
43 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
44 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
45 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
46 ACCEPT all -- 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
47 ACCEPT all -- 192.168.122.0/24 0.0.0.0/0
48 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
49 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
50 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:68
2 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:68
3 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:68
4 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:68
5 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:68
6 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:68
7 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:68
8 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:68
9 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:68
10 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:68
-----------------------------------------------------------------------------------
-----
---
--
-

And I searched in the logs in order to understand what's happening, I found this:
-
--
---
-----
-------------------------------------------------------------------------------
[root@edier88 edier88]# journalctl | grep 'Feb 09 14:4' | grep -i filter

Feb 09 14:41:42 edier88 chronyd[862]: chronyd version 3.4 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
Feb 09 14:41:42 edier88 audit: NETFILTER_CFG table=nat family=2 entries=0
Feb 09 14:41:44 edier88 audit: NETFILTER_CFG table=nat family=2 entries=5
Feb 09 14:41:44 edier88 audit: NETFILTER_CFG table=mangle family=2 entries=0
Feb 09 14:41:44 edier88 audit: NETFILTER_CFG table=mangle family=2 entries=6
Feb 09 14:41:45 edier88 audit: NETFILTER_CFG table=filter family=2 entries=4
Feb 09 14:41:48 edier88 named[998]: built with '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-python=/usr/bin/python3' '--with-libtool' '--localstatedir=/var' '--enable-threads' '--enable-ipv6' '--enable-filter-aaaa' '--with-pic' '--disable-static' '--includedir=/usr/include/bind9' '--with-tuning=large' '--with-geoip' '--with-libidn2' '--enable-openssl-hash' '--enable-native-pkcs11' '--with-pkcs11=/usr/lib64/pkcs11/libsofthsm2.so' '--with-dlopen=yes' '--with-dlz-ldap=yes' '--with-dlz-postgres=yes' '--with-dlz-mysql=yes' '--with-dlz-filesystem=yes' '--with-dlz-bdb=yes' '--with-gssapi=yes' '--disable-isc-spnego' '--with-lmdb=no' '--with-atf=/usr' '--enable-fixed-rrset' '--with-docbook-xsl=/usr/share/sgml/docbook/xsl-stylesheets' '--enable-full-report' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'CFLAGS= -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' 'LDFLAGS=-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' 'CPPFLAGS= -DDIG_SIGCHASE'
Feb 09 14:42:04 edier88 audit: NETFILTER_CFG table=filter family=10 entries=0
Feb 09 14:42:08 edier88 kernel: bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=filter family=2 entries=109
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=filter family=2 entries=110
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=filter family=2 entries=111
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=filter family=2 entries=112
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=filter family=2 entries=113
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=filter family=2 entries=114
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=filter family=2 entries=115
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=filter family=2 entries=116
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=filter family=2 entries=117
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=filter family=2 entries=118
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=nat family=2 entries=65
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=nat family=2 entries=66
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=nat family=2 entries=67
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=nat family=2 entries=68
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=nat family=2 entries=69
Feb 09 14:42:09 edier88 audit: NETFILTER_CFG table=mangle family=2 entries=18
-----------------------------------------------------------------------------------
-----
---
--
-

I really don't know if Auditd or NETFILTER is adding rules to iptables automagically, is that what is happening? How can this be deactivated?

I really appreciate all the help you can give me. Thanks a lot!!
 
Old 02-18-2019, 11:08 AM   #2
edier88
LQ Newbie
 
Registered: May 2011
Posts: 12

Original Poster
Rep: Reputation: Disabled
Hi everybody who's watching this thread.
I will give a solution to my problem myself, I'm the same person who created this thread.

I solved this with not the correct solution but with something that can mitigate the problem.

To avoid Iptables keep growing and adding rules to itself automagically I made a programmed task in 'rc.local' telling iptables to restore its correct rules everytime at startup.

First I activated the rc.local on Fedora 29 this way (rc.local isn't activated by default in fedora)


I created the file:
-----------------------------------------------------------------------------------
# vim /etc/rc.d/rc.local
-----------------------------------------------------------------------------------


I give execution permissions:
----------------------------------------------------------------------------------
# chmod +x /etc/rc.d/rc.local
----------------------------------------------------------------------------------


Activate the rc-local.service:
-----------------------------------------------------------------------------------
# systemctl enable rc-local.service
# systemctl start rc-local.service
# systemctl status rc-local.service
-----------------------------------------------------------------------------------


I save the iptables backup file with the rules I want to be restored at startup:
-----------------------------------------------------------------------------------
# iptables-save > /home/<user>/Desktop/iptablesbk.txt
-----------------------------------------------------------------------------------

Where <user> is the name of the user in Fedora.

I make an sh file, this is the file who is going to restore my iptables rules at startup:
--------------------------------------------------------------------------------------
# vim /home/<user>/Desktop/iptables.sh
--------------------------------------------------------------------------------------


And put this line in it, that will say to iptables to restore its rules with the given backup file:
--------------------------------------------------------------------------------------
iptables-restore < /home/edier88/Desktop/iptablesbk.txt
--------------------------------------------------------------------------------------
Save it.


In /etc/rc.d/rc.local I put these lines and save it:
-------------------------------------------------------------------------------------
#!/bin/bash
at -f /home/<user>/Desktop/iptables.sh now + 3 minutes
-------------------------------------------------------------------------------------


That way I'm executing at startup the file 'iptables.sh' which makes iptables to restore the rules contained in the file "iptablesbk.txt"

This is not the correct solution to my problem, but is a temporal solution because until now, I haven't solved it entirely.

If you have questions, replies or corrections to this, let me know.

Thank you!
 
  


Reply

Tags
audit, fedora, iptables, netfilter, startup



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables adding rules to itself automagically on Fedora 29 edier88 Linux - Networking 1 02-09-2019 04:08 PM
auditctl -l not showing any rules even though i have rules written in audit.rules alphaguy Linux - Security 1 02-07-2014 05:28 PM
computer switches from static to dhcp address (automagically?) cyberpuerka Linux - Networking 1 09-03-2004 11:29 AM
automagically mount Magneto-Optical Drive? wytiger Fedora 0 07-27-2004 10:56 PM
XMMS has stopped opening pls automagically Steve Cronje Linux - Software 3 05-04-2004 01:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration