1.\" 2.\" $FreeBSD$ 3.\" 4.Dd July 20, 1996 5.Dt IPFW 8 6.Os FreeBSD 7.Sh NAME 8.Nm ipfw 9.Nd controlling utility for IP firewall and traffic shaper 10.Sh SYNOPSIS 11.Nm ipfw 12.Op Fl q 13.Oo 14.Fl p Ar preproc 15.Op Fl D Ar macro Ns Op Ns =value 16.Op Fl U Ar macro 17.Oc 18.Ar file 19.Nm ipfw 20.Oo 21.Fl f 22| 23.Fl q 24.Oc 25flush 26.Nm ipfw 27.Oo 28.Fl q 29.Oc 30{zero|resetlog|delete} 31.Op Ar number ... 32.Nm ipfw 33.Op Fl aftN 34{list|show} 35.Op Ar number ... 36.Nm ipfw 37.Oo 38.Fl q 39.Oc 40add 41.Op Ar number 42.Ar rule-body 43.Nm ipfw 44pipe 45.Ar number 46config 47.Ar pipe-config-options 48.Nm ipfw 49pipe {delete|list|show} 50.Op Ar number ... 51.Sh DESCRIPTION 52.Nm 53is the user interface for controlling the IPFW firewall and 54.Nm dummynet 55traffic shaper in FreeBSD. 56.Pp 57Each incoming or outgoing packet is passed through the 58.Nm 59rules. In case a host is acting as a gateway, packets 60forwarded by the gateway are processed by 61.Nm 62twice. In case a host is acting as a bridge, packets 63forwarded by the bridge are processed by 64.Nm 65once. 66.Pp 67A firewall configuration is made of a list of numbered rules, which are 68scanned for each packet until a match is 69found and the relevant action is performed. Depending on the 70action and certain system settings, packets can be reinjected 71into the firewall at the rule after the matching one for further 72processing. All rules apply to all interfaces, so it is 73responsibility of the sysadmin to write the ruleset in such 74a way to minimize the number of checks. 75.Pp 76A configuration always includes a 77.Ar DEFAULT 78rule (numbered 65535) which cannot be modified by the programmer 79and always matches packets. The action associated with the 80default rule can be either 81.Ar deny 82or 83.Ar allow 84depending on how the kernel is configured. 85.Pp 86All rules have a few associated counters: a packet count and 87a byte count, a log count, and a timestamp indicating the time 88of the last match. Counters can be visualized or reset with 89.Nm 90commands. 91.Pp 92Rules can be added with the 93.Ar add 94command; deleted individually with the 95.Ar delete 96command, and globally with the 97.Ar flush 98command; visualized, optionally with the content of 99the counters, using the 100.Ar show 101and 102.Ar list 103commands. Finally, counters can be reset with the 104.Ar zero 105and 106.Ar resetlog 107commands. 108.Pp 109The following options are available: 110.Bl -tag -width indent 111.It Fl a 112While listing, show counter values. See also 113.Dq show 114command. 115.It Fl f 116Don't ask for confirmation for commands that can cause problems if misused 117(i.e. flush). 118.Ar Note , 119if there is no tty associated with the process, this is implied. 120.It Fl q 121While adding, zeroing, resetlogging or flushing, be quiet about actions (implies 122.Fl f Ns ). 123This is useful for adjusting rules by executing multiple 124.Nm 125commands in a script 126.Po 127e.g., 128.Sq sh /etc/rc.firewall 129.Pc , 130or by processing a file of many 131.Nm 132rules, 133across a remote login session. If a flush is performed in normal 134(verbose) mode (with the default kernel configuration), it prints a message. 135Because all rules are flushed, the 136message cannot be delivered to the login session. This causes the 137remote login session to be closed and the remainder of the ruleset is 138not processed. Access to the console is required to recover. 139.It Fl t 140While listing, show last match timestamp. 141.It Fl N 142Try to resolve addresses and service names in output. 143.El 144.Pp 145To ease configuration, rules can be put into a file which is processed 146using 147.Nm 148as shown in the first synopsis line. The 149.Ar file 150will be read line by line and applied as arguments to the 151.Nm 152command. 153.Pp 154Optionally, a preprocessor can be specified using 155.Fl p Ar preproc 156where 157.Ar file 158is to be piped through. Useful preprocessors include 159.Xr cpp 1 160and 161.Xr m4 1 . 162If 163.Ar preproc 164doesn't start with a slash as its first character, the usual 165.Ev PATH 166name search is performed. Care should be taken with this in environments 167where not all filesystems are mounted (yet) by the time 168.Nm 169is being run (e. g. since they are mounted over NFS). Once 170.Fl p 171has been specified, optional 172.Fl D 173and 174.Fl U 175specifications can follow and will be passed on to the preprocessor. 176This allows for flexible configuration files (like conditionalizing 177them on the local hostname) and the use of macros to centralize 178frequently required arguments like IP addresses. 179.Pp 180The 181.Nm 182.Ar pipe 183commands are used to configure the traffic shaper, as shown in 184the ``TRAFFIC SHAPER CONFIGURATION'' section below. 185.Pp 186.Sh RULE FORMAT 187The 188.Nm 189rule format is the following 190.Pp 191.Op prob Ar match_probability 192.Ar action 193.Op log Op Ar logamount Ar number 194.Ar proto 195from 196.Ar src 197to 198.Ar dst 199.Op interface-spec 200.Op Ar options 201.Pp 202Each packet can be filtered based on the following information that is 203associated with it: 204.Pp 205.Bl -tag -offset indent -compact -width xxxx 206.It Transmit and Receive Interface (by name or address) 207.It Direction (Incoming or Outgoing) 208.It Source and Destination IP Address (possibly masked) 209.It Protocol (TCP, UDP, ICMP, etc.) 210.It Source and Destination Port (lists, ranges or masks) 211.It TCP Flags 212.It IP Fragment Flag 213.It IP Options 214.It ICMP Types 215.It User/Group ID of the socket associated with the packet 216.El 217.Pp 218Note that may be dangerous to filter on the source IP address or 219source TCP/UDP port because either or both could easily be spoofed. 220.Pp 221.Ar prob match_probability 222.Bd -ragged -offset flag 223A match is only declared with the specified 224probability (floating point number between 0 and 1). This can be useful for a number of applications 225such as random packet drop or (in conjunction with 226.Xr dummynet 4 227) to simulate the effect of multiple paths leading to out-of-order 228packet delivery. 229.Ed 230.Pp 231.Ar action : 232.Bl -hang -offset flag -width 1234567890123456 233.It Ar allow 234Allow packets that match rule. 235The search terminates. Aliases are 236.Ar pass , 237.Ar permit , 238and 239.Ar accept . 240.It Ar deny 241Discard packets that match this rule. 242The search terminates. 243.Ar Drop 244is an alias for 245.Ar deny . 246.It Ar reject 247(Deprecated.) Discard packets that match this rule, and try to send an ICMP 248host unreachable notice. 249The search terminates. 250.It Ar unreach code 251Discard packets that match this rule, and try to send an ICMP 252unreachable notice with code 253.Ar code , 254where 255.Ar code 256is a number from zero to 255, or one of these aliases: 257.Ar net , 258.Ar host , 259.Ar protocol , 260.Ar port , 261.Ar needfrag , 262.Ar srcfail , 263.Ar net-unknown , 264.Ar host-unknown , 265.Ar isolated , 266.Ar net-prohib , 267.Ar host-prohib , 268.Ar tosnet , 269.Ar toshost , 270.Ar filter-prohib , 271.Ar host-precedence , 272or 273.Ar precedence-cutoff . 274The search terminates. 275.It Ar reset 276TCP packets only. Discard packets that match this rule, 277and try to send a TCP reset 278.Pq RST 279notice. 280The search terminates. 281.It Ar count 282Update counters for all packets that match rule. 283The search continues with the next rule. 284.It Ar divert port 285Divert packets that match this rule to the 286.Xr divert 4 287socket bound to port 288.Ar port . 289The search terminates. 290.It Ar tee port 291Send a copy of packets matching this rule to the 292.Xr divert 4 293socket bound to port 294.Ar port . 295The search terminates and the original packet is accepted 296(but see BUGS below). 297.It Ar fwd ipaddr Op ,port 298Change the next-hop on matching packets to 299.Ar ipaddr , 300which can be an IP address in dotted quad or a host name. 301If 302.Ar ipaddr 303is not a directly-reachable address, the route 304as found in the local routing table for that IP is used 305instead. 306If 307.Ar ipaddr 308is a local address, then on a packet entering the system from a remote 309host it will be diverted to 310.Ar port 311on the local machine, keeping the local address of the socket set 312to the original IP address the packet was destined for. This is intended 313for use with transparent proxy servers. If the IP is not 314a local address then the port number (if specified) is ignored and 315the rule only applies to packets leaving the system. This will 316also map addresses to local ports when packets are generated locally. 317The search terminates if this rule matches. If the port number is not 318given then the port number in the packet is used, so that a packet for 319an external machine port Y would be forwarded to local port Y. The kernel 320must have been compiled with options IPFIREWALL_FORWARD. 321.It Ar pipe pipe_nr 322Pass packet to a 323.Xr dummynet 4 324``pipe'' (for bandwidth limitation, delay etc.). See the 325.Xr dummynet 4 326manpage for further information. The search terminates; however, 327on exit from the pipe and if the sysctl variable 328net.inet.ip.fw.one_pass is not set, the packet is passed again to 329the firewall code starting from the next rule. 330.It Ar skipto number 331Skip all subsequent rules numbered less than 332.Ar number . 333The search continues with the first rule numbered 334.Ar number 335or higher. 336.El 337.Pp 338.Ar log Op Ar logamount Ar number 339.Bd -ragged -offset flag 340If the kernel was compiled with 341.Dv IPFIREWALL_VERBOSE , 342then when a packet matches a rule with the 343.Ar log 344keyword a message will be printed on the console. 345If the kernel was compiled with the 346.Dv IPFIREWALL_VERBOSE_LIMIT 347option, then by default logging will cease after the number 348of packets specified by the option are received for that 349particular chain entry. However, if 350.Ar logamount Ar number 351is used, that 352.Ar number 353will be the default logging limit rather than 354.Dv IPFIREWALL_VERBOSE_LIMIT . 355Logging may then be re-enabled by clearing the logging counter 356or the packet counter for that entry. 357.Pp 358Console logging and the log limit are adjustable dynamically 359through the 360.Xr sysctl 8 361interface in the MIB base of 362.Dv net.inet.ip.fw . 363.Ed 364.Pp 365.Ar proto : 366.Bd -ragged -offset flag 367An IP protocol specified by number or name (see 368.Pa /etc/protocols 369for a complete list). 370The 371.Ar ip 372or 373.Ar all 374keywords mean any protocol will match. 375.Ed 376.Pp 377.Ar src 378and 379.Ar dst : 380.Bd -ragged -offset flag 381.Ar <address/mask> Op Ar ports 382.Pp 383The 384.Em <address/mask> 385may be specified as: 386.Pp 387.Bl -hang -offset 0n -width 1234567890123456 388.It Ar ipno 389An ipnumber of the form 1.2.3.4. 390Only this exact ip number match the rule. 391.It Ar ipno/bits 392An ipnumber with a mask width of the form 1.2.3.4/24. 393In this case all ip numbers from 1.2.3.0 to 1.2.3.255 will match. 394.It Ar ipno:mask 395An ipnumber with a mask of the form 1.2.3.4:255.255.240.0. 396In this case all ip numbers from 1.2.0.0 to 1.2.15.255 will match. 397.El 398.Pp 399The sense of the match can be inverted by preceding an address with the 400.Dq not 401modifier, causing all other addresses to be matched instead. This 402does not affect the selection of port numbers. 403.Pp 404With the TCP and UDP protocols, optional 405.Em ports 406may be specified as: 407.Pp 408.Bl -hang -offset flag 409.It Ns {port|port-port|port:mask} Ns Op ,port Ns Op ,... 410.El 411.Pp 412The 413.Ql - 414notation specifies a range of ports (including boundaries). 415.Pp 416The 417.Ql \: 418notation specifies a port and a mask, a match is declared if 419the port number in the packet matches the one in the rule, 420limited to the bits which are set in the mask. 421.Pp 422Service names (from 423.Pa /etc/services ) 424may be used instead of numeric port values. 425A range may only be specified as the first value, 426and the length of the port list is limited to 427.Dv IP_FW_MAX_PORTS 428(as defined in 429.Pa /usr/src/sys/netinet/ip_fw.h ) 430ports. 431A 432.Ql \e 433can be used to escape the 434.Ql - 435character in a service name: 436.Pp 437.Dl ipfw add count tcp from any ftp\e\e-data-ftp to any 438.Pp 439Fragmented packets which have a non-zero offset (i.e. not the first 440fragment) will never match a rule which has one or more port 441specifications. See the 442.Ar frag 443option for details on matching fragmented packets. 444.Pp 445.Ed 446.Ar interface-spec : 447.Pp 448.Bd -ragged -offset flag 449Some combinations of the following specifiers are allowed: 450.Bl -hang -offset 0n -width 1234567890123456 451.It Ar in 452Only match incoming packets. 453.It Ar out 454Only match outgoing packets. 455.It Ar via ifX 456Packet must be going through interface 457.Ar ifX. 458.It Ar via if* 459Packet must be going through interface 460.Ar ifX , 461where X is any unit number. 462.It Ar via any 463Packet must be going through 464.Em some 465interface. 466.It Ar via ipno 467Packet must be going through the interface having IP address 468.Ar ipno . 469.El 470.Pp 471The 472.Ar via 473keyword causes the interface to always be checked. 474If 475.Ar recv 476or 477.Ar xmit 478is used instead of 479.Ar via , 480then the only receive or transmit interface (respectively) is checked. 481By specifying both, it is possible to match packets based on both receive 482and transmit interface, e.g.: 483.Pp 484.Dl "ipfw add 100 deny ip from any to any out recv ed0 xmit ed1" 485.Pp 486The 487.Ar recv 488interface can be tested on either incoming or outgoing packets, while the 489.Ar xmit 490interface can only be tested on outgoing packets. So 491.Ar out 492is required (and 493.Ar in 494invalid) whenever 495.Ar xmit 496is used. Specifying 497.Ar via 498together with 499.Ar xmit 500or 501.Ar recv 502is invalid. 503.Pp 504A packet may not have a receive or transmit interface: packets originating 505from the local host have no receive interface, while packets destined for 506the local host have no transmit interface. 507.Ed 508.Pp 509.Ar options : 510.Bl -hang -offset flag -width 1234567890123456 511.It frag 512Match if the packet is a fragment and this is not the first fragment 513of the datagram. 514.Ar frag 515may not be used in conjunction with either 516.Ar tcpflags 517or TCP/UDP port specifications. 518.It ipoptions Ar spec 519Match if the IP header contains the comma separated list of 520options specified in 521.Ar spec . 522The supported IP options are: 523.Pp 524.Ar ssrr 525(strict source route), 526.Ar lsrr 527(loose source route), 528.Ar rr 529(record packet route), and 530.Ar ts 531(timestamp). 532The absence of a particular option may be denoted 533with a 534.Dq ! . 535.It established 536Match packets that have the RST or ACK bits set. 537TCP packets only. 538.It setup 539Match packets that have the SYN bit set but no ACK bit. 540TCP packets only. 541.It tcpflags Ar spec 542Match if the TCP header contains the comma separated list of 543flags specified in 544.Ar spec . 545The supported TCP flags are: 546.Pp 547.Ar fin , 548.Ar syn , 549.Ar rst , 550.Ar psh , 551.Ar ack , 552and 553.Ar urg . 554The absence of a particular flag may be denoted 555with a 556.Dq ! . 557A rule which contains a 558.Ar tcpflags 559specification can never match a fragmented packet which has 560a non-zero offset. See the 561.Ar frag 562option for details on matching fragmented packets. 563.It icmptypes Ar types 564Match if the ICMP type is in the list 565.Ar types . 566The list may be specified as any combination of ranges 567or individual types separated by commas. 568The supported ICMP types are: 569.Pp 570echo reply 571.Pq Ar 0 , 572destination unreachable 573.Pq Ar 3 , 574source quench 575.Pq Ar 4 , 576redirect 577.Pq Ar 5 , 578echo request 579.Pq Ar 8 , 580router advertisement 581.Pq Ar 9 , 582router solicitation 583.Pq Ar 10 , 584time-to-live exceeded 585.Pq Ar 11 , 586IP header bad 587.Pq Ar 12 , 588timestamp request 589.Pq Ar 13 ,timestamp reply 590.Pq Ar 14 , 591information request 592.Pq Ar 15 , 593information reply 594.Pq Ar 16 , 595address mask request 596.Pq Ar 17 , 597and address mask reply 598.Pq Ar 18 599.It Ar uid user 600Match all TCP or UDP packets sent by or received for a 601.Ar user . 602A 603.Ar user 604may be matched by name or identification number. 605.It Ar gid group 606Match all TCP or UDP packets sent by or received for a 607.Ar group . 608A 609.Ar group 610may be matched by name or identification number. 611.El 612.Sh TRAFFIC SHAPER CONFIGURATION 613Ipfw is also the user interface for the 614.Xr dummynet 4 615traffic shaper. 616The shaper operates by passing packets to objects called 617.Ar pipes , 618which emulates a link with given bandwidth, propagation delay, 619queue size and packet loss rate. 620The 621.Nm 622pipe configuration format is the following 623.Pp 624.Ar pipe number config 625.Op bw Ar bandwidth 626.Op queue Ar {slots|size} 627.Op delay Ar delay-ms 628.Op plr Ar loss-probability 629.Op mask Ar {all | {dst-ip|src-ip|dst-port|src-port|proto} bitmask} 630.Op buckets Ar hash-table-size 631.Pp 632The following parameters can be configured for a pipe: 633.Bl -hang -offset flag -width 1234567890 634.It bw Ar bandwidth 635Bandwidth, measured in 636.Ar [K|M]{bit/s|Byte/s} . 637A value of 0 (default) means unlimited bandwidth. 638The unit must follow immediately the number, as in 639.Dl "ipfw pipe 1 config bw 300Kbit/s queue 50KBytes" 640.It delay Ar ms-delay 641propagation delay, measured in milliseconds. The value is rounded 642to the next multiple of the clock tick (typically 10ms, but it is 643good practice to run kernels with "options HZ=1000" to reduce 644the granularity to 1ms or less). Default value is 0, meaning 645no delay. 646.It queue Ar {slots|size} 647queue size, in slots or KBytes. Default value is 50 slots, which 648is the typical queue size for Ethernet devices. Note that for 649slow speed links you should keep the queue size short or your 650traffic might be affected by a significant queueing delay. E.g. 65150 max-sized ethernet packets (1500 652bytes) mean 600Kbit or 20s of queue on a 30Kbit/s pipe. 653Even worse effect can result if you get 654packets from an interface with a much larger MTU e.g. the loopback 655interface with its 16KB packets. 656.It plr packet-loss-rate 657packet loss rate. NN is a floating-point number, with 0 meaning 658no loss, 1 means 100% loss. The loss rate is internally represented 659on 31 bits. 660.It mask Ar mask-specifier 661dummynet allows you to generate per-flow queues 662using a single pipe specification. A flow identifier is constructed 663by masking the IP addresses, ports and protocol types as specified 664in the pipe configuration. Packets with the same ID after masking fall 665into the same queue. Available mask specifiers are a combination 666of the following: 667.Ar dst-ip mask , src-ip mask , 668.Ar dst-port mask , src-port mask , 669.Ar proto mask 670or 671.Ar all 672where the latter means all bits in all fields are significant. 673.It buckets Ar NN 674Specifies the size of the hash table used for storing the various queues. 675Default value is 64 controlled by the sysctl variable 676.Ar net.inet.ip.dummynet.hash_size , 677allowed range is 16 to 1024. 678.El 679.Sh CHECKLIST 680Here are some important points to consider when designing your 681rules: 682.Bl -bullet -hang -offset flag 683.It 684Remember that you filter both packets going in and out. 685Most connections need packets going in both directions. 686.It 687Remember to test very carefully. 688It is a good idea to be near the console when doing this. 689.It 690Don't forget the loopback interface. 691.El 692.Sh FINE POINTS 693There is one kind of packet that the firewall will always discard, 694that is an IP fragment with a fragment offset of one. 695This is a valid packet, but it only has one use, to try to circumvent 696firewalls. 697.Pp 698If you are logged in over a network, loading the KLD version of 699.Nm 700is probably not as straightforward as you would think. 701I recommend this command line: 702.Bd -literal -offset center 703kldload /modules/ipfw.ko && \e 704ipfw add 32000 allow all from any to any 705.Ed 706.Pp 707Along the same lines, doing an 708.Bd -literal -offset center 709ipfw flush 710.Ed 711.Pp 712in similar surroundings is also a bad idea. 713.Pp 714The IP filter list may not be modified if the system security level 715is set to 3 or higher 716.Po 717see 718.Xr init 8 719for information on system security levels 720.Pc . 721.Sh PACKET DIVERSION 722A divert socket bound to the specified port will receive all packets diverted 723to that port; see 724.Xr divert 4 . 725If no socket is bound to the destination port, or if the kernel 726wasn't compiled with divert socket support, the packets are dropped. 727.Sh EXAMPLES 728This command adds an entry which denies all tcp packets from 729.Em cracker.evil.org 730to the telnet port of 731.Em wolf.tambov.su 732from being forwarded by the host: 733.Pp 734.Dl ipfw add deny tcp from cracker.evil.org to wolf.tambov.su 23 735.Pp 736This one disallows any connection from the entire crackers network to 737my host: 738.Pp 739.Dl ipfw add deny all from 123.45.67.0/24 to my.host.org 740.Pp 741Here is a good usage of the 742.Ar list 743command to see accounting records 744and timestamp information: 745.Pp 746.Dl ipfw -at l 747.Pp 748or in short form without timestamps: 749.Pp 750.Dl ipfw -a l 751.Pp 752This rule diverts all incoming packets from 192.168.2.0/24 to divert port 5000: 753.Pp 754.Dl ipfw divert 5000 all from 192.168.2.0/24 to any in 755.Pp 756The following rules show some of the applications of ipfw and 757dummynet for simulations and the like. 758.Pp 759This rule drops random packets with a probability of 5% 760.Pp 761.Dl "ipfw add prob 0.05 deny ip from any to any in" 762.Pp 763A similar effect can be achieved making use of dummynet pipes: 764.Pp 765.Dl "ipfw add pipe 10 ip from any to any" 766.Dl "ipfw pipe 10 config plr 0.05" 767.Pp 768We can use pipes to artificially limit bandwidth e.g. on a machine 769acting as a router, if we want to limit traffic from local clients 770on 192.168.2.0/24 we do: 771.Pp 772.Dl "ipfw add pipe 1 ip from 192.168.2.0/24 to any out" 773.Dl "ipfw pipe 1 config bw 300Kbit/s queue 50KBytes" 774.Pp 775note that we use the 776.Ql out 777specifier so that the rule is not used twice. Remember in fact 778that ipfw rules are checked both on incoming and outgoing packets. 779.Pp 780Should we like to simulate a bidirectional link with bandwidth 781limitations, the correct way is the following: 782.Pp 783.Dl "ipfw add pipe 1 ip from any to any out" 784.Dl "ipfw add pipe 2 ip from any to any in" 785.Dl "ipfw pipe 1 config bw 64Kbit/s queue 10Kbytes" 786.Dl "ipfw pipe 2 config bw 64Kbit/s queue 10Kbytes" 787.Pp 788The above can be very useful e.g. if you want to see how your fancy 789Web page will look for a residential user which is connected only through 790a slow link. 791You should not use only 792one pipe for both directions, unless you want to simulate a half-duplex 793medium (e.g. appletalk, Ethernet, IRDA). 794It is not necessary that both pipes have the same configuration, 795so we can also simulate asymmetric links. 796.Pp 797Another typical application of the traffic shaper is to introduce some 798delay in the communication. This can affect a lot applications which do 799a lot of Remote Procedure Calls, and where the round-trip-time of the 800connection often becomes a limiting factor much more than bandwidth: 801.Pp 802.Dl "ipfw add pipe 1 ip from any to any out" 803.Dl "ipfw add pipe 2 ip from any to any in" 804.Dl "ipfw pipe 1 config delay 250ms bw 1Mbit/s" 805.Dl "ipfw pipe 2 config delay 250ms bw 1Mbit/s" 806.Pp 807Per-flow queueing can be useful for a variety of purposes. A very 808simple one is counting traffic: 809.Pp 810.Dl "ipfw add pipe 1 tcp from any to any" 811.Dl "ipfw add pipe 1 udp from any to any" 812.Dl "ipfw add pipe 1 ip from any to any" 813.Dl "ipfw pipe 1 config mask all" 814.Pp 815The above set of rules will create queues (and collect statistics) 816for all traffic. Because the pipes have no limitations, the only 817effect is collecting statistics. Note that we need 3 rules, not just 818the last one, because when ipfw tries to match ip packets it will 819not consider ports, so we would not see connections on separate ports 820as different ones. 821.Pp 822A more sophisticated example is limiting the outbound traffic on a net 823with per-host limits, rather than per-network limits: 824.Pp 825.Dl "ipfw add pipe 1 ip from 192.168.2.0/24 to any out" 826.Dl "ipfw add pipe 2 ip from any to 192.168.2.0/24 in" 827.Dl "ipfw pipe 1 config mask src-ip 0x000000ff bw 200Kbit/s queue 20Kbytes" 828.Dl "ipfw pipe 2 config mask dst-ip 0x000000ff bw 200Kbit/s queue 20Kbytes" 829.Sh SEE ALSO 830.Xr cpp 1 , 831.Xr m4 1 , 832.Xr divert 4 , 833.Xr dummynet 4 , 834.Xr bridge 4 , 835.Xr ip 4 , 836.Xr ipfirewall 4 , 837.Xr protocols 5 , 838.Xr services 5 , 839.Xr init 8 , 840.Xr kldload 8 , 841.Xr reboot 8 , 842.Xr sysctl 8 , 843.Xr syslogd 8 . 844.Sh BUGS 845.Pp 846The syntax has grown over the years and it is not very clean. 847.Pp 848.Em WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!! 849.Pp 850This program can put your computer in rather unusable state. When 851using it for the first time, work on the console of the computer, and 852do 853.Em NOT 854do anything you don't understand. 855.Pp 856When manipulating/adding chain entries, service and protocol names are 857not accepted. 858.Pp 859Incoming packet fragments diverted by 860.Ar divert 861or 862.Ar tee 863are reassembled before delivery to the socket. 864.Pp 865Packets that match a 866.Ar tee 867rule should not be immediately accepted, but should continue 868going through the rule list. This may be fixed in a later version. 869.Sh AUTHORS 870.An Ugen J. S. Antsilevich , 871.An Poul-Henning Kamp , 872.An Alex Nash , 873.An Archie Cobbs , 874.An Luigi Rizzo . 875.Pp 876API based upon code written by 877Daniel Boulet 878for BSDI. 879.Pp 880Work on dummynet traffic shaper supported by Akamba Corp. 881.Sh HISTORY 882.Nm Ipfw 883first appeared in 884.Fx 2.0 . 885.Nm dummynet 886was introduced in 887.Fx 2.2.8 888