1fc32c802SMatthew Dillon.\" Copyright (c) 2001, Matthew Dillon. Terms and conditions are those of 2fc32c802SMatthew Dillon.\" the BSD Copyright as specified in the file "/usr/src/COPYRIGHT" in 3fc32c802SMatthew Dillon.\" the source tree. 4fc32c802SMatthew Dillon.\" 5fc32c802SMatthew Dillon.\" $FreeBSD$ 6fc32c802SMatthew Dillon.\" 7fc32c802SMatthew Dillon.Dd May 26, 2001 8fc32c802SMatthew Dillon.Dt FIREWALL 7 93d45e180SRuslan Ermilov.Os 10fc32c802SMatthew Dillon.Sh NAME 11fc32c802SMatthew Dillon.Nm firewall 12fc32c802SMatthew Dillon.Nd simple firewalls under FreeBSD 13fc32c802SMatthew Dillon.Sh FIREWALL BASICS 14fc32c802SMatthew DillonA Firewall is most commonly used to protect an internal network 15fc32c802SMatthew Dillonfrom an outside network by preventing the outside network from 16fc32c802SMatthew Dillonmaking arbitrary connections into the internal network. Firewalls 17fc32c802SMatthew Dillonare also used to prevent outside entities from spoofing internal 18fc32c802SMatthew DillonIP addresses and to isolate services such as NFS or SMBFS (Windows 19fc32c802SMatthew Dillonfile sharing) within LAN segments. 20fc32c802SMatthew Dillon.Pp 21fc32c802SMatthew DillonThe 22fc32c802SMatthew Dillon.Fx 23fc32c802SMatthew Dillonfirewalling system also has the capability to limit bandwidth using 24fc32c802SMatthew Dillon.Xr dummynet 4 . 257c86a74bSMike PritchardThis feature can be useful when you need to guarantee a certain 26fc32c802SMatthew Dillonamount of bandwidth for a critical purpose. For example, if you 277c86a74bSMike Pritchardare doing video conferencing over the Internet via your 28fc32c802SMatthew Dillonoffice T1 (1.5 MBits), you may wish to bandwidth-limit all other 29fc32c802SMatthew DillonT1 traffic to 1 MBit in order to reserve at least 0.5 MBits 30fc32c802SMatthew Dillonfor your video conferencing connections. Similarly if you are 31fc32c802SMatthew Dillonrunning a popular web or ftp site from a colocation facility 32fc32c802SMatthew Dillonyou might want to limit bandwidth to prevent excessive band 33fc32c802SMatthew Dillonwidth charges from your provider. 34fc32c802SMatthew Dillon.Pp 35fc32c802SMatthew DillonFinally, 36fc32c802SMatthew Dillon.Fx 37fc32c802SMatthew Dillonfirewalls may be used to divert packets or change the next-hop 38fc32c802SMatthew Dillonaddress for packets to help route them to the correct destination. 39fc32c802SMatthew DillonPacket diversion is most often used to support NAT (network 40fc32c802SMatthew Dillonaddress translation), which allows an internal network using 41fc32c802SMatthew Dillona private IP space to make connections to the outside for browsing 42fc32c802SMatthew Dillonor other purposes. 43fc32c802SMatthew Dillon.Pp 44fc32c802SMatthew DillonConstructing a firewall may appear to be trivial, but most people 45fc32c802SMatthew Dillonget them wrong. The most common mistake is to create an exclusive 46fc32c802SMatthew Dillonfirewall rather then an inclusive firewall. An exclusive firewall 47fc32c802SMatthew Dillonallows all packets through except for those matching a set of rules. 48fc32c802SMatthew DillonAn inclusive firewall allows only packets matching the rulset 49fc32c802SMatthew Dillonthrough. Inclusive firewalls are much, much safer then exclusive 50fc32c802SMatthew Dillonfirewalls but a tad more difficult to build properly. The 51fc32c802SMatthew Dillonsecond most common mistake is to blackhole everything except the 52fc32c802SMatthew Dillonparticular port you want to let through. TCP/IP needs to be able 53fc32c802SMatthew Dillonto get certain types of ICMP errors to function properly - for 54fc32c802SMatthew Dillonexample, to implement MTU discovery. Also, a number of common 55fc32c802SMatthew Dillonsystem daemons make reverse connections to the 56fc32c802SMatthew Dillon.Sy auth 57fc32c802SMatthew Dillonservice in an attempt to authenticate the user making a connection. 58fc32c802SMatthew DillonAuth is rather dangerous but the proper implementation is to return 59fc32c802SMatthew Dillona TCP reset for the connection attempt rather then simply blackholing 60fc32c802SMatthew Dillonthe packet. We cover these and other quirks involved with constructing 61fc32c802SMatthew Dillona firewall in the sample firewall section below. 62fc32c802SMatthew Dillon.Sh IPFW KERNEL CONFIGURATION 63aa2ada4eSMurray StokelyYou do not need to create a custom kernel to use the IP firewalling features. 64b895742dSMatthew DillonIf you enable firewalling in your 65b895742dSMatthew Dillon.Em /etc/rc.conf 66b895742dSMatthew Dillon(see below), the ipfw kernel module will be loaded automatically. However, 67b895742dSMatthew Dillonif you are paranoid you can compile IPFW directly into the 68fc32c802SMatthew Dillon.Fx 69b895742dSMatthew Dillonkernel by using the 70fc32c802SMatthew Dillon.Sy IPFIREWALL 71b895742dSMatthew Dillonoption set. If compiled in the kernel defaults its firewall to deny all 72fc32c802SMatthew Dillonpackets by default, which means that if you do not load in 73fc32c802SMatthew Dillona permissive ruleset via 74fc32c802SMatthew Dillon.Em /etc/rc.conf , 75fc32c802SMatthew Dillonrebooting into your new kernel will take the network offline 76fc32c802SMatthew Dillonand will prevent you from being able to access it if you 77fc32c802SMatthew Dillonare not sitting at the console. It is also quite common to 78fc32c802SMatthew Dillonupdate a kernel to a new release and reboot before updating 79fc32c802SMatthew Dillonthe binaries. This can result in an incompatibility between 80fc32c802SMatthew Dillonthe 81fc32c802SMatthew Dillon.Xr ipfw 8 82fc32c802SMatthew Dillonprogram and the kernel which prevents it from running in the 83fc32c802SMatthew Dillonboot sequence, also resulting in an inaccessible machine. 84fc32c802SMatthew DillonBecause of these problems the 85fc32c802SMatthew Dillon.Sy IPFIREWALL_DEFAULT_TO_ACCEPT 86fc32c802SMatthew Dillonkernel option is also available which changes the default firewall 87b895742dSMatthew Dillonto pass through all packets. Note, however, that using this option 88b895742dSMatthew Dillonmay open a small window of opportunity during booting where your 89b895742dSMatthew Dillonfirewall passes all packets. Still, it's a good option to use 90b895742dSMatthew Dillonwhile getting up to speed with 91fc32c802SMatthew Dillon.Fx 92b895742dSMatthew Dillonfirewalling. Get rid of it once you understand how it all works 93b895742dSMatthew Dillonto close the loophole, though. There is a third option called 94fc32c802SMatthew Dillon.Sy IPDIVERT 95fc32c802SMatthew Dillonwhich allows you to use the firewall to divert packets to a user program 96fc32c802SMatthew Dillonand is necessary if you wish to use 97fc32c802SMatthew Dillon.Xr natd 8 98fc32c802SMatthew Dillonto give private internal networks access to the outside world. 99fc32c802SMatthew DillonIf you want to be able to limit the bandwidth used by certain types of 100fc32c802SMatthew Dillontraffic, the 101fc32c802SMatthew Dillon.Sy DUMMYNET 102fc32c802SMatthew Dillonoption must be used to enable 103fc32c802SMatthew Dillon.Em ipfw pipe 104fc32c802SMatthew Dillonrules. 105fc32c802SMatthew Dillon.Sh SAMPLE IPFW-BASED FIREWALL 106fc32c802SMatthew DillonHere is an example ipfw-based firewall taken from a machine with three 107fc32c802SMatthew Dilloninterface cards. fxp0 is connected to the 'exposed' LAN. Machines 108fc32c802SMatthew Dillonon this LAN are dual-homed with both internal 10. IP addresses and 1097c86a74bSMike PritchardInternet-routed IP addresses. In our example, 192.100.5.x represents 1107c86a74bSMike Pritchardthe Internet-routed IP block while 10.x.x.x represents the internal 111fc32c802SMatthew Dillonnetworks. While it isn't relevant to the example, 10.0.1.x is 112fc32c802SMatthew Dillonassigned as the internal address block for the LAN on fxp0, 10.0.2.x 113fc32c802SMatthew Dillonfor the LAN on fxp1, and 10.0.3.x for the LAN on fxp2. 114fc32c802SMatthew Dillon.Pp 1157c86a74bSMike PritchardIn this example we want to isolate all three LANs from the Internet 116fc32c802SMatthew Dillonas well as isolate them from each other, and we want to give all 1177c86a74bSMike Pritchardinternal addresses access to the Internet through a NAT gateway running 118fc32c802SMatthew Dillonon this machine. To make the NAT gateway work, the firewall machine 1197c86a74bSMike Pritchardis given two Internet-exposed addresses on fxp0 in addition to an 120fc32c802SMatthew Dilloninternal 10. address on fxp0: one exposed address (not shown) 121fc32c802SMatthew Dillonrepresents the machine's official address, and the second exposed 122fc32c802SMatthew Dillonaddress (192.100.5.5 in our example) represents the NAT gateway 123fc32c802SMatthew Dillonrendezvous IP. We make the example more complex by giving the machines 124fc32c802SMatthew Dillonon the exposed LAN internal 10.0.0.x addresses as well as exposed 125fc32c802SMatthew Dillonaddresses. The idea here is that you can bind internal services 126fc32c802SMatthew Dillonto internal addresses even on exposed machines and still protect 1277c86a74bSMike Pritchardthose services from the Internet. The only services you run on 128fc32c802SMatthew Dillonexposed IP addresses would be the ones you wish to expose to the 1297c86a74bSMike PritchardInternet. 130fc32c802SMatthew Dillon.Pp 131fc32c802SMatthew DillonIt is important to note that the 10.0.0.x network in our example 132fc32c802SMatthew Dillonis not protected by our firewall. You must make sure that your 1337c86a74bSMike PritchardInternet router protects this network from outside spoofing. 134fc32c802SMatthew DillonAlso, in our example, we pretty much give the exposed hosts free 135fc32c802SMatthew Dillonreign on our internal network when operating services through 136fc32c802SMatthew Dilloninternal IP addresses (10.0.0.x). This is somewhat of security 137fc32c802SMatthew Dillonrisk... what if an exposed host is compromised? To remove the 138fc32c802SMatthew Dillonrisk and force everything coming in via LAN0 to go through 139fc32c802SMatthew Dillonthe firewall, remove rules 01010 and 01011. 140fc32c802SMatthew Dillon.Pp 141fc32c802SMatthew DillonFinally, note that the use of internal addresses represents a 142fc32c802SMatthew Dillonbig piece of our firewall protection mechanism. With proper 143fc32c802SMatthew Dillonspoofing safeguards in place, nothing outside can directly 144fc32c802SMatthew Dillonaccess an internal (LAN1 or LAN2) host. 145fc32c802SMatthew Dillon.Bd -literal 146fc32c802SMatthew Dillon# /etc/rc.conf 147fc32c802SMatthew Dillon# 148fc32c802SMatthew Dillonfirewall_enable="YES" 149fc32c802SMatthew Dillonfirewall_type="/etc/ipfw.conf" 150fc32c802SMatthew Dillon 151fc32c802SMatthew Dillon# temporary port binding range let 152fc32c802SMatthew Dillon# through the firewall. 153fc32c802SMatthew Dillon# 154fc32c802SMatthew Dillon# NOTE: heavily loaded services running through the firewall may require 155fc32c802SMatthew Dillon# a larger port range for local-size binding. 4000-10000 or 4000-30000 156fc32c802SMatthew Dillon# might be a better choice. 157fc32c802SMatthew Dillonip_portrange_first=4000 158fc32c802SMatthew Dillonip_portrange_last=5000 15963b2f772SRuslan Ermilov\&... 160fc32c802SMatthew Dillon.Ed 161fc32c802SMatthew Dillon.Pp 162fc32c802SMatthew Dillon.Bd -literal 163fc32c802SMatthew Dillon# /etc/ipfw.conf 164fc32c802SMatthew Dillon# 165fc32c802SMatthew Dillon# FIREWALL: the firewall machine / nat gateway 166fc32c802SMatthew Dillon# LAN0 10.0.0.X and 192.100.5.X (dual homed) 167fc32c802SMatthew Dillon# LAN1 10.0.1.X 168fc32c802SMatthew Dillon# LAN2 10.0.2.X 169fc32c802SMatthew Dillon# sw: ethernet switch (unmanaged) 170fc32c802SMatthew Dillon# 1717c86a74bSMike Pritchard# 192.100.5.x represents IP addresses exposed to the Internet 1727c86a74bSMike Pritchard# (i.e. Internet routeable). 10.x.x.x represent internal IPs 173fc32c802SMatthew Dillon# (not exposed) 174fc32c802SMatthew Dillon# 175fc32c802SMatthew Dillon# [LAN1] 176fc32c802SMatthew Dillon# ^ 177fc32c802SMatthew Dillon# | 178fc32c802SMatthew Dillon# FIREWALL -->[LAN2] 179fc32c802SMatthew Dillon# | 180fc32c802SMatthew Dillon# [LAN0] 181fc32c802SMatthew Dillon# | 182fc32c802SMatthew Dillon# +--> exposed host A 183fc32c802SMatthew Dillon# +--> exposed host B 184fc32c802SMatthew Dillon# +--> exposed host C 185fc32c802SMatthew Dillon# | 186fc32c802SMatthew Dillon# INTERNET (secondary firewall) 187fc32c802SMatthew Dillon# ROUTER 188fc32c802SMatthew Dillon# | 1897c86a74bSMike Pritchard# [Internet] 190fc32c802SMatthew Dillon# 191fc32c802SMatthew Dillon# NOT SHOWN: The INTERNET ROUTER must contain rules to disallow 192fc32c802SMatthew Dillon# all packets with source IP addresses in the 10. block in order 193fc32c802SMatthew Dillon# to protect the dual-homed 10.0.0.x block. Exposed hosts are 194fc32c802SMatthew Dillon# not otherwise protected in this example - they should only bind 195fc32c802SMatthew Dillon# exposed services to exposed IPs but can safely bind internal 196fc32c802SMatthew Dillon# services to internal IPs. 197fc32c802SMatthew Dillon# 198fc32c802SMatthew Dillon# The NAT gateway works by taking packets sent from internal 199fc32c802SMatthew Dillon# IP addresses to external IP addresses and routing them to natd, which 200fc32c802SMatthew Dillon# is listening on port 8668. This is handled by rule 00300. Data coming 201fc32c802SMatthew Dillon# back to natd from the outside world must also be routed to natd using 202fc32c802SMatthew Dillon# rule 00301. To make the example interesting, we note that we do 203fc32c802SMatthew Dillon# NOT have to run internal requests to exposed hosts through natd 204fc32c802SMatthew Dillon# (rule 00290) because those exposed hosts know about our 205fc32c802SMatthew Dillon# 10. network. This can reduce the load on natd. Also note that we 206fc32c802SMatthew Dillon# of course do not have to route internal<->internal traffic through 207fc32c802SMatthew Dillon# natd since those hosts know how to route our 10. internal network. 208fc32c802SMatthew Dillon# The natd command we run from /etc/rc.local is shown below. See 209fc32c802SMatthew Dillon# also the in-kernel version of natd, ipnat. 210fc32c802SMatthew Dillon# 211fc32c802SMatthew Dillon# natd -s -u -a 208.161.114.67 212fc32c802SMatthew Dillon# 213fc32c802SMatthew Dillon# 214fc32c802SMatthew Dillonadd 00290 skipto 1000 ip from 10.0.0.0/8 to 192.100.5.0/24 215fc32c802SMatthew Dillonadd 00300 divert 8668 ip from 10.0.0.0/8 to not 10.0.0.0/8 216fc32c802SMatthew Dillonadd 00301 divert 8668 ip from not 10.0.0.0/8 to 192.100.5.5 217fc32c802SMatthew Dillon 218fc32c802SMatthew Dillon# Short cut the rules to avoid running high bandwidths through 219fc32c802SMatthew Dillon# the entire rule set. Allow established tcp connections through, 220fc32c802SMatthew Dillon# and shortcut all outgoing packets under the assumption that 221fc32c802SMatthew Dillon# we need only firewall incoming packets. 222fc32c802SMatthew Dillon# 223fc32c802SMatthew Dillon# Allowing established tcp connections through creates a small 224fc32c802SMatthew Dillon# hole but may be necessary to avoid overloading your firewall. 225fc32c802SMatthew Dillon# If you are worried, you can move the rule to after the spoof 226fc32c802SMatthew Dillon# checks. 227fc32c802SMatthew Dillon# 228fc32c802SMatthew Dillonadd 01000 allow tcp from any to any established 229fc32c802SMatthew Dillonadd 01001 allow all from any to any out via fxp0 230fc32c802SMatthew Dillonadd 01001 allow all from any to any out via fxp1 231fc32c802SMatthew Dillonadd 01001 allow all from any to any out via fxp2 232fc32c802SMatthew Dillon 233fc32c802SMatthew Dillon# Spoof protection. This depends on how well you trust your 234fc32c802SMatthew Dillon# internal networks. Packets received via fxp1 MUST come from 235fc32c802SMatthew Dillon# 10.0.1.x. Packets received via fxp2 MUST come from 10.0.2.x. 236fc32c802SMatthew Dillon# Packets received via fxp0 cannot come from the LAN1 or LAN2 2377c86a74bSMike Pritchard# blocks. We can't protect 10.0.0.x here, the Internet router 238fc32c802SMatthew Dillon# must do that for us. 239fc32c802SMatthew Dillon# 240fc32c802SMatthew Dillonadd 01500 deny all from not 10.0.1.0/24 in via fxp1 241fc32c802SMatthew Dillonadd 01500 deny all from not 10.0.2.0/24 in via fxp2 242fc32c802SMatthew Dillonadd 01501 deny all from 10.0.1.0/24 in via fxp0 243fc32c802SMatthew Dillonadd 01501 deny all from 10.0.2.0/24 in via fxp0 244fc32c802SMatthew Dillon 245fc32c802SMatthew Dillon# In this example rule set there are no restrictions between 246fc32c802SMatthew Dillon# internal hosts, even those on the exposed LAN (as long as 247fc32c802SMatthew Dillon# they use an internal IP address). This represents a 248fc32c802SMatthew Dillon# potential security hole (what if an exposed host is 249fc32c802SMatthew Dillon# compromised?). If you want full restrictions to apply 250fc32c802SMatthew Dillon# between the three LANs, firewalling them off from each 251fc32c802SMatthew Dillon# other for added security, remove these two rules. 252fc32c802SMatthew Dillon# 253fc32c802SMatthew Dillon# If you want to isolate LAN1 and LAN2, but still want 254fc32c802SMatthew Dillon# to give exposed hosts free reign with each other, get 255fc32c802SMatthew Dillon# rid of rule 01010 and keep rule 01011. 256fc32c802SMatthew Dillon# 257fc32c802SMatthew Dillon# (commented out, uncomment for less restrictive firewall) 258fc32c802SMatthew Dillon#add 01010 allow all from 10.0.0.0/8 to 10.0.0.0/8 259fc32c802SMatthew Dillon#add 01011 allow all from 192.100.5.0/24 to 192.100.5.0/24 260fc32c802SMatthew Dillon# 261fc32c802SMatthew Dillon 262fc32c802SMatthew Dillon# SPECIFIC SERVICES ALLOWED FROM SPECIFIC LANS 263fc32c802SMatthew Dillon# 264fc32c802SMatthew Dillon# If using a more restrictive firewall, allow specific LANs 265fc32c802SMatthew Dillon# access to specific services running on the firewall itself. 266fc32c802SMatthew Dillon# In this case we assume LAN1 needs access to filesharing running 267fc32c802SMatthew Dillon# on the firewall. If using a less restrictive firewall 268fc32c802SMatthew Dillon# (allowing rule 01010), you don't need these rules. 269fc32c802SMatthew Dillon# 270fc32c802SMatthew Dillonadd 01012 allow tcp from 10.0.1.0/8 to 10.0.1.1 139 271fc32c802SMatthew Dillonadd 01012 allow udp from 10.0.1.0/8 to 10.0.1.1 137,138 272fc32c802SMatthew Dillon 273fc32c802SMatthew Dillon# GENERAL SERVICES ALLOWED TO CROSS INTERNAL AND EXPOSED LANS 274fc32c802SMatthew Dillon# 275fc32c802SMatthew Dillon# We allow specific UDP services through: DNS lookups, ntalk, and ntp. 276fc32c802SMatthew Dillon# Note that internal services are protected by virtue of having 277fc32c802SMatthew Dillon# spoof-proof internal IP addresses (10. net), so these rules 278fc32c802SMatthew Dillon# really only apply to services bound to exposed IPs. We have 279fc32c802SMatthew Dillon# to allow UDP fragments or larger fragmented UDP packets will 280fc32c802SMatthew Dillon# not survive the firewall. 281fc32c802SMatthew Dillon# 282fc32c802SMatthew Dillon# If we want to expose high-numbered temporary service ports 283fc32c802SMatthew Dillon# for things like DNS lookup responses we can use a port range, 284fc32c802SMatthew Dillon# in this example 4000-65535, and we set to /etc/rc.conf variables 285fc32c802SMatthew Dillon# on all exposed machines to make sure they bind temporary ports 286fc32c802SMatthew Dillon# to the exposed port range (see rc.conf example above) 287fc32c802SMatthew Dillon# 288fc32c802SMatthew Dillonadd 02000 allow udp from any to any 4000-65535,domain,ntalk,ntp 289fc32c802SMatthew Dillonadd 02500 allow udp from any to any frag 290fc32c802SMatthew Dillon 291fc32c802SMatthew Dillon# Allow similar services for TCP. Again, these only apply to 292fc32c802SMatthew Dillon# services bound to exposed addresses. NOTE: we allow 'auth' 293fc32c802SMatthew Dillon# through but do not actually run an identd server on any exposed 294fc32c802SMatthew Dillon# port. This allows the machine being authed to respond with a 295fc32c802SMatthew Dillon# TCP RESET. Throwing the packet away would result in delays 296fc32c802SMatthew Dillon# when connecting to remote services that do reverse ident lookups. 297fc32c802SMatthew Dillon# 298fc32c802SMatthew Dillon# Note that we do not allow tcp fragments through, and that we do 299fc32c802SMatthew Dillon# not allow fragments in general (except for UDP fragments). We 300fc32c802SMatthew Dillon# expect the TCP mtu discovery protocol to work properly so there 301fc32c802SMatthew Dillon# should be no TCP fragments. 302fc32c802SMatthew Dillon# 303fc32c802SMatthew Dillonadd 03000 allow tcp from any to any http,https 304fc32c802SMatthew Dillonadd 03000 allow tcp from any to any 4000-65535,ssh,smtp,domain,ntalk 305fc32c802SMatthew Dillonadd 03000 allow tcp from any to any auth,pop3,ftp,ftp-data 306fc32c802SMatthew Dillon 307455c7374SMatthew Dillon# It is important to allow certain ICMP types through, here is a list 308455c7374SMatthew Dillon# of general ICMP types. Note that it is important to let ICMP type 3 309455c7374SMatthew Dillon# through. 310fc32c802SMatthew Dillon# 311fc32c802SMatthew Dillon# 0 Echo Reply 312455c7374SMatthew Dillon# 3 Destination Unreachable (used by TCP MTU discovery, aka 313455c7374SMatthew Dillon# packet-too-big) 314fc32c802SMatthew Dillon# 4 Source Quench (typically not allowed) 315fc32c802SMatthew Dillon# 5 Redirect (typically not allowed - can be dangerous!) 316fc32c802SMatthew Dillon# 8 Echo 317fc32c802SMatthew Dillon# 11 Time Exceeded 318fc32c802SMatthew Dillon# 12 Parameter Problem 319fc32c802SMatthew Dillon# 13 Timestamp 320fc32c802SMatthew Dillon# 14 Timestamp Reply 321fc32c802SMatthew Dillon# 322fc32c802SMatthew Dillon# Sometimes people need to allow ICMP REDIRECT packets, which is 3237c86a74bSMike Pritchard# type 5, but if you allow it make sure that your Internet router 324fc32c802SMatthew Dillon# disallows it. 325fc32c802SMatthew Dillon 326455c7374SMatthew Dillonadd 04000 allow icmp from any to any icmptypes 0,3,8,11,12,13,14 327fc32c802SMatthew Dillon 328fc32c802SMatthew Dillon# log any remaining fragments that get through. Might be useful, 329fc32c802SMatthew Dillon# otherwise don't bother. Have a final deny rule as a safety to 3307c86a74bSMike Pritchard# guarantee that your firewall is inclusive no matter how the kernel 331fc32c802SMatthew Dillon# is configured. 332fc32c802SMatthew Dillon# 333fc32c802SMatthew Dillonadd 05000 deny log ip from any to any frag 334fc32c802SMatthew Dillonadd 06000 deny all from any to any 335fc32c802SMatthew Dillon.Ed 336fc32c802SMatthew Dillon.Sh PORT BINDING INTERNAL AND EXTERNAL SERVICES 337fc32c802SMatthew DillonWe've mentioned multi-homing hosts and binding services to internal or 338fc32c802SMatthew Dillonexternal addresses but we haven't really explained it. When you have a 339fc32c802SMatthew Dillonhost with multiple IP addresses assigned to it, you can bind services run 340fc32c802SMatthew Dillonon that host to specific IPs or interfaces rather then all IPs. Take 341fc32c802SMatthew Dillonthe firewall machine for example: With three interfaces 342fc32c802SMatthew Dillonand two exposed IP addresses 343fc32c802SMatthew Dillonon one of those interfaces, the firewall machine is known by 5 different 344fc32c802SMatthew DillonIP addresses (10.0.0.1, 10.0.1.1, 10.0.2.1, 192.100.5.5, and say 345fc32c802SMatthew Dillon192.100.5.1). If the firewall is providing file sharing services to the 346fc32c802SMatthew Dillonwindows LAN segment (say it is LAN1), you can use samba's 'bind interfaces' 347fc32c802SMatthew Dillondirective to specifically bind it to just the LAN1 IP address. That 348fc32c802SMatthew Dillonway the file sharing services will not be made available to other LAN 349fc32c802SMatthew Dillonsegments. The same goes for NFS. If LAN2 has your UNIX engineering 350fc32c802SMatthew Dillonworkstations, you can tell nfsd to bind specifically to 10.0.2.1. You 351fc32c802SMatthew Dilloncan specify how to bind virtually every service on the machine and you 352fc32c802SMatthew Dilloncan use a light 353fc32c802SMatthew Dillon.Xr jail 8 354fc32c802SMatthew Dillonto indirectly bind services that do not otherwise give you the option. 355fc32c802SMatthew Dillon.Sh SEE ALSO 356fc32c802SMatthew Dillon.Xr ipnat 1 , 3575521ff5aSRuslan Ermilov.Xr dummynet 4 , 358fc32c802SMatthew Dillon.Xr ipnat 5 , 3595521ff5aSRuslan Ermilov.Xr rc.conf 5 , 3605521ff5aSRuslan Ermilov.Xr smb.conf 5 [ /usr/ports/net/samba ] , 3615521ff5aSRuslan Ermilov.Xr samba 7 [ /usr/ports/net/samba ] , 3625521ff5aSRuslan Ermilov.Xr config 8 , 3635521ff5aSRuslan Ermilov.Xr ipfw 8 , 364fc32c802SMatthew Dillon.Xr jail 8 , 365fc32c802SMatthew Dillon.Xr natd 8 , 3665521ff5aSRuslan Ermilov.Xr nfsd 8 367fc32c802SMatthew Dillon.Sh ADDITIONAL READING 368fc32c802SMatthew Dillon.Xr ipf 5 , 369fc32c802SMatthew Dillon.Xr ipf 8 , 370fc32c802SMatthew Dillon.Xr ipfstat 8 371fc32c802SMatthew Dillon.Sh HISTORY 372fc32c802SMatthew DillonThe 373fc32c802SMatthew Dillon.Nm 374fc32c802SMatthew Dillonmanual page was originally written by 375fc32c802SMatthew Dillon.An Matthew Dillon 376fc32c802SMatthew Dillonand first appeared 377fc32c802SMatthew Dillonin 378fc32c802SMatthew Dillon.Fx 4.3 , 379fc32c802SMatthew DillonMay 2001. 380