Категорії
Misc, staff, other Routers, GW, Internet

[pf] Правильно настраиваем dup-to

Эта опция в pf позволяет дублировать трафик, минуя таблицу маршрутизации. Синтаксис прост:

pass in|out on $ext_if dup-to ($dup_if $dup_addr) ...

где, $ext_if – интерфейс с которого снимать трафик, dup_if – интерфейс, на который пересылать трафик (находится на том же роутере, что и ext_if), dup_addr – IP-адрес хоста, куда будет дублироваться трафик (находится в той же подсети, что и dup_if).

А теперь самое главное, которое не пишут (не нашёл ни в одном мануале из 10-ка популярных) – что бы копирование трафика работало правильно, обязательно нужно что бы state-policy была if-bound. Или другими словами, нужно наличие строки:

set state-policy if-bound

Ниже выдержка из рассылки с кратким объяснением такого заключения.

I’ve looked at the state matching for a bit. It turns out that by
default packets will match state on any interface (specifically, the
state is saved to the ‘all’ interface, rather than to the specific
interface it was created on).

А вот часть мануала, с объяснением:

set state-policy option

Sets PF’s behavior when it comes to keeping state. This behavior can be overridden on a per rule basis. See Keeping State.

  • if-bound – states are bound to the interface they’re created on. If traffic matches a state table entry but is not crossing the interface recorded in that state entry, the match is rejected. The packet must then match a filter rule or will be dropped/rejected altogether.
  • floating – states can match packets on any interface. As long as the packet matches a state entry and is passing in the same direction as it was on the interface when the state was created, it does not matter what interface it’s crossing, it will pass.

The default is floating.

 

Залишити відповідь

Ваша e-mail адреса не оприлюднюватиметься. Обов’язкові поля позначені *

Домашняя страничка Andy
Записки молодого админа
Самостоятельная подготовка к Cisco CCNA
Самостоятельная подготовка к Cisco CCNP
Powered by Muff