1.\" 2.\" $FreeBSD$ 3.\" 4.Dd December 1, 2003 5.Dt IPFW 8 6.Os 7.Sh NAME 8.Nm ipfw 9.Nd IP firewall and traffic shaper control program 10.Sh SYNOPSIS 11.Nm 12.Op Fl cq 13.Cm add 14.Ar rule 15.Nm 16.Op Fl acdefnNStT 17.Brq Cm list | show 18.Op Ar rule | first-last ... 19.Nm 20.Op Fl f | q 21.Cm flush 22.Nm 23.Op Fl q 24.Brq Cm delete | zero | resetlog 25.Op Cm set 26.Op Ar number ... 27.Nm 28.Cm enable 29.Brq Cm firewall | one_pass | debug | verbose | dyn_keepalive 30.Nm 31.Cm disable 32.Brq Cm firewall | one_pass | debug | verbose | dyn_keepalive 33.Pp 34.Nm 35.Cm set Oo Cm disable Ar number ... Oc Op Cm enable Ar number ... 36.Nm 37.Cm set move 38.Op Cm rule 39.Ar number Cm to Ar number 40.Nm 41.Cm set swap Ar number number 42.Nm 43.Cm set show 44.Pp 45.Nm 46.Brq Cm pipe | queue 47.Ar number 48.Cm config 49.Ar config-options 50.Nm 51.Op Fl s Op Ar field 52.Brq Cm pipe | queue 53.Brq Cm delete | list | show 54.Op Ar number ... 55.Pp 56.Nm 57.Op Fl cfnNqS 58.Oo 59.Fl p Ar preproc 60.Oo 61.Ar preproc-flags 62.Oc 63.Oc 64.Ar pathname 65.Sh DESCRIPTION 66The 67.Nm 68utility is the user interface for controlling the 69.Xr ipfw 4 70firewall and the 71.Xr dummynet 4 72traffic shaper in 73.Fx . 74.Pp 75.Bd -ragged -offset XXXX 76.Em NOTE: 77this manual page documents the newer version of 78.Nm 79introduced in 80.Fx 81CURRENT in July 2002, also known as 82.Nm ipfw2 . 83.Nm ipfw2 84is a superset of the old firewall, 85.Nm ipfw1 . 86The differences between the two are listed in Section 87.Sx IPFW2 ENHANCEMENTS , 88which you are encouraged to read to revise older rulesets and possibly 89write them more efficiently. 90See Section 91.Sx USING IPFW2 IN FreeBSD-STABLE 92for instructions on how to run 93.Nm ipfw2 94on 95.Fx 96STABLE. 97.Ed 98.Pp 99An 100.Nm 101configuration, or 102.Em ruleset , 103is made of a list of 104.Em rules 105numbered from 1 to 65535. 106Packets are passed to 107.Nm 108from a number of different places in the protocol stack 109(depending on the source and destination of the packet, 110it is possible that 111.Nm 112is invoked multiple times on the same packet). 113The packet passed to the firewall is compared 114against each of the rules in the firewall 115.Em ruleset . 116When a match is found, the action corresponding to the 117matching rule is performed. 118.Pp 119Depending on the action and certain system settings, packets 120can be reinjected into the firewall at some rule after the 121matching one for further processing. 122.Pp 123An 124.Nm 125ruleset always includes a 126.Em default 127rule (numbered 65535) which cannot be modified or deleted, 128and matches all packets. 129The action associated with the 130.Em default 131rule can be either 132.Cm deny 133or 134.Cm allow 135depending on how the kernel is configured. 136.Pp 137If the ruleset includes one or more rules with the 138.Cm keep-state 139or 140.Cm limit 141option, then 142.Nm 143assumes a 144.Em stateful 145behaviour, i.e. upon a match it will create dynamic rules matching 146the exact parameters (addresses and ports) of the matching packet. 147.Pp 148These dynamic rules, which have a limited lifetime, are checked 149at the first occurrence of a 150.Cm check-state , 151.Cm keep-state 152or 153.Cm limit 154rule, and are typically used to open the firewall on-demand to 155legitimate traffic only. 156See the 157.Sx STATEFUL FIREWALL 158and 159.Sx EXAMPLES 160Sections below for more information on the stateful behaviour of 161.Nm . 162.Pp 163All rules (including dynamic ones) have a few associated counters: 164a packet count, a byte count, a log count and a timestamp 165indicating the time of the last match. 166Counters can be displayed or reset with 167.Nm 168commands. 169.Pp 170Rules can be added with the 171.Cm add 172command; deleted individually or in groups with the 173.Cm delete 174command, and globally (except those in set 31) with the 175.Cm flush 176command; displayed, optionally with the content of the 177counters, using the 178.Cm show 179and 180.Cm list 181commands. 182Finally, counters can be reset with the 183.Cm zero 184and 185.Cm resetlog 186commands. 187.Pp 188Also, each rule belongs to one of 32 different 189.Em sets 190, and there are 191.Nm 192commands to atomically manipulate sets, such as enable, 193disable, swap sets, move all rules in a set to another 194one, delete all rules in a set. These can be useful to 195install temporary configurations, or to test them. 196See Section 197.Sx SETS OF RULES 198for more information on 199.Em sets . 200.Pp 201The following options are available: 202.Bl -tag -width indent 203.It Fl a 204While listing, show counter values. 205The 206.Cm show 207command just implies this option. 208.It Fl b 209Only show the action and the comment, not the body of a rule. 210Implies 211.Fl c . 212.It Fl c 213When entering or showing rules, print them in compact form, 214i.e. without the optional "ip from any to any" string 215when this does not carry any additional information. 216.It Fl d 217While listing, show dynamic rules in addition to static ones. 218.It Fl e 219While listing, if the 220.Fl d 221option was specified, also show expired dynamic rules. 222.It Fl f 223Don't ask for confirmation for commands that can cause problems 224if misused, 225.No i.e. Cm flush . 226If there is no tty associated with the process, this is implied. 227.It Fl n 228Only check syntax of the command strings, without actually passing 229them to the kernel. 230.It Fl N 231Try to resolve addresses and service names in output. 232.It Fl q 233While 234.Cm add Ns ing , 235.Cm zero Ns ing , 236.Cm resetlog Ns ging 237or 238.Cm flush Ns ing , 239be quiet about actions 240(implies 241.Fl f ) . 242This is useful for adjusting rules by executing multiple 243.Nm 244commands in a script 245(e.g., 246.Ql sh\ /etc/rc.firewall ) , 247or by processing a file of many 248.Nm 249rules across a remote login session. 250If a 251.Cm flush 252is performed in normal (verbose) mode (with the default kernel 253configuration), it prints a message. 254Because all rules are flushed, the message might not be delivered 255to the login session, causing the remote login session to be closed 256and the remainder of the ruleset to not be processed. 257Access to the console would then be required to recover. 258.It Fl S 259While listing rules, show the 260.Em set 261each rule belongs to. 262If this flag is not specified, disabled rules will not be 263listed. 264.It Fl s Op Ar field 265While listing pipes, sort according to one of the four 266counters (total or current packets or bytes). 267.It Fl t 268While listing, show last match timestamp (converted with ctime()). 269.It Fl T 270While listing, show last match timestamp (as seconds from the epoch). 271This form can be more convenient for postprocessing by scripts. 272.El 273.Pp 274To ease configuration, rules can be put into a file which is 275processed using 276.Nm 277as shown in the last synopsis line. 278An absolute 279.Ar pathname 280must be used. 281The file will be read line by line and applied as arguments to the 282.Nm 283utility. 284.Pp 285Optionally, a preprocessor can be specified using 286.Fl p Ar preproc 287where 288.Ar pathname 289is to be piped through. 290Useful preprocessors include 291.Xr cpp 1 292and 293.Xr m4 1 . 294If 295.Ar preproc 296doesn't start with a slash 297.Pq Ql / 298as its first character, the usual 299.Ev PATH 300name search is performed. 301Care should be taken with this in environments where not all 302file systems are mounted (yet) by the time 303.Nm 304is being run (e.g. when they are mounted over NFS). 305Once 306.Fl p 307has been specified, any additional arguments as passed on to the preprocessor 308for interpretation. 309This allows for flexible configuration files (like conditionalizing 310them on the local hostname) and the use of macros to centralize 311frequently required arguments like IP addresses. 312.Pp 313The 314.Nm 315.Cm pipe 316and 317.Cm queue 318commands are used to configure the traffic shaper, as shown in the 319.Sx TRAFFIC SHAPER (DUMMYNET) CONFIGURATION 320Section below. 321.Pp 322If the world and the kernel get out of sync the 323.Nm 324ABI may break, preventing you from being able to add any rules. This can 325adversely effect the booting process. You can use 326.Nm 327.Cm disable 328.Cm firewall 329to temporarily disable the firewall to regain access to the network, 330allowing you to fix the problem. 331.Sh PACKET FLOW 332A packet is checked against the active ruleset in multiple places 333in the protocol stack, under control of several sysctl variables. 334These places and variables are shown below, and it is important to 335have this picture in mind in order to design a correct ruleset. 336.Bd -literal -offset indent 337 ^ to upper layers V 338 | | 339 +----------->-----------+ 340 ^ V 341 [ip_input] [ip_output] net.inet.ip.fw.enable=1 342 | | 343 ^ V 344[ether_demux] [ether_output_frame] net.link.ether.ipfw=1 345 | | 346 +-->--[bdg_forward]-->--+ net.link.ether.bridge_ipfw=1 347 ^ V 348 | to devices | 349.Ed 350.Pp 351As can be noted from the above picture, the number of 352times the same packet goes through the firewall can 353vary between 0 and 4 depending on packet source and 354destination, and system configuration. 355.Pp 356Note that as packets flow through the stack, headers can be 357stripped or added to it, and so they may or may not be available 358for inspection. 359E.g., incoming packets will include the MAC header when 360.Nm 361is invoked from 362.Cm ether_demux() , 363but the same packets will have the MAC header stripped off when 364.Nm 365is invoked from 366.Cm ip_input() . 367.Pp 368Also note that each packet is always checked against the complete ruleset, 369irrespective of the place where the check occurs, or the source of the packet. 370If a rule contains some match patterns or actions which are not valid 371for the place of invocation (e.g. trying to match a MAC header within 372.Cm ip_input() 373), the match pattern will not match, but a 374.Cm not 375operator in front of such patterns 376.Em will 377cause the pattern to 378.Em always 379match on those packets. 380It is thus the responsibility of 381the programmer, if necessary, to write a suitable ruleset to 382differentiate among the possible places. 383.Cm skipto 384rules can be useful here, as an example: 385.Bd -literal -offset indent 386# packets from ether_demux or bdg_forward 387ipfw add 10 skipto 1000 all from any to any layer2 in 388# packets from ip_input 389ipfw add 10 skipto 2000 all from any to any not layer2 in 390# packets from ip_output 391ipfw add 10 skipto 3000 all from any to any not layer2 out 392# packets from ether_output_frame 393ipfw add 10 skipto 4000 all from any to any layer2 out 394.Ed 395.Pp 396(yes, at the moment there is no way to differentiate between 397ether_demux and bdg_forward). 398.Sh SYNTAX 399In general, each keyword or argument must be provided as 400a separate command line argument, with no leading or trailing 401spaces. Keywords are case-sensitive, whereas arguments may 402or may not be case-sensitive depending on their nature 403(e.g. uid's are, hostnames are not). 404.Pp 405In 406.Nm ipfw2 407you can introduce spaces after commas ',' to make 408the line more readable. You can also put the entire 409command (including flags) into a single argument. 410E.g. the following forms are equivalent: 411.Bd -literal -offset indent 412ipfw -q add deny src-ip 10.0.0.0/24,127.0.0.1/8 413ipfw -q add deny src-ip 10.0.0.0/24, 127.0.0.1/8 414ipfw "-q add deny src-ip 10.0.0.0/24, 127.0.0.1/8" 415.Ed 416.Sh RULE FORMAT 417The format of 418.Nm 419rules is the following: 420.Bd -ragged -offset indent 421.Op Ar rule_number 422.Op Cm set Ar set_number 423.Op Cm prob Ar match_probability 424.br 425.Ar " " action 426.Op Cm log Op Cm logamount Ar number 427.Ar body 428.Ed 429.Pp 430where the body of the rule specifies which information is used 431for filtering packets, among the following: 432.Pp 433.Bl -tag -width "Source and dest. addresses and ports" -offset XXX -compact 434.It Layer-2 header fields 435When available 436.It IPv4 Protocol 437TCP, UDP, ICMP, etc. 438.It Source and dest. addresses and ports 439.It Direction 440See Section 441.Sx PACKET FLOW 442.It Transmit and receive interface 443By name or address 444.It Misc. IP header fields 445Version, type of service, datagram length, identification, 446fragment flag (non-zero IP offset), 447Time To Live 448.It IP options 449.It Misc. TCP header fields 450TCP flags (SYN, FIN, ACK, RST, etc.), 451sequence number, acknowledgment number, 452window 453.It TCP options 454.It ICMP types 455for ICMP packets 456.It User/group ID 457When the packet can be associated with a local socket. 458.El 459.Pp 460Note that some of the above information, e.g. source MAC or IP addresses and 461TCP/UDP ports, could easily be spoofed, so filtering on those fields 462alone might not guarantee the desired results. 463.Bl -tag -width indent 464.It Ar rule_number 465Each rule is associated with a 466.Ar rule_number 467in the range 1..65535, with the latter reserved for the 468.Em default 469rule. 470Rules are checked sequentially by rule number. 471Multiple rules can have the same number, in which case they are 472checked (and listed) according to the order in which they have 473been added. 474If a rule is entered without specifying a number, the kernel will 475assign one in such a way that the rule becomes the last one 476before the 477.Em default 478rule. 479Automatic rule numbers are assigned by incrementing the last 480non-default rule number by the value of the sysctl variable 481.Ar net.inet.ip.fw.autoinc_step 482which defaults to 100. 483If this is not possible (e.g. because we would go beyond the 484maximum allowed rule number), the number of the last 485non-default value is used instead. 486.It Cm set Ar set_number 487Each rule is associated with a 488.Ar set_number 489in the range 0..31. 490Sets can be individually disabled and enabled, so this parameter 491is of fundamental importance for atomic ruleset manipulation. 492It can be also used to simplify deletion of groups of rules. 493If a rule is entered without specifying a set number, 494set 0 will be used. 495.br 496Set 31 is special in that it cannot be disabled, 497and rules in set 31 are not deleted by the 498.Nm ipfw flush 499command (but you can delete them with the 500.Nm ipfw delete set 31 501command). 502Set 31 is also used for the 503.Em default 504rule. 505.It Cm prob Ar match_probability 506A match is only declared with the specified probability 507(floating point number between 0 and 1). 508This can be useful for a number of applications such as 509random packet drop or 510(in conjunction with 511.Xr dummynet 4 ) 512to simulate the effect of multiple paths leading to out-of-order 513packet delivery. 514.Pp 515Note: this condition is checked before any other condition, including 516ones such as keep-state or check-state which might have side effects. 517.It Cm log Op Cm logamount Ar number 518When a packet matches a rule with the 519.Cm log 520keyword, a message will be 521logged to 522.Xr syslogd 8 523with a 524.Dv LOG_SECURITY 525facility. 526The logging only occurs if the sysctl variable 527.Em net.inet.ip.fw.verbose 528is set to 1 529(which is the default when the kernel is compiled with 530.Dv IPFIREWALL_VERBOSE 531) and the number of packets logged so far for that 532particular rule does not exceed the 533.Cm logamount 534parameter. 535If no 536.Cm logamount 537is specified, the limit is taken from the sysctl variable 538.Em net.inet.ip.fw.verbose_limit . 539In both cases, a value of 0 removes the logging limit. 540.Pp 541Once the limit is reached, logging can be re-enabled by 542clearing the logging counter or the packet counter for that entry, see the 543.Cm resetlog 544command. 545.Pp 546Note: logging is done after all other packet matching conditions 547have been successfully verified, and before performing the final 548action (accept, deny, etc.) on the packet. 549.El 550.Ss RULE ACTIONS 551A rule can be associated with one of the following actions, which 552will be executed when the packet matches the body of the rule. 553.Bl -tag -width indent 554.It Cm allow | accept | pass | permit 555Allow packets that match rule. 556The search terminates. 557.It Cm check-state 558Checks the packet against the dynamic ruleset. 559If a match is found, execute the action associated with 560the rule which generated this dynamic rule, otherwise 561move to the next rule. 562.br 563.Cm Check-state 564rules do not have a body. 565If no 566.Cm check-state 567rule is found, the dynamic ruleset is checked at the first 568.Cm keep-state 569or 570.Cm limit 571rule. 572.It Cm count 573Update counters for all packets that match rule. 574The search continues with the next rule. 575.It Cm deny | drop 576Discard packets that match this rule. 577The search terminates. 578.It Cm divert Ar port 579Divert packets that match this rule to the 580.Xr divert 4 581socket bound to port 582.Ar port . 583The search terminates. 584.It Cm fwd | forward Ar ipaddr Ns Op , Ns Ar port 585Change the next-hop on matching packets to 586.Ar ipaddr , 587which can be an IP address in dotted quad format or a host name. 588The search terminates if this rule matches. 589.Pp 590If 591.Ar ipaddr 592is a local address, then matching packets will be forwarded to 593.Ar port 594(or the port number in the packet if one is not specified in the rule) 595on the local machine. 596.br 597If 598.Ar ipaddr 599is not a local address, then the port number 600(if specified) is ignored, and the packet will be 601forwarded to the remote address, using the route as found in 602the local routing table for that IP. 603.br 604A 605.Ar fwd 606rule will not match layer-2 packets (those received 607on ether_input, ether_output, or bridged). 608.br 609The 610.Cm fwd 611action does not change the contents of the packet at all. 612In particular, the destination address remains unmodified, so 613packets forwarded to another system will usually be rejected by that system 614unless there is a matching rule on that system to capture them. 615For packets forwarded locally, 616the local address of the socket will be 617set to the original destination address of the packet. 618This makes the 619.Xr netstat 1 620entry look rather weird but is intended for 621use with transparent proxy servers. 622.It Cm pipe Ar pipe_nr 623Pass packet to a 624.Xr dummynet 4 625.Dq pipe 626(for bandwidth limitation, delay, etc.). 627See the 628.Sx TRAFFIC SHAPER (DUMMYNET) CONFIGURATION 629Section for further information. 630The search terminates; however, on exit from the pipe and if 631the 632.Xr sysctl 8 633variable 634.Em net.inet.ip.fw.one_pass 635is not set, the packet is passed again to the firewall code 636starting from the next rule. 637.It Cm queue Ar queue_nr 638Pass packet to a 639.Xr dummynet 4 640.Dq queue 641(for bandwidth limitation using WF2Q+). 642.It Cm reject 643(Deprecated). 644Synonym for 645.Cm unreach host . 646.It Cm reset 647Discard packets that match this rule, and if the 648packet is a TCP packet, try to send a TCP reset (RST) notice. 649The search terminates. 650.It Cm skipto Ar number 651Skip all subsequent rules numbered less than 652.Ar number . 653The search continues with the first rule numbered 654.Ar number 655or higher. 656.It Cm tee Ar port 657Send a copy of packets matching this rule to the 658.Xr divert 4 659socket bound to port 660.Ar port . 661The search terminates and the original packet is accepted 662(but see Section 663.Sx BUGS 664below). 665.It Cm unreach Ar code 666Discard packets that match this rule, and try to send an ICMP 667unreachable notice with code 668.Ar code , 669where 670.Ar code 671is a number from 0 to 255, or one of these aliases: 672.Cm net , host , protocol , port , 673.Cm needfrag , srcfail , net-unknown , host-unknown , 674.Cm isolated , net-prohib , host-prohib , tosnet , 675.Cm toshost , filter-prohib , host-precedence 676or 677.Cm precedence-cutoff . 678The search terminates. 679.El 680.Ss RULE BODY 681The body of a rule contains zero or more patterns (such as 682specific source and destination addresses or ports, 683protocol options, incoming or outgoing interfaces, etc.) 684that the packet must match in order to be recognised. 685In general, the patterns are connected by (implicit) 686.Cm and 687operators -- i.e. all must match in order for the 688rule to match. 689Individual patterns can be prefixed by the 690.Cm not 691operator to reverse the result of the match, as in 692.Pp 693.Dl "ipfw add 100 allow ip from not 1.2.3.4 to any" 694.Pp 695Additionally, sets of alternative match patterns ( 696.Em or-blocks 697) can be constructed by putting the patterns in 698lists enclosed between parentheses ( ) or braces { }, and 699using the 700.Cm or 701operator as follows: 702.Pp 703.Dl "ipfw add 100 allow ip from { x or not y or z } to any" 704.Pp 705Only one level of parentheses is allowed. 706Beware that most shells have special meanings for parentheses 707or braces, so it is advisable to put a backslash \\ in front of them 708to prevent such interpretations. 709.Pp 710The body of a rule must in general include a source and destination 711address specifier. 712The keyword 713.Ar any 714can be used in various places to specify that the content of 715a required field is irrelevant. 716.Pp 717The rule body has the following format: 718.Bd -ragged -offset indent 719.Op Ar proto Cm from Ar src Cm to Ar dst 720.Op Ar options 721.Ed 722.Pp 723The first part (proto from src to dst) is for backward 724compatibility with 725.Nm ipfw1 . 726In 727.Nm ipfw2 728any match pattern (including MAC headers, IPv4 protocols, 729addresses and ports) can be specified in the 730.Ar options 731section. 732.Pp 733Rule fields have the following meaning: 734.Bl -tag -width indent 735.It Ar proto : protocol | Cm { Ar protocol Cm or ... } 736.It Ar protocol : Oo Cm not Oc Ar protocol-name | protocol-number 737An IPv4 protocol specified by number or name 738(for a complete list see 739.Pa /etc/protocols ) . 740The 741.Cm ip 742or 743.Cm all 744keywords mean any protocol will match. 745.Pp 746The 747.Cm { Ar protocol Cm or ... } 748format (an 749.Em or-block ) 750is provided for convenience only but its use is deprecated. 751.It Ar src No and Ar dst : Bro Cm addr | Cm { Ar addr Cm or ... } Brc Op Oo Cm not Oc Ar ports 752An address (or a list, see below) 753optionally followed by 754.Ar ports 755specifiers. 756.Pp 757The second format ( 758.Em or-block 759with multiple addresses) is provided for convenience only and 760its use is discouraged. 761.It Ar addr : Oo Cm not Oc Brq Cm any | me | Ar addr-list | Ar addr-set 762.It Cm any 763matches any IP address. 764.It Cm me 765matches any IP address configured on an interface in the system. 766The address list is evaluated at the time the packet is 767analysed. 768.It Ar addr-list : ip-addr Ns Op Ns , Ns Ar addr-list 769.It Ar ip-addr : 770A host or subnet address specified in one of the following ways: 771.Bl -tag -width indent 772.It Ar numeric-ip | hostname 773Matches a single IPv4 address, specified as dotted-quad or a hostname. 774Hostnames are resolved at the time the rule is added to the firewall list. 775.It Ar addr Ns / Ns Ar masklen 776Matches all addresses with base 777.Ar addr 778(specified as a dotted quad or a hostname) 779and mask width of 780.Cm masklen 781bits. 782As an example, 1.2.3.4/25 will match 783all IP numbers from 1.2.3.0 to 1.2.3.127 . 784.It Ar addr Ns : Ns Ar mask 785Matches all addresses with base 786.Ar addr 787(specified as a dotted quad or a hostname) 788and the mask of 789.Ar mask , 790specified as a dotted quad. 791As an example, 1.2.3.4:255.0.255.0 will match 7921.*.3.*. 793This form is advised only for non-contiguous 794masks. It is better to resort to the 795.Ar addr Ns / Ns Ar masklen 796format for contiguous masks, which is more compact and less 797error-prone. 798.El 799.It Ar addr-set : addr Ns Oo Ns / Ns Ar masklen Oc Ns Cm { Ns Ar list Ns Cm } 800.It Ar list : Bro Ar num | num-num Brc Ns Op Ns , Ns Ar list 801Matches all addresses with base address 802.Ar addr 803(specified as a dotted quad or a hostname) 804and whose last byte is in the list between braces { } . 805Note that there must be no spaces between braces and 806numbers (spaces after commas are allowed). 807Elements of the list can be specified as single entries 808or ranges. 809The 810.Ar masklen 811field is used to limit the size of the set of addresses, 812and can have any value between 24 and 32. If not specified, 813it will be assumed as 24. 814.br 815This format is particularly useful to handle sparse address sets 816within a single rule. Because the matching occurs using a 817bitmask, it takes constant time and dramatically reduces 818the complexity of rulesets. 819.br 820As an example, an address specified as 1.2.3.4/24{128,35-55,89} 821will match the following IP addresses: 822.br 8231.2.3.128, 1.2.3.35 to 1.2.3.55, 1.2.3.89 . 824.It Ar ports : Bro Ar port | port Ns \&- Ns Ar port Ns Brc Ns Op , Ns Ar ports 825For protocols which support port numbers (such as TCP and UDP), optional 826.Cm ports 827may be specified as one or more ports or port ranges, separated 828by commas but no spaces, and an optional 829.Cm not 830operator. 831The 832.Ql \&- 833notation specifies a range of ports (including boundaries). 834.Pp 835Service names (from 836.Pa /etc/services ) 837may be used instead of numeric port values. 838The length of the port list is limited to 30 ports or ranges, 839though one can specify larger ranges by using an 840.Em or-block 841in the 842.Cm options 843section of the rule. 844.Pp 845A backslash 846.Pq Ql \e 847can be used to escape the dash 848.Pq Ql - 849character in a service name (from a shell, the backslash must be 850typed twice to avoid the shell itself interpreting it as an escape 851character). 852.Pp 853.Dl "ipfw add count tcp from any ftp\e\e-data-ftp to any" 854.Pp 855Fragmented packets which have a non-zero offset (i.e. not the first 856fragment) will never match a rule which has one or more port 857specifications. 858See the 859.Cm frag 860option for details on matching fragmented packets. 861.El 862.Ss RULE OPTIONS (MATCH PATTERNS) 863Additional match patterns can be used within 864rules. Zero or more of these so-called 865.Em options 866can be present in a rule, optionally prefixed by the 867.Cm not 868operand, and possibly grouped into 869.Em or-blocks . 870.Pp 871The following match patterns can be used (listed in alphabetical order): 872.Bl -tag -width indent 873.It Cm // this is a comment. 874Inserts the specified text as a comment in the rule. 875Everything following // is considered as a comment and stored in the rule. 876You can have comment-only rules, which are listed as having a 877.Cm count 878action followed by the comment. 879.It Cm bridged 880Matches only bridged packets. 881.It Cm dst-ip Ar ip-address 882Matches IP packets whose destination IP is one of the address(es) 883specified as argument. 884.It Cm dst-port Ar ports 885Matches IP packets whose destination port is one of the port(s) 886specified as argument. 887.It Cm established 888Matches TCP packets that have the RST or ACK bits set. 889.It Cm frag 890Matches packets that are fragments and not the first 891fragment of an IP datagram. Note that these packets will not have 892the next protocol header (e.g. TCP, UDP) so options that look into 893these headers cannot match. 894.It Cm gid Ar group 895Matches all TCP or UDP packets sent by or received for a 896.Ar group . 897A 898.Ar group 899may be specified by name or number. 900.It Cm icmptypes Ar types 901Matches ICMP packets whose ICMP type is in the list 902.Ar types . 903The list may be specified as any combination of 904individual types (numeric) separated by commas. 905.Em Ranges are not allowed. 906The supported ICMP types are: 907.Pp 908echo reply 909.Pq Cm 0 , 910destination unreachable 911.Pq Cm 3 , 912source quench 913.Pq Cm 4 , 914redirect 915.Pq Cm 5 , 916echo request 917.Pq Cm 8 , 918router advertisement 919.Pq Cm 9 , 920router solicitation 921.Pq Cm 10 , 922time-to-live exceeded 923.Pq Cm 11 , 924IP header bad 925.Pq Cm 12 , 926timestamp request 927.Pq Cm 13 , 928timestamp reply 929.Pq Cm 14 , 930information request 931.Pq Cm 15 , 932information reply 933.Pq Cm 16 , 934address mask request 935.Pq Cm 17 936and address mask reply 937.Pq Cm 18 . 938.It Cm in | out 939Matches incoming or outgoing packets, respectively. 940.Cm in 941and 942.Cm out 943are mutually exclusive (in fact, 944.Cm out 945is implemented as 946.Cm not in Ns No ). 947.It Cm ipid Ar id-list 948Matches IP packets whose 949.Cm ip_id 950field has value included in 951.Ar id-list , 952which is either a single value or a list of values or ranges 953specified in the same way as 954.Ar ports . 955.It Cm iplen Ar len-list 956Matches IP packets whose total length, including header and data, is 957in the set 958.Ar len-list , 959which is either a single value or a list of values or ranges 960specified in the same way as 961.Ar ports . 962.It Cm ipoptions Ar spec 963Matches packets whose IP header contains the comma separated list of 964options specified in 965.Ar spec . 966The supported IP options are: 967.Pp 968.Cm ssrr 969(strict source route), 970.Cm lsrr 971(loose source route), 972.Cm rr 973(record packet route) and 974.Cm ts 975(timestamp). 976The absence of a particular option may be denoted 977with a 978.Ql \&! . 979.It Cm ipprecedence Ar precedence 980Matches IP packets whose precedence field is equal to 981.Ar precedence . 982.It Cm ipsec 983Matches packets that have IPSEC history associated with them 984(i.e. the packet comes encapsulated in IPSEC, the kernel 985has IPSEC support and IPSEC_FILTERGIF option, and can correctly 986decapsulate it). 987.Pp 988Note that specifying 989.Cm ipsec 990is different from specifying 991.Cm proto Ar ipsec 992as the latter will only look at the specific IP protocol field, 993irrespective of IPSEC kernel support and the validity of the IPSEC data. 994.Pp 995Further note that this flag is silently ignored in kernels without 996IPSEC support. 997It does not affect rule processing when given and the 998rules are handled as if with no 999.Cm ipsec 1000flag. 1001.It Cm iptos Ar spec 1002Matches IP packets whose 1003.Cm tos 1004field contains the comma separated list of 1005service types specified in 1006.Ar spec . 1007The supported IP types of service are: 1008.Pp 1009.Cm lowdelay 1010.Pq Dv IPTOS_LOWDELAY , 1011.Cm throughput 1012.Pq Dv IPTOS_THROUGHPUT , 1013.Cm reliability 1014.Pq Dv IPTOS_RELIABILITY , 1015.Cm mincost 1016.Pq Dv IPTOS_MINCOST , 1017.Cm congestion 1018.Pq Dv IPTOS_CE . 1019The absence of a particular type may be denoted 1020with a 1021.Ql \&! . 1022.It Cm ipttl Ar ttl-list 1023Matches IP packets whose time to live is included in 1024.Ar ttl-list , 1025which is either a single value or a list of values or ranges 1026specified in the same way as 1027.Ar ports . 1028.It Cm ipversion Ar ver 1029Matches IP packets whose IP version field is 1030.Ar ver . 1031.It Cm keep-state 1032Upon a match, the firewall will create a dynamic rule, whose 1033default behaviour is to match bidirectional traffic between 1034source and destination IP/port using the same protocol. 1035The rule has a limited lifetime (controlled by a set of 1036.Xr sysctl 8 1037variables), and the lifetime is refreshed every time a matching 1038packet is found. 1039.It Cm layer2 1040Matches only layer2 packets, i.e. those passed to 1041.Nm 1042from ether_demux() and ether_output_frame(). 1043.It Cm limit Bro Cm src-addr | src-port | dst-addr | dst-port Brc Ar N 1044The firewall will only allow 1045.Ar N 1046connections with the same 1047set of parameters as specified in the rule. 1048One or more 1049of source and destination addresses and ports can be 1050specified. 1051.It Cm { MAC | mac } Ar dst-mac src-mac 1052Match packets with a given 1053.Ar dst-mac 1054and 1055.Ar src-mac 1056addresses, specified as the 1057.Cm any 1058keyword (matching any MAC address), or six groups of hex digits 1059separated by colons, 1060and optionally followed by a mask indicating the significant bits. 1061The mask may be specified using either of the following methods: 1062.Bl -enum -width indent 1063.It 1064A slash 1065.Pq / 1066followed by the number of significant bits. 1067For example, an address with 33 significant bits could be specified as: 1068.Pp 1069.Dl "MAC 10:20:30:40:50:60/33 any" 1070.Pp 1071.It 1072An ampersand 1073.Pq & 1074followed by a bitmask specified as six groups of hex digits separated 1075by colons. 1076For example, an address in which the last 16 bits are significant could 1077be specified as: 1078.Pp 1079.Dl "MAC 10:20:30:40:50:60&00:00:00:00:ff:ff any" 1080.Pp 1081Note that the ampersand character has a special meaning in many shells 1082and should generally be escaped. 1083.Pp 1084.El 1085Note that the order of MAC addresses (destination first, 1086source second) is 1087the same as on the wire, but the opposite of the one used for 1088IP addresses. 1089.It Cm mac-type Ar mac-type 1090Matches packets whose Ethernet Type field 1091corresponds to one of those specified as argument. 1092.Ar mac-type 1093is specified in the same way as 1094.Cm port numbers 1095(i.e. one or more comma-separated single values or ranges). 1096You can use symbolic names for known values such as 1097.Em vlan , ipv4, ipv6 . 1098Values can be entered as decimal or hexadecimal (if prefixed by 0x), 1099and they are always printed as hexadecimal (unless the 1100.Cm -N 1101option is used, in which case symbolic resolution will be attempted). 1102.It Cm proto Ar protocol 1103Matches packets with the corresponding IPv4 protocol. 1104.It Cm recv | xmit | via Brq Ar ifX | Ar if Ns Cm * | Ar ipno | Ar any 1105Matches packets received, transmitted or going through, 1106respectively, the interface specified by exact name 1107.Ns No ( Ar ifX Ns No ), 1108by device name 1109.Ns No ( Ar if Ns Ar * Ns No ), 1110by IP address, or through some interface. 1111.Pp 1112The 1113.Cm via 1114keyword causes the interface to always be checked. 1115If 1116.Cm recv 1117or 1118.Cm xmit 1119is used instead of 1120.Cm via , 1121then only the receive or transmit interface (respectively) 1122is checked. 1123By specifying both, it is possible to match packets based on 1124both receive and transmit interface, e.g.: 1125.Pp 1126.Dl "ipfw add deny ip from any to any out recv ed0 xmit ed1" 1127.Pp 1128The 1129.Cm recv 1130interface can be tested on either incoming or outgoing packets, 1131while the 1132.Cm xmit 1133interface can only be tested on outgoing packets. 1134So 1135.Cm out 1136is required (and 1137.Cm in 1138is invalid) whenever 1139.Cm xmit 1140is used. 1141.Pp 1142A packet may not have a receive or transmit interface: packets 1143originating from the local host have no receive interface, 1144while packets destined for the local host have no transmit 1145interface. 1146.It Cm setup 1147Matches TCP packets that have the SYN bit set but no ACK bit. 1148This is the short form of 1149.Dq Li tcpflags\ syn,!ack . 1150.It Cm src-ip Ar ip-address 1151Matches IP packets whose source IP is one of the address(es) 1152specified as argument. 1153.It Cm src-port Ar ports 1154Matches IP packets whose source port is one of the port(s) 1155specified as argument. 1156.It Cm tcpack Ar ack 1157TCP packets only. 1158Match if the TCP header acknowledgment number field is set to 1159.Ar ack . 1160.It Cm tcpflags Ar spec 1161TCP packets only. 1162Match if the TCP header contains the comma separated list of 1163flags specified in 1164.Ar spec . 1165The supported TCP flags are: 1166.Pp 1167.Cm fin , 1168.Cm syn , 1169.Cm rst , 1170.Cm psh , 1171.Cm ack 1172and 1173.Cm urg . 1174The absence of a particular flag may be denoted 1175with a 1176.Ql \&! . 1177A rule which contains a 1178.Cm tcpflags 1179specification can never match a fragmented packet which has 1180a non-zero offset. 1181See the 1182.Cm frag 1183option for details on matching fragmented packets. 1184.It Cm tcpseq Ar seq 1185TCP packets only. 1186Match if the TCP header sequence number field is set to 1187.Ar seq . 1188.It Cm tcpwin Ar win 1189TCP packets only. 1190Match if the TCP header window field is set to 1191.Ar win . 1192.It Cm tcpoptions Ar spec 1193TCP packets only. 1194Match if the TCP header contains the comma separated list of 1195options specified in 1196.Ar spec . 1197The supported TCP options are: 1198.Pp 1199.Cm mss 1200(maximum segment size), 1201.Cm window 1202(tcp window advertisement), 1203.Cm sack 1204(selective ack), 1205.Cm ts 1206(rfc1323 timestamp) and 1207.Cm cc 1208(rfc1644 t/tcp connection count). 1209The absence of a particular option may be denoted 1210with a 1211.Ql \&! . 1212.It Cm uid Ar user 1213Match all TCP or UDP packets sent by or received for a 1214.Ar user . 1215A 1216.Ar user 1217may be matched by name or identification number. 1218.It Cm verrevpath 1219For incoming packets, 1220a routing table lookup is done on the packet's source address. 1221If the interface on which the packet entered the system matches the 1222outgoing interface for the route, 1223the packet matches. 1224If the interfaces do not match up, 1225the packet does not match. 1226All outgoing packets or packets with no incoming interface match. 1227.Pp 1228The name and functionality of the option is intentionally similar to 1229the Cisco IOS command: 1230.Pp 1231.Dl ip verify unicast reverse-path 1232.Pp 1233This option can be used to make anti-spoofing rules to reject all 1234packets with source addresses not from this interface. 1235.It Cm versrcreach 1236For incoming packets, 1237a routing table lookup is done on the packet's source address. 1238If a route to the source address exists, but not the default route, 1239the packet matches. 1240Otherwise the packet does not match. 1241All outgoing packets match. 1242.Pp 1243The name and functionality of the option is intentionally similar to 1244the Cisco IOS command: 1245.Pp 1246.Dl ip verify unicast source reachable-via any 1247.Pp 1248This option can be used to make anti-spoofing rules to reject all 1249packets whose source address is unreachable. 1250.El 1251.Sh SETS OF RULES 1252Each rule belongs to one of 32 different 1253.Em sets 1254, numbered 0 to 31. 1255Set 31 is reserved for the default rule. 1256.Pp 1257By default, rules are put in set 0, unless you use the 1258.Cm set N 1259attribute when entering a new rule. 1260Sets can be individually and atomically enabled or disabled, 1261so this mechanism permits an easy way to store multiple configurations 1262of the firewall and quickly (and atomically) switch between them. 1263The command to enable/disable sets is 1264.Bd -ragged -offset indent 1265.Nm 1266.Cm set Oo Cm disable Ar number ... Oc Op Cm enable Ar number ... 1267.Ed 1268.Pp 1269where multiple 1270.Cm enable 1271or 1272.Cm disable 1273sections can be specified. 1274Command execution is atomic on all the sets specified in the command. 1275By default, all sets are enabled. 1276.Pp 1277When you disable a set, its rules behave as if they do not exist 1278in the firewall configuration, with only one exception: 1279.Bd -ragged -offset indent 1280dynamic rules created from a rule before it had been disabled 1281will still be active until they expire. In order to delete 1282dynamic rules you have to explicitly delete the parent rule 1283which generated them. 1284.Ed 1285.Pp 1286The set number of rules can be changed with the command 1287.Bd -ragged -offset indent 1288.Nm 1289.Cm set move 1290.Brq Cm rule Ar rule-number | old-set 1291.Cm to Ar new-set 1292.Ed 1293.Pp 1294Also, you can atomically swap two rulesets with the command 1295.Bd -ragged -offset indent 1296.Nm 1297.Cm set swap Ar first-set second-set 1298.Ed 1299.Pp 1300See the 1301.Sx EXAMPLES 1302Section on some possible uses of sets of rules. 1303.Sh STATEFUL FIREWALL 1304Stateful operation is a way for the firewall to dynamically 1305create rules for specific flows when packets that 1306match a given pattern are detected. Support for stateful 1307operation comes through the 1308.Cm check-state , keep-state 1309and 1310.Cm limit 1311options of 1312.Nm rules. 1313.Pp 1314Dynamic rules are created when a packet matches a 1315.Cm keep-state 1316or 1317.Cm limit 1318rule, causing the creation of a 1319.Em dynamic 1320rule which will match all and only packets with 1321a given 1322.Em protocol 1323between a 1324.Em src-ip/src-port dst-ip/dst-port 1325pair of addresses ( 1326.Em src 1327and 1328.Em dst 1329are used here only to denote the initial match addresses, but they 1330are completely equivalent afterwards). 1331Dynamic rules will be checked at the first 1332.Cm check-state, keep-state 1333or 1334.Cm limit 1335occurrence, and the action performed upon a match will be the same 1336as in the parent rule. 1337.Pp 1338Note that no additional attributes other than protocol and IP addresses 1339and ports are checked on dynamic rules. 1340.Pp 1341The typical use of dynamic rules is to keep a closed firewall configuration, 1342but let the first TCP SYN packet from the inside network install a 1343dynamic rule for the flow so that packets belonging to that session 1344will be allowed through the firewall: 1345.Pp 1346.Dl "ipfw add check-state" 1347.Dl "ipfw add allow tcp from my-subnet to any setup keep-state" 1348.Dl "ipfw add deny tcp from any to any" 1349.Pp 1350A similar approach can be used for UDP, where an UDP packet coming 1351from the inside will install a dynamic rule to let the response through 1352the firewall: 1353.Pp 1354.Dl "ipfw add check-state" 1355.Dl "ipfw add allow udp from my-subnet to any keep-state" 1356.Dl "ipfw add deny udp from any to any" 1357.Pp 1358Dynamic rules expire after some time, which depends on the status 1359of the flow and the setting of some 1360.Cm sysctl 1361variables. 1362See Section 1363.Sx SYSCTL VARIABLES 1364for more details. 1365For TCP sessions, dynamic rules can be instructed to periodically 1366send keepalive packets to refresh the state of the rule when it is 1367about to expire. 1368.Pp 1369See Section 1370.Sx EXAMPLES 1371for more examples on how to use dynamic rules. 1372.Sh TRAFFIC SHAPER (DUMMYNET) CONFIGURATION 1373.Nm 1374is also the user interface for the 1375.Xr dummynet 4 1376traffic shaper. 1377.Pp 1378.Nm dummynet 1379operates by first using the firewall to classify packets and divide them into 1380.Em flows , 1381using any match pattern that can be used in 1382.Nm 1383rules. 1384Depending on local policies, a flow can contain packets for a single 1385TCP connection, or from/to a given host, or entire subnet, or a 1386protocol type, etc. 1387.Pp 1388Packets belonging to the same flow are then passed to either of two 1389different objects, which implement the traffic regulation: 1390.Bl -hang -offset XXXX 1391.It Em pipe 1392A pipe emulates a link with given bandwidth, propagation delay, 1393queue size and packet loss rate. 1394Packets are queued in front of the pipe as they come out from the classifier, 1395and then transferred to the pipe according to the pipe's parameters. 1396.Pp 1397.It Em queue 1398A queue 1399is an abstraction used to implement the WF2Q+ 1400(Worst-case Fair Weighted Fair Queueing) policy, which is 1401an efficient variant of the WFQ policy. 1402.br 1403The queue associates a 1404.Em weight 1405and a reference pipe to each flow, and then all backlogged (i.e., 1406with packets queued) flows linked to the same pipe share the pipe's 1407bandwidth proportionally to their weights. 1408Note that weights are not priorities; a flow with a lower weight 1409is still guaranteed to get its fraction of the bandwidth even if a 1410flow with a higher weight is permanently backlogged. 1411.Pp 1412.El 1413In practice, 1414.Em pipes 1415can be used to set hard limits to the bandwidth that a flow can use, whereas 1416.Em queues 1417can be used to determine how different flow share the available bandwidth. 1418.Pp 1419The 1420.Em pipe 1421and 1422.Em queue 1423configuration commands are the following: 1424.Bd -ragged -offset indent 1425.Cm pipe Ar number Cm config Ar pipe-configuration 1426.Pp 1427.Cm queue Ar number Cm config Ar queue-configuration 1428.Ed 1429.Pp 1430The following parameters can be configured for a pipe: 1431.Pp 1432.Bl -tag -width indent -compact 1433.It Cm bw Ar bandwidth | device 1434Bandwidth, measured in 1435.Sm off 1436.Op Cm K | M 1437.Brq Cm bit/s | Byte/s . 1438.Sm on 1439.Pp 1440A value of 0 (default) means unlimited bandwidth. 1441The unit must immediately follow the number, as in 1442.Pp 1443.Dl "ipfw pipe 1 config bw 300Kbit/s" 1444.Pp 1445If a device name is specified instead of a numeric value, as in 1446.Pp 1447.Dl "ipfw pipe 1 config bw tun0" 1448.Pp 1449then the transmit clock is supplied by the specified device. 1450At the moment only the 1451.Xr tun 4 1452device supports this 1453functionality, for use in conjunction with 1454.Xr ppp 8 . 1455.Pp 1456.It Cm delay Ar ms-delay 1457Propagation delay, measured in milliseconds. 1458The value is rounded to the next multiple of the clock tick 1459(typically 10ms, but it is a good practice to run kernels 1460with 1461.Dq "options HZ=1000" 1462to reduce 1463the granularity to 1ms or less). 1464Default value is 0, meaning no delay. 1465.El 1466.Pp 1467The following parameters can be configured for a queue: 1468.Pp 1469.Bl -tag -width indent -compact 1470.It Cm pipe Ar pipe_nr 1471Connects a queue to the specified pipe. 1472Multiple queues (with the same or different weights) can be connected to 1473the same pipe, which specifies the aggregate rate for the set of queues. 1474.Pp 1475.It Cm weight Ar weight 1476Specifies the weight to be used for flows matching this queue. 1477The weight must be in the range 1..100, and defaults to 1. 1478.El 1479.Pp 1480Finally, the following parameters can be configured for both 1481pipes and queues: 1482.Pp 1483.Bl -tag -width XXXX -compact 1484.Pp 1485.It Cm buckets Ar hash-table-size 1486Specifies the size of the hash table used for storing the 1487various queues. 1488Default value is 64 controlled by the 1489.Xr sysctl 8 1490variable 1491.Em net.inet.ip.dummynet.hash_size , 1492allowed range is 16 to 65536. 1493.Pp 1494.It Cm mask Ar mask-specifier 1495Packets sent to a given pipe or queue by an 1496.Nm 1497rule can be further classified into multiple flows, each of which is then 1498sent to a different 1499.Em dynamic 1500pipe or queue. 1501A flow identifier is constructed by masking the IP addresses, 1502ports and protocol types as specified with the 1503.Cm mask 1504options in the configuration of the pipe or queue. 1505For each different flow identifier, a new pipe or queue is created 1506with the same parameters as the original object, and matching packets 1507are sent to it. 1508.Pp 1509Thus, when 1510.Em dynamic pipes 1511are used, each flow will get the same bandwidth as defined by the pipe, 1512whereas when 1513.Em dynamic queues 1514are used, each flow will share the parent's pipe bandwidth evenly 1515with other flows generated by the same queue (note that other queues 1516with different weights might be connected to the same pipe). 1517.br 1518Available mask specifiers are a combination of one or more of the following: 1519.Pp 1520.Cm dst-ip Ar mask , 1521.Cm src-ip Ar mask , 1522.Cm dst-port Ar mask , 1523.Cm src-port Ar mask , 1524.Cm proto Ar mask 1525or 1526.Cm all , 1527.Pp 1528where the latter means all bits in all fields are significant. 1529.Pp 1530.It Cm noerror 1531When a packet is dropped by a dummynet queue or pipe, the error 1532is normally reported to the caller routine in the kernel, in the 1533same way as it happens when a device queue fills up. Setting this 1534option reports the packet as successfully delivered, which can be 1535needed for some experimental setups where you want to simulate 1536loss or congestion at a remote router. 1537.Pp 1538.It Cm plr Ar packet-loss-rate 1539Packet loss rate. 1540Argument 1541.Ar packet-loss-rate 1542is a floating-point number between 0 and 1, with 0 meaning no 1543loss, 1 meaning 100% loss. 1544The loss rate is internally represented on 31 bits. 1545.Pp 1546.It Cm queue Brq Ar slots | size Ns Cm Kbytes 1547Queue size, in 1548.Ar slots 1549or 1550.Cm KBytes . 1551Default value is 50 slots, which 1552is the typical queue size for Ethernet devices. 1553Note that for slow speed links you should keep the queue 1554size short or your traffic might be affected by a significant 1555queueing delay. 1556E.g., 50 max-sized ethernet packets (1500 bytes) mean 600Kbit 1557or 20s of queue on a 30Kbit/s pipe. 1558Even worse effects can result if you get packets from an 1559interface with a much larger MTU, e.g. the loopback interface 1560with its 16KB packets. 1561.Pp 1562.It Cm red | gred Ar w_q Ns / Ns Ar min_th Ns / Ns Ar max_th Ns / Ns Ar max_p 1563Make use of the RED (Random Early Detection) queue management algorithm. 1564.Ar w_q 1565and 1566.Ar max_p 1567are floating 1568point numbers between 0 and 1 (0 not included), while 1569.Ar min_th 1570and 1571.Ar max_th 1572are integer numbers specifying thresholds for queue management 1573(thresholds are computed in bytes if the queue has been defined 1574in bytes, in slots otherwise). 1575The 1576.Xr dummynet 4 1577also supports the gentle RED variant (gred). 1578Three 1579.Xr sysctl 8 1580variables can be used to control the RED behaviour: 1581.Bl -tag -width indent 1582.It Em net.inet.ip.dummynet.red_lookup_depth 1583specifies the accuracy in computing the average queue 1584when the link is idle (defaults to 256, must be greater than zero) 1585.It Em net.inet.ip.dummynet.red_avg_pkt_size 1586specifies the expected average packet size (defaults to 512, must be 1587greater than zero) 1588.It Em net.inet.ip.dummynet.red_max_pkt_size 1589specifies the expected maximum packet size, only used when queue 1590thresholds are in bytes (defaults to 1500, must be greater than zero). 1591.El 1592.El 1593.Sh CHECKLIST 1594Here are some important points to consider when designing your 1595rules: 1596.Bl -bullet 1597.It 1598Remember that you filter both packets going 1599.Cm in 1600and 1601.Cm out . 1602Most connections need packets going in both directions. 1603.It 1604Remember to test very carefully. 1605It is a good idea to be near the console when doing this. 1606If you cannot be near the console, 1607use an auto-recovery script such as the one in 1608.Pa /usr/share/examples/ipfw/change_rules.sh . 1609.It 1610Don't forget the loopback interface. 1611.El 1612.Sh FINE POINTS 1613.Bl -bullet 1614.It 1615There are circumstances where fragmented datagrams are unconditionally 1616dropped. 1617TCP packets are dropped if they do not contain at least 20 bytes of 1618TCP header, UDP packets are dropped if they do not contain a full 8 1619byte UDP header, and ICMP packets are dropped if they do not contain 16204 bytes of ICMP header, enough to specify the ICMP type, code, and 1621checksum. 1622These packets are simply logged as 1623.Dq pullup failed 1624since there may not be enough good data in the packet to produce a 1625meaningful log entry. 1626.It 1627Another type of packet is unconditionally dropped, a TCP packet with a 1628fragment offset of one. 1629This is a valid packet, but it only has one use, to try 1630to circumvent firewalls. 1631When logging is enabled, these packets are 1632reported as being dropped by rule -1. 1633.It 1634If you are logged in over a network, loading the 1635.Xr kld 4 1636version of 1637.Nm 1638is probably not as straightforward as you would think. 1639I recommend the following command line: 1640.Bd -literal -offset indent 1641kldload ipfw && \e 1642ipfw add 32000 allow ip from any to any 1643.Ed 1644.Pp 1645Along the same lines, doing an 1646.Bd -literal -offset indent 1647ipfw flush 1648.Ed 1649.Pp 1650in similar surroundings is also a bad idea. 1651.It 1652The 1653.Nm 1654filter list may not be modified if the system security level 1655is set to 3 or higher 1656(see 1657.Xr init 8 1658for information on system security levels). 1659.El 1660.Sh PACKET DIVERSION 1661A 1662.Xr divert 4 1663socket bound to the specified port will receive all packets 1664diverted to that port. 1665If no socket is bound to the destination port, or if the kernel 1666wasn't compiled with divert socket support, the packets are 1667dropped. 1668.Sh SYSCTL VARIABLES 1669A set of 1670.Xr sysctl 8 1671variables controls the behaviour of the firewall and 1672associated modules ( 1673.Nm dummynet, bridge 1674). 1675These are shown below together with their default value 1676(but always check with the 1677.Xr sysctl 8 1678command what value is actually in use) and meaning: 1679.Bl -tag -width indent 1680.It Em net.inet.ip.dummynet.expire : No 1 1681Lazily delete dynamic pipes/queue once they have no pending traffic. 1682You can disable this by setting the variable to 0, in which case 1683the pipes/queues will only be deleted when the threshold is reached. 1684.It Em net.inet.ip.dummynet.hash_size : No 64 1685Default size of the hash table used for dynamic pipes/queues. 1686This value is used when no 1687.Cm buckets 1688option is specified when configuring a pipe/queue. 1689.It Em net.inet.ip.dummynet.max_chain_len : No 16 1690Target value for the maximum number of pipes/queues in a hash bucket. 1691The product 1692.Cm max_chain_len*hash_size 1693is used to determine the threshold over which empty pipes/queues 1694will be expired even when 1695.Cm net.inet.ip.dummynet.expire=0 . 1696.It Em net.inet.ip.dummynet.red_lookup_depth : No 256 1697.It Em net.inet.ip.dummynet.red_avg_pkt_size : No 512 1698.It Em net.inet.ip.dummynet.red_max_pkt_size : No 1500 1699Parameters used in the computations of the drop probability 1700for the RED algorithm. 1701.It Em net.inet.ip.fw.autoinc_step : No 100 1702Delta between rule numbers when auto-generating them. 1703The value must be in the range 1..1000. 1704This variable is only present in 1705.Nm ipfw2 , 1706the delta is hardwired to 100 in 1707.Nm ipfw1 . 1708.It Em net.inet.ip.fw.curr_dyn_buckets : Em net.inet.ip.fw.dyn_buckets 1709The current number of buckets in the hash table for dynamic rules 1710(readonly). 1711.It Em net.inet.ip.fw.debug : No 1 1712Controls debugging messages produced by 1713.Nm . 1714.It Em net.inet.ip.fw.dyn_buckets : No 256 1715The number of buckets in the hash table for dynamic rules. 1716Must be a power of 2, up to 65536. 1717It only takes effect when all dynamic rules have expired, so you 1718are advised to use a 1719.Cm flush 1720command to make sure that the hash table is resized. 1721.It Em net.inet.ip.fw.dyn_count : No 3 1722Current number of dynamic rules 1723(read-only). 1724.It Em net.inet.ip.fw.dyn_keepalive : No 1 1725Enables generation of keepalive packets for 1726.Cm keep-state 1727rules on TCP sessions. A keepalive is generated to both 1728sides of the connection every 5 seconds for the last 20 1729seconds of the lifetime of the rule. 1730.It Em net.inet.ip.fw.dyn_max : No 8192 1731Maximum number of dynamic rules. 1732When you hit this limit, no more dynamic rules can be 1733installed until old ones expire. 1734.It Em net.inet.ip.fw.dyn_ack_lifetime : No 300 1735.It Em net.inet.ip.fw.dyn_syn_lifetime : No 20 1736.It Em net.inet.ip.fw.dyn_fin_lifetime : No 1 1737.It Em net.inet.ip.fw.dyn_rst_lifetime : No 1 1738.It Em net.inet.ip.fw.dyn_udp_lifetime : No 5 1739.It Em net.inet.ip.fw.dyn_short_lifetime : No 30 1740These variables control the lifetime, in seconds, of dynamic 1741rules. 1742Upon the initial SYN exchange the lifetime is kept short, 1743then increased after both SYN have been seen, then decreased 1744again during the final FIN exchange or when a RST is received. 1745Both 1746.Em dyn_fin_lifetime 1747and 1748.Em dyn_rst_lifetime 1749must be strictly lower than 5 seconds, the period of 1750repetition of keepalives. The firewall enforces that. 1751.It Em net.inet.ip.fw.enable : No 1 1752Enables the firewall. 1753Setting this variable to 0 lets you run your machine without 1754firewall even if compiled in. 1755.It Em net.inet.ip.fw.one_pass : No 1 1756When set, the packet exiting from the 1757.Xr dummynet 4 1758pipe is not passed though the firewall again. 1759Otherwise, after a pipe action, the packet is 1760reinjected into the firewall at the next rule. 1761.It Em net.inet.ip.fw.verbose : No 1 1762Enables verbose messages. 1763.It Em net.inet.ip.fw.verbose_limit : No 0 1764Limits the number of messages produced by a verbose firewall. 1765.It Em net.link.ether.ipfw : No 0 1766Controls whether layer-2 packets are passed to 1767.Nm . 1768Default is no. 1769.It Em net.link.ether.bridge_ipfw : No 0 1770Controls whether bridged packets are passed to 1771.Nm . 1772Default is no. 1773.El 1774.Sh USING IPFW2 IN FreeBSD-STABLE 1775.Nm ipfw2 1776is standard in 1777.Fx 1778CURRENT, whereas 1779.Fx 1780STABLE still uses 1781.Nm ipfw1 1782unless the kernel is compiled with 1783.Cm options IPFW2 , 1784and 1785.Nm /sbin/ipfw 1786and 1787.Nm /usr/lib/libalias 1788are recompiled with 1789.Cm -DIPFW2 1790and reinstalled (the same effect can be achieved by adding 1791.Cm IPFW2=TRUE 1792to 1793.Nm /etc/make.conf 1794before a buildworld). 1795.Pp 1796.Sh IPFW2 ENHANCEMENTS 1797This Section lists the features that have been introduced in 1798.Nm ipfw2 1799which were not present in 1800.Nm ipfw1 . 1801They are listed in order of the potential impact that they can 1802have in writing your rulesets. 1803You might want to consider using these features in order to 1804write your rulesets in a more efficient way. 1805.Bl -tag -width indent 1806.It Syntax and flags 1807.Nm ipfw1 1808does not support the -n flag (only test syntax), 1809nor does it allow spaces after commas or support all 1810rule fields in a single argument. 1811.Nm ipfw1 1812does not allow the -f flag (force) in conjunction with 1813the -p flag (preprocessor). 1814.Nm ipfw1 1815does not support the -c (compact) flag. 1816.It Handling of non-IPv4 packets 1817.Nm ipfw1 1818will silently accept all non-IPv4 packets (which 1819.Nm ipfw1 1820will only see when 1821.Em net.link.ether.bridge_ipfw=1 Ns 1822). 1823.Nm ipfw2 1824will filter all packets (including non-IPv4 ones) according to the ruleset. 1825To achieve the same behaviour as 1826.Nm ipfw1 1827you can use the following as the very first rule in your ruleset: 1828.Pp 1829.Dl "ipfw add 1 allow layer2 not mac-type ip" 1830.Pp 1831The 1832.Cm layer2 1833option might seem redundant, but it is necessary -- packets 1834passed to the firewall from layer3 will not have a MAC header, 1835so the 1836.Cm mac-type ip 1837pattern will always fail on them, and the 1838.Cm not 1839operator will make this rule into a pass-all. 1840.It Addresses 1841.Nm ipfw1 1842does not support address sets or lists of addresses. 1843.Pp 1844.It Port specifications 1845.Nm ipfw1 1846only allows one port range when specifying TCP and UDP ports, and 1847is limited to 10 entries instead of the 30 allowed by 1848.Nm ipfw2 . 1849Also, in 1850.Nm ipfw1 1851you can only specify ports when the rule is requesting 1852.Cm tcp 1853or 1854.Cm udp 1855packets. With 1856.Nm ipfw2 1857you can put port specifications in rules matching all packets, 1858and the match will be attempted only on those packets carrying 1859protocols which include port identifiers. 1860.Pp 1861Finally, 1862.Nm ipfw1 1863allowed the first port entry to be specified as 1864.Ar port:mask 1865where 1866.Ar mask 1867can be an arbitrary 16-bit mask. 1868This syntax is of questionable usefulness and it is not 1869supported anymore in 1870.Nm ipfw2 . 1871.It Or-blocks 1872.Nm ipfw1 1873does not support Or-blocks. 1874.It keepalives 1875.Nm ipfw1 1876does not generate keepalives for stateful sessions. 1877As a consequence, it might cause idle sessions to drop because 1878the lifetime of the dynamic rules expires. 1879.It Sets of rules 1880.Nm ipfw1 1881does not implement sets of rules. 1882.It MAC header filtering and Layer-2 firewalling. 1883.Nm ipfw1 1884does not implement filtering on MAC header fields, nor is it 1885invoked on packets from 1886.Cm ether_demux() 1887and 1888.Cm ether_output_frame(). 1889The sysctl variable 1890.Em net.link.ether.ipfw 1891has no effect there. 1892.It Options 1893In 1894.Nm ipfw1 , 1895the following options only accept a single value as an argument: 1896.Pp 1897.Cm ipid, iplen, ipttl 1898.Pp 1899The following options are not implemented by 1900.Nm ipfw1 : 1901.Pp 1902.Cm dst-ip, dst-port, layer2, mac, mac-type, src-ip, src-port. 1903.Pp 1904Additionally, the RELENG_4 version of 1905.Nm ipfw1 1906does not implement the following options: 1907.Pp 1908.Cm ipid, iplen, ipprecedence, iptos, ipttl, 1909.Cm ipversion, tcpack, tcpseq, tcpwin . 1910.It Dummynet options 1911The following option for 1912.Nm dummynet 1913pipes/queues is not supported: 1914.Cm noerror . 1915.El 1916.Sh EXAMPLES 1917There are far too many possible uses of 1918.Nm 1919so this Section will only give a small set of examples. 1920.Pp 1921.Ss BASIC PACKET FILTERING 1922This command adds an entry which denies all tcp packets from 1923.Em cracker.evil.org 1924to the telnet port of 1925.Em wolf.tambov.su 1926from being forwarded by the host: 1927.Pp 1928.Dl "ipfw add deny tcp from cracker.evil.org to wolf.tambov.su telnet" 1929.Pp 1930This one disallows any connection from the entire cracker's 1931network to my host: 1932.Pp 1933.Dl "ipfw add deny ip from 123.45.67.0/24 to my.host.org" 1934.Pp 1935A first and efficient way to limit access (not using dynamic rules) 1936is the use of the following rules: 1937.Pp 1938.Dl "ipfw add allow tcp from any to any established" 1939.Dl "ipfw add allow tcp from net1 portlist1 to net2 portlist2 setup" 1940.Dl "ipfw add allow tcp from net3 portlist3 to net3 portlist3 setup" 1941.Dl "..." 1942.Dl "ipfw add deny tcp from any to any" 1943.Pp 1944The first rule will be a quick match for normal TCP packets, 1945but it will not match the initial SYN packet, which will be 1946matched by the 1947.Cm setup 1948rules only for selected source/destination pairs. 1949All other SYN packets will be rejected by the final 1950.Cm deny 1951rule. 1952.Pp 1953If you administer one or more subnets, you can take advantage of the 1954.Nm ipfw2 1955syntax to specify address sets and or-blocks and write extremely 1956compact rulesets which selectively enable services to blocks 1957of clients, as below: 1958.Pp 1959.Dl "goodguys=\*q{ 10.1.2.0/24{20,35,66,18} or 10.2.3.0/28{6,3,11} }\*q" 1960.Dl "badguys=\*q10.1.2.0/24{8,38,60}\*q" 1961.Dl "" 1962.Dl "ipfw add allow ip from ${goodguys} to any" 1963.Dl "ipfw add deny ip from ${badguys} to any" 1964.Dl "... normal policies ..." 1965.Pp 1966The 1967.Nm ipfw1 1968syntax would require a separate rule for each IP in the above 1969example. 1970.Pp 1971The 1972.Cm verrevpath 1973option could be used to do automated anti-spoofing by adding the 1974following to the top of a ruleset: 1975.Pp 1976.Dl "ipfw add deny ip from any to any not verrevpath in" 1977.Pp 1978This rule drops all incoming packets that appear to be coming to the 1979system on the wrong interface. For example, a packet with a source 1980address belonging to a host on a protected internal network would be 1981dropped if it tried to enter the system from an external interface. 1982.Ss DYNAMIC RULES 1983In order to protect a site from flood attacks involving fake 1984TCP packets, it is safer to use dynamic rules: 1985.Pp 1986.Dl "ipfw add check-state" 1987.Dl "ipfw add deny tcp from any to any established" 1988.Dl "ipfw add allow tcp from my-net to any setup keep-state" 1989.Pp 1990This will let the firewall install dynamic rules only for 1991those connection which start with a regular SYN packet coming 1992from the inside of our network. 1993Dynamic rules are checked when encountering the first 1994.Cm check-state 1995or 1996.Cm keep-state 1997rule. 1998A 1999.Cm check-state 2000rule should usually be placed near the beginning of the 2001ruleset to minimize the amount of work scanning the ruleset. 2002Your mileage may vary. 2003.Pp 2004To limit the number of connections a user can open 2005you can use the following type of rules: 2006.Pp 2007.Dl "ipfw add allow tcp from my-net/24 to any setup limit src-addr 10" 2008.Dl "ipfw add allow tcp from any to me setup limit src-addr 4" 2009.Pp 2010The former (assuming it runs on a gateway) will allow each host 2011on a /24 network to open at most 10 TCP connections. 2012The latter can be placed on a server to make sure that a single 2013client does not use more than 4 simultaneous connections. 2014.Pp 2015.Em BEWARE : 2016stateful rules can be subject to denial-of-service attacks 2017by a SYN-flood which opens a huge number of dynamic rules. 2018The effects of such attacks can be partially limited by 2019acting on a set of 2020.Xr sysctl 8 2021variables which control the operation of the firewall. 2022.Pp 2023Here is a good usage of the 2024.Cm list 2025command to see accounting records and timestamp information: 2026.Pp 2027.Dl ipfw -at list 2028.Pp 2029or in short form without timestamps: 2030.Pp 2031.Dl ipfw -a list 2032.Pp 2033which is equivalent to: 2034.Pp 2035.Dl ipfw show 2036.Pp 2037Next rule diverts all incoming packets from 192.168.2.0/24 2038to divert port 5000: 2039.Pp 2040.Dl ipfw divert 5000 ip from 192.168.2.0/24 to any in 2041.Pp 2042.Ss TRAFFIC SHAPING 2043The following rules show some of the applications of 2044.Nm 2045and 2046.Xr dummynet 4 2047for simulations and the like. 2048.Pp 2049This rule drops random incoming packets with a probability 2050of 5%: 2051.Pp 2052.Dl "ipfw add prob 0.05 deny ip from any to any in" 2053.Pp 2054A similar effect can be achieved making use of dummynet pipes: 2055.Pp 2056.Dl "ipfw add pipe 10 ip from any to any" 2057.Dl "ipfw pipe 10 config plr 0.05" 2058.Pp 2059We can use pipes to artificially limit bandwidth, e.g. on a 2060machine acting as a router, if we want to limit traffic from 2061local clients on 192.168.2.0/24 we do: 2062.Pp 2063.Dl "ipfw add pipe 1 ip from 192.168.2.0/24 to any out" 2064.Dl "ipfw pipe 1 config bw 300Kbit/s queue 50KBytes" 2065.Pp 2066note that we use the 2067.Cm out 2068modifier so that the rule is not used twice. 2069Remember in fact that 2070.Nm 2071rules are checked both on incoming and outgoing packets. 2072.Pp 2073Should we want to simulate a bidirectional link with bandwidth 2074limitations, the correct way is the following: 2075.Pp 2076.Dl "ipfw add pipe 1 ip from any to any out" 2077.Dl "ipfw add pipe 2 ip from any to any in" 2078.Dl "ipfw pipe 1 config bw 64Kbit/s queue 10Kbytes" 2079.Dl "ipfw pipe 2 config bw 64Kbit/s queue 10Kbytes" 2080.Pp 2081The above can be very useful, e.g. if you want to see how 2082your fancy Web page will look for a residential user who 2083is connected only through a slow link. 2084You should not use only one pipe for both directions, unless 2085you want to simulate a half-duplex medium (e.g. AppleTalk, 2086Ethernet, IRDA). 2087It is not necessary that both pipes have the same configuration, 2088so we can also simulate asymmetric links. 2089.Pp 2090Should we want to verify network performance with the RED queue 2091management algorithm: 2092.Pp 2093.Dl "ipfw add pipe 1 ip from any to any" 2094.Dl "ipfw pipe 1 config bw 500Kbit/s queue 100 red 0.002/30/80/0.1" 2095.Pp 2096Another typical application of the traffic shaper is to 2097introduce some delay in the communication. 2098This can significantly affect applications which do a lot of Remote 2099Procedure Calls, and where the round-trip-time of the 2100connection often becomes a limiting factor much more than 2101bandwidth: 2102.Pp 2103.Dl "ipfw add pipe 1 ip from any to any out" 2104.Dl "ipfw add pipe 2 ip from any to any in" 2105.Dl "ipfw pipe 1 config delay 250ms bw 1Mbit/s" 2106.Dl "ipfw pipe 2 config delay 250ms bw 1Mbit/s" 2107.Pp 2108Per-flow queueing can be useful for a variety of purposes. 2109A very simple one is counting traffic: 2110.Pp 2111.Dl "ipfw add pipe 1 tcp from any to any" 2112.Dl "ipfw add pipe 1 udp from any to any" 2113.Dl "ipfw add pipe 1 ip from any to any" 2114.Dl "ipfw pipe 1 config mask all" 2115.Pp 2116The above set of rules will create queues (and collect 2117statistics) for all traffic. 2118Because the pipes have no limitations, the only effect is 2119collecting statistics. 2120Note that we need 3 rules, not just the last one, because 2121when 2122.Nm 2123tries to match IP packets it will not consider ports, so we 2124would not see connections on separate ports as different 2125ones. 2126.Pp 2127A more sophisticated example is limiting the outbound traffic 2128on a net with per-host limits, rather than per-network limits: 2129.Pp 2130.Dl "ipfw add pipe 1 ip from 192.168.2.0/24 to any out" 2131.Dl "ipfw add pipe 2 ip from any to 192.168.2.0/24 in" 2132.Dl "ipfw pipe 1 config mask src-ip 0x000000ff bw 200Kbit/s queue 20Kbytes" 2133.Dl "ipfw pipe 2 config mask dst-ip 0x000000ff bw 200Kbit/s queue 20Kbytes" 2134.Ss SETS OF RULES 2135To add a set of rules atomically, e.g. set 18: 2136.Pp 2137.Dl "ipfw set disable 18" 2138.Dl "ipfw add NN set 18 ... # repeat as needed" 2139.Dl "ipfw set enable 18" 2140.Pp 2141To delete a set of rules atomically the command is simply: 2142.Pp 2143.Dl "ipfw delete set 18" 2144.Pp 2145To test a ruleset and disable it and regain control if something goes wrong: 2146.Pp 2147.Dl "ipfw set disable 18" 2148.Dl "ipfw add NN set 18 ... # repeat as needed" 2149.Dl "ipfw set enable 18; echo done; sleep 30 && ipfw set disable 18" 2150.Pp 2151Here if everything goes well, you press control-C before the "sleep" 2152terminates, and your ruleset will be left active. Otherwise, e.g. if 2153you cannot access your box, the ruleset will be disabled after 2154the sleep terminates thus restoring the previous situation. 2155.Sh SEE ALSO 2156.Xr cpp 1 , 2157.Xr m4 1 , 2158.Xr bridge 4 , 2159.Xr divert 4 , 2160.Xr dummynet 4 , 2161.Xr ip 4 , 2162.Xr ipfirewall 4 , 2163.Xr protocols 5 , 2164.Xr services 5 , 2165.Xr init 8 , 2166.Xr kldload 8 , 2167.Xr reboot 8 , 2168.Xr sysctl 8 , 2169.Xr syslogd 8 2170.Sh BUGS 2171The syntax has grown over the years and sometimes it might be confusing. 2172Unfortunately, backward compatibility prevents cleaning up mistakes 2173made in the definition of the syntax. 2174.Pp 2175.Em !!! WARNING !!! 2176.Pp 2177Misconfiguring the firewall can put your computer in an unusable state, 2178possibly shutting down network services and requiring console access to 2179regain control of it. 2180.Pp 2181Incoming packet fragments diverted by 2182.Cm divert 2183or 2184.Cm tee 2185are reassembled before delivery to the socket. 2186The action used on those packet is the one from the 2187rule which matches the first fragment of the packet. 2188.Pp 2189Packets that match a 2190.Cm tee 2191rule should not be immediately accepted, but should continue 2192going through the rule list. 2193This may be fixed in a later version. 2194.Pp 2195Packets diverted to userland, and then reinserted by a userland process 2196may lose various packet attributes. 2197The packet source interface name 2198will be preserved if it is shorter than 8 bytes and the userland process 2199saves and reuses the sockaddr_in 2200(as does 2201.Xr natd 8 ) ; 2202otherwise, it may be lost. 2203If a packet is reinserted in this manner, later rules may be incorrectly 2204applied, making the order of 2205.Cm divert 2206rules in the rule sequence very important. 2207.Sh AUTHORS 2208.An Ugen J. S. Antsilevich , 2209.An Poul-Henning Kamp , 2210.An Alex Nash , 2211.An Archie Cobbs , 2212.An Luigi Rizzo . 2213.Pp 2214.An -nosplit 2215API based upon code written by 2216.An Daniel Boulet 2217for BSDI. 2218.Pp 2219Work on 2220.Xr dummynet 4 2221traffic shaper supported by Akamba Corp. 2222.Sh HISTORY 2223The 2224.Nm 2225utility first appeared in 2226.Fx 2.0 . 2227.Xr dummynet 4 2228was introduced in 2229.Fx 2.2.8 . 2230Stateful extensions were introduced in 2231.Fx 4.0 . 2232.Nm ipfw2 2233was introduced in Summer 2002. 2234