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

Возвращение к ipfw+nat в7.0

Добавлено: 2008-05-07 6:57:59
Div
Посмотрел архивы про сабж и не нашел того чего надо...
Подскажите плиииз как сделать ipfw_nat правила в ipfw , чтобы было нат как с одного IP из внутренней сети,
так и с пула адресов и разными портами... Вобщем несколько разных интересных ситуаций....
Стандартно со всех из сети по ману все ОК...
Заранее спасибо большое..

Re: Возвращение к ipfw+nat в7.0

Добавлено: 2008-05-07 7:50:22
zg

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

IPFW(8)                 FreeBSD System Manager's Manual                IPFW(8)

NAME
     ipfw -- IP firewall and traffic shaper control program

SYNOPSIS
     ipfw [-cq] add rule
     ipfw [-acdefnNStT] [set N] {list | show} [rule | first-last ...]
     ipfw [-f | -q] [set N] flush
     ipfw [-q] [set N] {delete | zero | resetlog} [number ...]
     ipfw enable
          {firewall | altq | one_pass | debug | verbose | dyn_keepalive}
     ipfw disable
          {firewall | altq | one_pass | debug | verbose | dyn_keepalive}

     ipfw set [disable number ...] [enable number ...]
     ipfw set move [rule] number to number
     ipfw set swap number number
     ipfw set show

     ipfw table number add addr[/masklen] [value]
     ipfw table number delete addr[/masklen]
     ipfw table number flush
     ipfw table number list

     ipfw {pipe | queue} number config config-options
     ipfw [-s [field]] {pipe | queue} {delete | list | show} [number ...]

     ipfw nat number config config-options

     ipfw [-cfnNqS] [-p preproc [preproc-flags]] pathname

....

     nat nat_nr
             Pass packet to a nat instance (for network address translation,
             address redirect, etc.): see the NETWORK ADDRESS TRANSLATION
             (NAT) Section for further information.

....

   NAT, REDIRECT AND LSNAT
     First redirect all the traffic to nat instance 123:

           ipfw add nat 123 all from any to any

     Then to configure nat instance 123 to alias all the outgoing traffic with
     ip 192.168.0.123, blocking all incoming connections, trying to keep same
     ports on both sides, clearing aliasing table on address change and keep-
     ing a log of traffic/link statistics:

           ipfw nat 123 config ip 192.168.0.123 log deny_in reset same_ports

     Or to change address of instance 123, aliasing table will be cleared (see
     reset option):

           ipfw nat 123 config ip 10.0.0.1

     To see configuration of nat instance 123:

           ipfw nat 123 show config

     To show logs of all the instances in range 111-999:

           ipfw nat 111-999 show

     To see configurations of all instances:

           ipfw nat show config

     Or a redirect rule with mixed modes could looks like:

           ipfw nat 123 config redirect_addr 10.0.0.1 10.0.0.66
                           redirect_port tcp 192.168.0.1:80 500
                           redirect_proto udp 192.168.1.43 192.168.1.1
                           redirect_addr 192.168.0.10,192.168.0.11
                                   10.0.0.100 # LSNAT
                           redirect_port tcp 192.168.0.1:80,192.168.0.10:22
                                   500        # LSNAT

     or it could be splitted in:

           ipfw nat 1 config redirect_addr 10.0.0.1 10.0.0.66
           ipfw nat 2 config redirect_port tcp 192.168.0.1:80 500
           ipfw nat 3 config redirect_proto udp 192.168.1.43 192.168.1.1
           ipfw nat 4 config redirect_addr
           192.168.0.10,192.168.0.11,192.168.0.12
                                        10.0.0.100
           ipfw nat 5 config redirect_port tcp
                          192.168.0.1:80,192.168.0.10:22,192.168.0.20:25 500

Re: Возвращение к ipfw+nat в7.0

Добавлено: 2008-05-07 8:19:10
Div
Это я все видел...Редирект мне не нужен...
Нужен обычный нат, в первой части это для всех входящих адресов,
а вот как пул входящих адресов указать?
Можно ли это как-то через ipfw table это сделать?

Re: Возвращение к ipfw+nat в7.0

Добавлено: 2008-05-07 12:13:51
zg
Div писал(а):Можно ли это как-то через ipfw table это сделать?
тебе что конкретно сделать надо?

обычный нат?

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

ipfw add nat 123 all from any to any
ipfw nat 123 config ip 10.0.0.1
всё... весь трафик будет натиться на 10.0.0.1

необычный нат?

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

ipfw add nat 1 all from host to any
ipfw add nat 2 all from any to host
......
ipfw nat 1 config redirect_addr 10.0.0.1 10.0.0.66
ipfw nat 2 config redirect_port tcp 192.168.0.1:80 500
ipfw nat 3 config redirect_proto udp 192.168.1.43 192.168.1.1
ipfw nat 4 config redirect_addr
вместо редиректа можно писать что угодно

система впринципе простая, но думаю глюкавая, если сложности там прописывать