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

ipfw nat - не прлучается - помогите!

Добавлено: 2011-02-04 18:48:08
voy22
Блин, не получается рубить трафик, помогите - кто чем может. OS: FreeBSD 8.0
Вот мё:

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

[voy@bsd:~]$ ifconfig rl0
rl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8<VLAN_MTU>
        ether 00:40:45:20:b2:cf
        inet 178.140.187.130 netmask 0xffffff00 broadcast 178.140.187.255
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
[voy@bsd:~]$ ifconfig re0
re0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=389b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_UCAST,WOL_MCAST,WOL_MAGIC>
        ether 00:e0:4c:00:19:20
        inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.2.255
        inet 192.168.2.2 netmask 0xffffff00 broadcast 192.168.2.255
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
Вот /etc/firewall.sh - с которым все работает как надо - т.е (192.168.2.x) <->(192.168.2.1 <- nat -> 178.140.187.130) <-> INET

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

[voy@bsd:~]$ cat /etc/firewall2.sh
ipfw -f flush
ipfw -f pipe flush
ipfw -f queue flush

# разрешаем все через интерфейс локальной сети
ipfw add 1040 allow ip from any to any via re0

# настройка ната.
ipfw nat 1 config log if rl0 reset same_ports deny_in

# заварачиваем все что проходит через внешний интерфейс в нат
ipfw add 10300 nat 1 ip from any to any via rl0

ipfw add 65534 deny all from any to any
А теперь пытаюсь сузить канал:

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

[root@bsd:/etc]# cat firewall3.sh
ipfw -f flush
ipfw -f pipe flush
ipfw -f queue flush

# разрешаем все через интерфейс локальной сети
ipfw add 1040 allow ip from any to any via re0


ipfw pipe 1 config bw 500Kbit/s queue 60 gred 0.002/10/30/0.1
ipfw queue 1 config pipe 1 queue 60 mask src-ip 0xffffffff gred 0.002/10/30/0.1

ipfw pipe 2 config bw 250Kbit/s queue 60 gred 0.002/10/30/0.1
ipfw queue 2 config pipe 2 queue 60 mask dst-ip 0xffffffff gred 0.002/10/30/0.1

ipfw nat 1 config log if rl0 reset same_ports deny_in

ipfw add 10150 queue 1 ip from any to any out xmit rl0
ipfw add 10160 nat 1 ip from any to any via rl0
ipfw add 10170 queue 2 ip from any to any in recv rl0

ipfw add 10230 allow all from any to any
ipfw add 65534 deny all from any to any
Запускаю:

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

[root@bsd:~]# /etc/firewall3.sh
Flushed all rules.
Flushed all pipes.
Flushed all pipes.
01040 allow ip from any to any via re0
ipfw nat 1 config if rl0 log deny_in same_ports reset
10150 queue 1 ip from any to any out xmit rl0
10160 nat 1 ip from any to any via rl0
10170 queue 2 ip from any to any in recv rl0
10230 allow ip from any to any
65534 deny ip from any to any
мониторим (в чем я плохо чего понимаю):

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

[root@bsd:~]# ipfw list
01040 allow ip from any to any via re0
10150 queue 1 ip from any to any out xmit rl0
10160 nat 1 ip from any to any via rl0
10170 queue 2 ip from any to any in recv rl0
10230 allow ip from any to any
65534 deny ip from any to any
65535 deny ip from any to any

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

[root@bsd:~]# ipfw pipe show
00001: 500.000 Kbit/s    0 ms   60 sl. 0 queues (1 buckets)
         GRED w_q 0.001999 min_th 10 max_th 30 max_p 0.099991
         burst: 0 Byte
00002: 250.000 Kbit/s    0 ms   60 sl. 0 queues (1 buckets)
         GRED w_q 0.001999 min_th 10 max_th 30 max_p 0.099991
         burst: 0 Byte
q00001: weight 1 pipe 1   60 sl. 3 queues (64 buckets)
         GRED w_q 0.001999 min_th 10 max_th 30 max_p 0.099991
    mask: 0x00 0xffffffff/0x0000 -> 0x00000000/0x0000
BKT Prot ___Source IP/port____ ____Dest. IP/port____ Tot_pkt/bytes Pkt/Byte Drp
 20 ip      192.168.2.30/0             0.0.0.0/0     3387   310860  0    0   0
 24 ip   178.140.187.130/0             0.0.0.0/0     1807  1420406  0    0   0
 40 ip      192.168.2.32/0             0.0.0.0/0      383    22211  0    0   0
q00002: weight 1 pipe 2   60 sl. 0 queues (64 buckets)
         GRED w_q 0.001999 min_th 10 max_th 30 max_p 0.099991
И в инет дорога закрыта.
Прошу помощи!

Re: ipfw nat - не прлучается - помогите!

Добавлено: 2011-02-05 0:19:04
hranitel_y2k
sysctl net.inet.ip.fw.one_pass=0

