xok Posted June 2, 2010 Доброй ночи всем! Помогите настроить ng_nat на два канала. Суть в следующем: по 1 (ext_ip) должен ходить http трафик, а по 2 (ext_ip2) всё остальное. Вот как у меня сейчас построено на одном: #!/bin/sh fwcmd="/sbin/ipfw" ngctl="/usr/sbin/ngctl" ext_if="em0" ext_ip="192.168.0.1" ext_ip2="192.168.1.1" int_if="em1" int_ip="10.10.0.1" ${ngctl} mkpeer ipfw: nat 60 out ${ngctl} name ipfw:60 nat ${ngctl} connect ipfw: nat: 61 in ${ngctl} msg nat: setaliasaddr ${ext_ip} ${fwcmd} -f flush ${fwcmd} table 127 flush ${fwcmd} table 127 add 10.10.0.0/24 ${fwcmd} add 00001 allow ip from any to any via lo0 ${fwcmd} add 00031 netgraph 61 all from any to ${ext_ip} in via ${ext_if} ${fwcmd} add 60022 netgraph 60 ip from "table(127)" to any Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
Ilya Evseev Posted June 3, 2010 ng_nat не принимает решения о маршруте. PBR в ipfw делается правилами fwd (старый подход) и setfib (новый подход). Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
xok Posted June 3, 2010 хорошо! И как же в моём случае реализовать это дело на setfib? Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
Dyr Posted January 23, 2012 (edited) Больше для себя отвечу. Вот так это делается. Правило 00500 отвечает за то, какие сети из диапазона 10.1.0.0/16 отправлять не через дефолтный ReTN, а через RosTelecom: 00400 setfib 1 ip from any to any via vlan500 // RosTelecom 00500 setfib 1 ip from table(2) to any // Selective sources for PBR via RosTelecom 00600 setfib 1 ip from 212.xx.199.248/29 to any // RosTelecom 00700 setfib 1 ip from any to 212.xx.199.248/29 // RosTelecom 00800 fwd 212.xx.199.249 ip from 212.xx.199.250 to any xmit vlan720 // Redirect RT traffic from wrong interface, i.e. my own 01000 count log logamount 29999 tcp from any to any dst-port 25 setup recv vlan100 // Dumb antispam rule 01200 allow tcp from any to me dst-port 22 setup keep-state // SSH ... 03000 skipto 6000 ip from table(1) to any // Skip deny rules for allowed ips 03100 unreach filter-prohib ip from any to not me in recv vlan100 // Verbose deny for internal lan 04000 netgraph 4000 ip from any to me recv vlan720 // Inside NAT 04100 netgraph 4100 ip from any to 212.xx.199.251 recv vlan500 // Inside NAT 06000 pipe tablearg ip from any to table(4) xmit vlan100 // Shaping to customers 06100 pipe tablearg ip from table(5) to any xmit vlan720 // Shaping from customers to ReTN channel 06200 pipe tablearg ip from table(5) to any xmit vlan500 // Shaping from customers to RosTelecom channel 07000 netgraph 7000 ip from 10.1.0.0/16 to any xmit vlan720 // Outside NAT to ReTN channel 07100 netgraph 7100 ip from 10.1.0.0/16 to any xmit vlan500 // Outside NAT to RosTelecom channel 08000 allow ip from me to any xmit vlan720 // Allow all from me (and NAT) to ReTN 08100 allow ip from 212.xx.199.248/29 to any xmit vlan500 // Allow me (net) to RosTelecom 08150 allow tcp from me to any setup keep-state // Tcp from me 08160 allow udp from any to me keep-state // Open my udp 08170 allow udp from me to any keep-state // Open my udp 08200 allow ip from any to any established 08300 allow ip from table(1) to any // Excessive rules 08400 allow ip from any to table(1) // Excessive rules 08500 allow icmp from any to any icmptypes 0,3,4,8,11 65530 deny log logamount 100 ip from any to any 65535 allow ip from any to any Edited January 23, 2012 by Dyr Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
vlad11 Posted January 23, 2012 (edited) ng_nat не принимает решения о маршруте. PBR в ipfw делается правилами fwd (старый подход) и setfib (новый подход). У мну одновременно юзаются fwd, setfib и tag|tagged Edited January 23, 2012 by vlad11 Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
Dyr Posted January 23, 2012 Про первые два понятно, а tag|tagged зачем используете? Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
vlad11 Posted January 25, 2012 Про первые два понятно, а tag|tagged зачем используете? мне так легче маркировать траффик Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...
Dyr Posted January 25, 2012 Логично :) Вставить ник Quote Ответить с цитированием Share this post Link to post Share on other sites More sharing options...