Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Oct 2018 16:39:25 +0300
From:      "Andrey V. Elsukov" <bu7cher@yandex.ru>
To:        Ole <ole@free.de>, freebsd-ipfw@freebsd.org
Subject:   Re: net.inet.ip.fw.dyn_keep_states (was: ipfw managing rules - best practice?)
Message-ID:  <846ae8ef-be8b-08a6-6c07-ef62f8cb1a4b@yandex.ru>
In-Reply-To: <20181025110919.61379c13.ole@free.de>
References:  <20180905112847.54287198.ole@free.de> <67544958-07fe-7ff4-b5d2-88bf85324061@yandex.ru> <20181023131220.20c700ba.ole@free.de> <20181024182252.49ee516b.ole@free.de> <6bb037c2-643d-151b-cb34-f78c97f241d4@yandex.ru> <20181025110919.61379c13.ole@free.de>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--4PeinUYON8Ve6scFxaOZ04LVp0mHvjEJL
Content-Type: multipart/mixed; boundary="VXq8KOyCgu1cI1pao52b3RvrOyCtTi6tx";
 protected-headers="v1"
From: "Andrey V. Elsukov" <bu7cher@yandex.ru>
To: Ole <ole@free.de>, freebsd-ipfw@freebsd.org
Message-ID: <846ae8ef-be8b-08a6-6c07-ef62f8cb1a4b@yandex.ru>
Subject: Re: net.inet.ip.fw.dyn_keep_states (was: ipfw managing rules - best
 practice?)
References: <20180905112847.54287198.ole@free.de>
 <67544958-07fe-7ff4-b5d2-88bf85324061@yandex.ru>
 <20181023131220.20c700ba.ole@free.de> <20181024182252.49ee516b.ole@free.de>
 <6bb037c2-643d-151b-cb34-f78c97f241d4@yandex.ru>
 <20181025110919.61379c13.ole@free.de>
In-Reply-To: <20181025110919.61379c13.ole@free.de>

--VXq8KOyCgu1cI1pao52b3RvrOyCtTi6tx
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

On 25.10.2018 12:09, Ole wrote:
> So do you think the bug is only related to 'setup' and not to 'keep-sta=
te'
> rules? Or is this just a coincidence?=20
> Im reloading rules now for 1h each minute, and a ssh connection is stil=
l stable.

Hi,

I think you do not quite understand how it works :)
Dynamic states do not work automagically. In general words, you have two
types of firewall rules - static and dynamic. Static rules are kept in
an array and checked by firewall until some action will be applied, that
will finish the search.
Dynamic rules have special opcodes, that initiate the search in dynamic
states. And if a packet doesn't have a match in these dynamic states,
new dynamic state will be created for this packet.
If some state matches a packet, then corresponding action will be
applied for this packet. This is why usually "check-state" rule added to
the beginning of rules. A packet will be checked first for match in
dynamic states, and only then it will be checked by static rules.

So, when you have many rules and states, doing `ipfw flush` will delete
all static rules, but depending from keep_states sysctl variable,
dynamic states can be kept or deleted.

So, if you will do `ipfw -q flush` and do not add new dynamic rule, all
dynamic states will expire after some time and will be deleted
(regardless of the fact you have keep_states=3D1).

But, when you are doing `flush` and then reload new rules, that have
some dynamic rules (those that have "keep-state" or "limit" opcodes),
this means that new rules will initiate the search in dynamic states,
and for existing connection the state will be updated and because of
this, the connection is still work.

--=20
WBR, Andrey V. Elsukov


--VXq8KOyCgu1cI1pao52b3RvrOyCtTi6tx--

--4PeinUYON8Ve6scFxaOZ04LVp0mHvjEJL
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQEzBAEBCAAdFiEE5lkeG0HaFRbwybwAAcXqBBDIoXoFAlvRx40ACgkQAcXqBBDI
oXrnIwgAsTdExP4fylJ6N8N8SOpcNEIHFz2rDJdl9MgdeJ6Y4LBOVWdemYtUy06f
VMVT3ZrZs8qohdJFdPacLyYL6bmUC22kqKaajTE/cprC7fiqfSzznnLcDiLhELps
Zj161TTrVawUlc0/SiuEPhx5K52yv7/+LAj4HkrClXBNdwz0SvI6vXskkXaEOnn2
VJOeUkHcZduiS+VIgoQMCZN3x9NV05uFJfedmZMIvBPV53h/efXu3pj0t92b3ktV
ipOleE8md9d7PhLmhgUFVlN4V0hulRce9lfrsi9dPSXQY9m1SjLO2QCwiTg7Gdv6
1j7yB4HOXUiV6B9Jm+SeXAiEcD7MjQ==
=U4fi
-----END PGP SIGNATURE-----

--4PeinUYON8Ve6scFxaOZ04LVp0mHvjEJL--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?846ae8ef-be8b-08a6-6c07-ef62f8cb1a4b>