Re: ipfw nat - не прлучается - помогите!

Добавлено: 2011-02-13 0:52:04
RAGNAR
у тебя есть касяк в правилах... сделай так.

sysctl net.inet.ip.fw.one_pass=0

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

${ipfw} nat 1 config if ng0 log same_ports unreg_only 

${ipfw} pipe 1 config bw 6656Kbit/s queue 50 gred 0.002/10/30/0.1
${ipfw} pipe 2 config bw  950Kbit/s queue 50 gred 0.002/10/30/0.1

${ipfw} queue 1 config pipe 1 queue 50 mask dst-ip 0xffffffff gred 0.002/10/30/0.1
${ipfw} queue 2 config pipe 2 queue 50 mask src-ip 0xffffffff gred 0.002/10/30/0.1



${ipfw} add  queue 2 ip from any to any out xmit ng0

${ipfw} add  nat 1 ip from any to any out xmit ng0
${ipfw} add  nat 1 ip from any to xx.xx.xx.xx in recv ng0  //  ну там свой поставь или any

${ipfw} add  queue 1 ip from any to any in recv ng0
${ipfw} add  allow all from any to any
ipfw pipe show

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

 00001:   6.656 Mbit/s    0 ms   50 sl. 0 queues (1 buckets)
          GRED w_q 0.001999 min_th 10 max_th 30 max_p 0.099991
00002: 950.000 Kbit/s    0 ms   50 sl. 0 queues (1 buckets)
          GRED w_q 0.001999 min_th 10 max_th 30 max_p 0.099991
q00001: weight 1 pipe 1   50 sl. 13 queues (64 buckets)
          GRED w_q 0.001999 min_th 10 max_th 30 max_p 0.099991
    mask: 0x00 0x00000000/0x0000 -> 0xffffffff/0x0000
BKT Prot ___Source IP/port____ ____Dest. IP/port____ Tot_pkt/bytes Pkt/Byte Drp
  0 ip           0.0.0.0/0          10.10.0.20/0     3696  1641756  0    0   0
  1 ip           0.0.0.0/0          10.10.0.21/0     1877779 194534906  0    0   1
  5 ip           0.0.0.0/0          10.10.0.17/0     4118  2569054  0    0   0
  7 ip           0.0.0.0/0          10.10.0.19/0     834849 399604142  0    0   0
 10 ip           0.0.0.0/0          10.10.0.30/0     16981 18607431  0    0  13
 16 ip           0.0.0.0/0           10.10.0.4/0     18918  1621169  0    0   0
 22 ip           0.0.0.0/0        xx.xx.xx.xx/0     20277918 26616088543  0    0 27888
 27 ip           0.0.0.0/0          10.10.0.15/0     193497 96433504  0    0  21
 29 ip           0.0.0.0/0           10.10.0.9/0     46656  7131717  0    0   0
 30 ip           0.0.0.0/0          10.10.0.10/0     1117779 224799840  0    0   0
 50 ip           0.0.0.0/0          10.10.0.38/0     2556  3217848  0    0   1
 52 ip           0.0.0.0/0          10.10.0.32/0     1363484 508754428  0    0   0
 54 ip           0.0.0.0/0          10.10.0.34/0     12137030 16416051963  0    0 56023
q00002: weight 1 pipe 2   50 sl. 13 queues (64 buckets)
          GRED w_q 0.001999 min_th 10 max_th 30 max_p 0.099991
    mask: 0x00 0xffffffff/0x0000 -> 0x00000000/0x0000
BKT Prot ___Source IP/port____ ____Dest. IP/port____ Tot_pkt/bytes Pkt/Byte Drp
  2 ip         10.10.0.4/0             0.0.0.0/0     27238 31756712  0    0   0
  6 ip        10.10.0.38/0             0.0.0.0/0     2008   499815  0    0   0
 10 ip        10.10.0.32/0             0.0.0.0/0     1401851 523088835  0    0   0
 14 ip        10.10.0.34/0             0.0.0.0/0     5256830 406772734  0    0   0
 20 ip        10.10.0.15/0             0.0.0.0/0     187362 16550815  0    0  13
 24 ip         10.10.0.9/0             0.0.0.0/0     73505  7274665  0    0   0
 30 ip        10.10.0.10/0             0.0.0.0/0     1209806 100601648  0    0   0
 32 ip        10.10.0.21/0             0.0.0.0/0     1031868 50865464  0    0   0
 34 ip        10.10.0.20/0             0.0.0.0/0     4681   286707  0    0   0
 40 ip        10.10.0.17/0             0.0.0.0/0     3556  1159543  0    0   0
 44 ip        10.10.0.19/0             0.0.0.0/0     765395 36789684  0    0   0
 46 ip      xx.xx.xx.xx/0             0.0.0.0/0     15009995 1409795314  0    0 1378
 54 ip        10.10.0.30/0             0.0.0.0/0     13160  4478503  0    0   0