Страница 1 из 1

Перечисление ip в ipfw

Добавлено: 2012-01-11 10:24:37
Гость
Допустим есть такое правило
${FwCMD} add allow tcp from 192.168.0.0{1,2,3,4} to any in via ${LanIn}
то есть можно перечислить несколько ip в одном правиле.
А теперь нубский вопрос:
Какие еще перечисления доступны в написании правил. Допустим если мне нужно два блока 10.0.0.0/8 и 192.168.0.0/16 впихнуть в одно правило.
Ну и где главное это описывается? 192.168.0.0{1,2,3,4} вот такую запись вычитал у кого то в настройках, а где источник?

Re: Перечисление ip в ipfw

Добавлено: 2012-01-11 10:44:51
hizel
see man ipfw and use tables, Luke

Re: Перечисление ip в ipfw

Добавлено: 2012-01-11 12:23:34
Гость
Вы меня не правильно поняли. Про table я знаю, меня интересует именно синтаксис в ipfw. Перечисление ip я привел пример, вот разобрало любопытство, а как все выглядит в полном объеме эта возможность.

Re: Перечисление ip в ipfw

Добавлено: 2012-01-11 12:31:34
hizel
man ipfw и /usr/src/sbin/ipfw/ipfw2.c в помощь

Re: Перечисление ip в ipfw

Добавлено: 2012-01-11 12:46:10
dikens3
Допустим если мне нужно два блока 10.0.0.0/8 и 192.168.0.0/16 впихнуть в одно правило.
Через запятую можно. Если много IP-Адресов, то смотреть вывод ipfw -ad list не удобно.

Код: Выделить всё

${FwCMD} add allow tcp from IP1,IP2,IP3-5 to any in via ${LanIn}

Re: Перечисление ip в ipfw

Добавлено: 2012-01-11 13:20:02
Гость
В файлике /usr/src/sbin/ipfw/ipfw2.c ответ на мой вопрос.
/*
* fills the addr and mask fields in the instruction as appropriate from av.
* Update length as appropriate.
* The following formats are allowed:
*<---->me<---->returns O_IP_*_ME
*<---->1.2.3.4><------>single IP address
*<---->1.2.3.4:5.6.7.8>address:mask
*<---->1.2.3.4/24<---->address/mask
*<---->1.2.3.4/26{1,6,5,4,23}<>set of addresses in a subnet
* We can have multiple comma-separated address/mask entries.
*/
То есть 10.0.0.0/8 и 192.168.0.0/16 одним правилом можно описать.
${FwCMD} add allow tcp from 192.168.0.0/24,10.0.0.0/8 to any in via ${LanIn}
Теперь полностью все ясно, как и что. Спасибо за помощь...

Re: Перечисление ip в ipfw

Добавлено: 2012-01-11 13:41:58
hizel
мдэ

Код: Выделить всё

     addr-list: ip-addr[,addr-list]

     ip-addr:
             A host or subnet address specified in one of the following ways:

             numeric-ip | hostname
                     Matches a single IPv4 address, specified as dotted-quad
                     or a hostname.  Hostnames are resolved at the time the
                     rule is added to the firewall list.

             addr/masklen
                     Matches all addresses with base addr (specified as an IP
                     address, a network number, or a hostname) and mask width
                     of masklen bits.  As an example, 1.2.3.4/25 or 1.2.3.0/25
                     will match all IP numbers from 1.2.3.0 to 1.2.3.127 .

             addr:mask
                     Matches all addresses with base addr (specified as an IP
                     address, a network number, or a hostname) and the mask of
                     mask, specified as a dotted quad.  As an example,
                     1.2.3.4:255.0.255.0 or 1.0.3.0:255.0.255.0 will match
                     1.*.3.*.  This form is advised only for non-contiguous
                     masks.  It is better to resort to the addr/masklen format
                     for contiguous masks, which is more compact and less
                     error-prone.
alert! магия в man-е!

а еще есть src-ip rule options, man-ы они такие :-(