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 . 25fc32c802SMatthew DillonThis feature can be useful when you need to guarentee a certain 26fc32c802SMatthew Dillonamount of bandwidth for a critical purpose. For example, if you 27fc32c802SMatthew Dillonare 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 63fc32c802SMatthew DillonTo use the ip firewall features of 64fc32c802SMatthew Dillon.Fx 65fc32c802SMatthew Dillonyou must create a custom kernel with the 66fc32c802SMatthew Dillon.Sy IPFIREWALL 67fc32c802SMatthew Dillonoption set. The kernel defaults its firewall to deny all 68fc32c802SMatthew Dillonpackets by default, which means that if you do not load in 69fc32c802SMatthew Dillona permissive ruleset via 70fc32c802SMatthew Dillon.Em /etc/rc.conf , 71fc32c802SMatthew Dillonrebooting into your new kernel will take the network offline 72fc32c802SMatthew Dillonand will prevent you from being able to access it if you 73fc32c802SMatthew Dillonare not sitting at the console. It is also quite common to 74fc32c802SMatthew Dillonupdate a kernel to a new release and reboot before updating 75fc32c802SMatthew Dillonthe binaries. This can result in an incompatibility between 76fc32c802SMatthew Dillonthe 77fc32c802SMatthew Dillon.Xr ipfw 8 78fc32c802SMatthew Dillonprogram and the kernel which prevents it from running in the 79fc32c802SMatthew Dillonboot sequence, also resulting in an inaccessible machine. 80fc32c802SMatthew DillonBecause of these problems the 81fc32c802SMatthew Dillon.Sy IPFIREWALL_DEFAULT_TO_ACCEPT 82fc32c802SMatthew Dillonkernel option is also available which changes the default firewall 83fc32c802SMatthew Dillonto pass through all packets. Note, however, that this is a very 84fc32c802SMatthew Dillondangerous option to set because it means your firewall is disabled 85fc32c802SMatthew Dillonduring booting. You should use this option while getting up to 86fc32c802SMatthew Dillonspeed with 87fc32c802SMatthew Dillon.Fx 88fc32c802SMatthew Dillonfirewalling, but get rid of it once you understand how it all works 89fc32c802SMatthew Dillonto close the loophole. There is a third option called 90fc32c802SMatthew Dillon.Sy IPDIVERT 91fc32c802SMatthew Dillonwhich allows you to use the firewall to divert packets to a user program 92fc32c802SMatthew Dillonand is necessary if you wish to use 93fc32c802SMatthew Dillon.Xr natd 8 94fc32c802SMatthew Dillonto give private internal networks access to the outside world. 95fc32c802SMatthew DillonIf you want to be able to limit the bandwidth used by certain types of 96fc32c802SMatthew Dillontraffic, the 97fc32c802SMatthew Dillon.Sy DUMMYNET 98fc32c802SMatthew Dillonoption must be used to enable 99fc32c802SMatthew Dillon.Em ipfw pipe 100fc32c802SMatthew Dillonrules. 101fc32c802SMatthew Dillon.Sh SAMPLE IPFW-BASED FIREWALL 102fc32c802SMatthew DillonHere is an example ipfw-based firewall taken from a machine with three 103fc32c802SMatthew Dilloninterface cards. fxp0 is connected to the 'exposed' LAN. Machines 104fc32c802SMatthew Dillonon this LAN are dual-homed with both internal 10. IP addresses and 105fc32c802SMatthew Dilloninternet-routed IP addresses. In our example, 192.100.5.x represents 106fc32c802SMatthew Dillonthe internet-routed IP block while 10.x.x.x represents the internal 107fc32c802SMatthew Dillonnetworks. While it isn't relevant to the example, 10.0.1.x is 108fc32c802SMatthew Dillonassigned as the internal address block for the LAN on fxp0, 10.0.2.x 109fc32c802SMatthew Dillonfor the LAN on fxp1, and 10.0.3.x for the LAN on fxp2. 110fc32c802SMatthew Dillon.Pp 111fc32c802SMatthew DillonIn this example we want to isolate all three LANs from the internet 112fc32c802SMatthew Dillonas well as isolate them from each other, and we want to give all 113fc32c802SMatthew Dilloninternal addresses access to the internet through a NAT gateway running 114fc32c802SMatthew Dillonon this machine. To make the NAT gateway work, the firewall machine 115fc32c802SMatthew Dillonis given two internet-exposed addresses on fxp0 in addition to an 116fc32c802SMatthew Dilloninternal 10. address on fxp0: one exposed address (not shown) 117fc32c802SMatthew Dillonrepresents the machine's official address, and the second exposed 118fc32c802SMatthew Dillonaddress (192.100.5.5 in our example) represents the NAT gateway 119fc32c802SMatthew Dillonrendezvous IP. We make the example more complex by giving the machines 120fc32c802SMatthew Dillonon the exposed LAN internal 10.0.0.x addresses as well as exposed 121fc32c802SMatthew Dillonaddresses. The idea here is that you can bind internal services 122fc32c802SMatthew Dillonto internal addresses even on exposed machines and still protect 123fc32c802SMatthew Dillonthose services from the internet. The only services you run on 124fc32c802SMatthew Dillonexposed IP addresses would be the ones you wish to expose to the 125fc32c802SMatthew Dilloninternet. 126fc32c802SMatthew Dillon.Pp 127fc32c802SMatthew DillonIt is important to note that the 10.0.0.x network in our example 128fc32c802SMatthew Dillonis not protected by our firewall. You must make sure that your 129fc32c802SMatthew Dilloninternet router protects this network from outside spoofing. 130fc32c802SMatthew DillonAlso, in our example, we pretty much give the exposed hosts free 131fc32c802SMatthew Dillonreign on our internal network when operating services through 132fc32c802SMatthew Dilloninternal IP addresses (10.0.0.x). This is somewhat of security 133fc32c802SMatthew Dillonrisk... what if an exposed host is compromised? To remove the 134fc32c802SMatthew Dillonrisk and force everything coming in via LAN0 to go through 135fc32c802SMatthew Dillonthe firewall, remove rules 01010 and 01011. 136fc32c802SMatthew Dillon.Pp 137fc32c802SMatthew DillonFinally, note that the use of internal addresses represents a 138fc32c802SMatthew Dillonbig piece of our firewall protection mechanism. With proper 139fc32c802SMatthew Dillonspoofing safeguards in place, nothing outside can directly 140fc32c802SMatthew Dillonaccess an internal (LAN1 or LAN2) host. 141fc32c802SMatthew Dillon.Bd -literal 142fc32c802SMatthew Dillon# /etc/rc.conf 143fc32c802SMatthew Dillon# 144fc32c802SMatthew Dillonfirewall_enable="YES" 145fc32c802SMatthew Dillonfirewall_type="/etc/ipfw.conf" 146fc32c802SMatthew Dillon 147fc32c802SMatthew Dillon# temporary port binding range let 148fc32c802SMatthew Dillon# through the firewall. 149fc32c802SMatthew Dillon# 150fc32c802SMatthew Dillon# NOTE: heavily loaded services running through the firewall may require 151fc32c802SMatthew Dillon# a larger port range for local-size binding. 4000-10000 or 4000-30000 152fc32c802SMatthew Dillon# might be a better choice. 153fc32c802SMatthew Dillonip_portrange_first=4000 154fc32c802SMatthew Dillonip_portrange_last=5000 155fc32c802SMatthew Dillon... 156fc32c802SMatthew Dillon.Ed 157fc32c802SMatthew Dillon.Pp 158fc32c802SMatthew Dillon.Bd -literal 159fc32c802SMatthew Dillon# /etc/ipfw.conf 160fc32c802SMatthew Dillon# 161fc32c802SMatthew Dillon# FIREWALL: the firewall machine / nat gateway 162fc32c802SMatthew Dillon# LAN0 10.0.0.X and 192.100.5.X (dual homed) 163fc32c802SMatthew Dillon# LAN1 10.0.1.X 164fc32c802SMatthew Dillon# LAN2 10.0.2.X 165fc32c802SMatthew Dillon# sw: ethernet switch (unmanaged) 166fc32c802SMatthew Dillon# 167fc32c802SMatthew Dillon# 192.100.5.x represents IP addresses exposed to the internet 168fc32c802SMatthew Dillon# (i.e. internet routeable). 10.x.x.x represent internal IPs 169fc32c802SMatthew Dillon# (not exposed) 170fc32c802SMatthew Dillon# 171fc32c802SMatthew Dillon# [LAN1] 172fc32c802SMatthew Dillon# ^ 173fc32c802SMatthew Dillon# | 174fc32c802SMatthew Dillon# FIREWALL -->[LAN2] 175fc32c802SMatthew Dillon# | 176fc32c802SMatthew Dillon# [LAN0] 177fc32c802SMatthew Dillon# | 178fc32c802SMatthew Dillon# +--> exposed host A 179fc32c802SMatthew Dillon# +--> exposed host B 180fc32c802SMatthew Dillon# +--> exposed host C 181fc32c802SMatthew Dillon# | 182fc32c802SMatthew Dillon# INTERNET (secondary firewall) 183fc32c802SMatthew Dillon# ROUTER 184fc32c802SMatthew Dillon# | 185fc32c802SMatthew Dillon# [internet] 186fc32c802SMatthew Dillon# 187fc32c802SMatthew Dillon# NOT SHOWN: The INTERNET ROUTER must contain rules to disallow 188fc32c802SMatthew Dillon# all packets with source IP addresses in the 10. block in order 189fc32c802SMatthew Dillon# to protect the dual-homed 10.0.0.x block. Exposed hosts are 190fc32c802SMatthew Dillon# not otherwise protected in this example - they should only bind 191fc32c802SMatthew Dillon# exposed services to exposed IPs but can safely bind internal 192fc32c802SMatthew Dillon# services to internal IPs. 193fc32c802SMatthew Dillon# 194fc32c802SMatthew Dillon# The NAT gateway works by taking packets sent from internal 195fc32c802SMatthew Dillon# IP addresses to external IP addresses and routing them to natd, which 196fc32c802SMatthew Dillon# is listening on port 8668. This is handled by rule 00300. Data coming 197fc32c802SMatthew Dillon# back to natd from the outside world must also be routed to natd using 198fc32c802SMatthew Dillon# rule 00301. To make the example interesting, we note that we do 199fc32c802SMatthew Dillon# NOT have to run internal requests to exposed hosts through natd 200fc32c802SMatthew Dillon# (rule 00290) because those exposed hosts know about our 201fc32c802SMatthew Dillon# 10. network. This can reduce the load on natd. Also note that we 202fc32c802SMatthew Dillon# of course do not have to route internal<->internal traffic through 203fc32c802SMatthew Dillon# natd since those hosts know how to route our 10. internal network. 204fc32c802SMatthew Dillon# The natd command we run from /etc/rc.local is shown below. See 205fc32c802SMatthew Dillon# also the in-kernel version of natd, ipnat. 206fc32c802SMatthew Dillon# 207fc32c802SMatthew Dillon# natd -s -u -a 208.161.114.67 208fc32c802SMatthew Dillon# 209fc32c802SMatthew Dillon# 210fc32c802SMatthew Dillonadd 00290 skipto 1000 ip from 10.0.0.0/8 to 192.100.5.0/24 211fc32c802SMatthew Dillonadd 00300 divert 8668 ip from 10.0.0.0/8 to not 10.0.0.0/8 212fc32c802SMatthew Dillonadd 00301 divert 8668 ip from not 10.0.0.0/8 to 192.100.5.5 213fc32c802SMatthew Dillon 214fc32c802SMatthew Dillon# Short cut the rules to avoid running high bandwidths through 215fc32c802SMatthew Dillon# the entire rule set. Allow established tcp connections through, 216fc32c802SMatthew Dillon# and shortcut all outgoing packets under the assumption that 217fc32c802SMatthew Dillon# we need only firewall incoming packets. 218fc32c802SMatthew Dillon# 219fc32c802SMatthew Dillon# Allowing established tcp connections through creates a small 220fc32c802SMatthew Dillon# hole but may be necessary to avoid overloading your firewall. 221fc32c802SMatthew Dillon# If you are worried, you can move the rule to after the spoof 222fc32c802SMatthew Dillon# checks. 223fc32c802SMatthew Dillon# 224fc32c802SMatthew Dillonadd 01000 allow tcp from any to any established 225fc32c802SMatthew Dillonadd 01001 allow all from any to any out via fxp0 226fc32c802SMatthew Dillonadd 01001 allow all from any to any out via fxp1 227fc32c802SMatthew Dillonadd 01001 allow all from any to any out via fxp2 228fc32c802SMatthew Dillon 229fc32c802SMatthew Dillon# Spoof protection. This depends on how well you trust your 230fc32c802SMatthew Dillon# internal networks. Packets received via fxp1 MUST come from 231fc32c802SMatthew Dillon# 10.0.1.x. Packets received via fxp2 MUST come from 10.0.2.x. 232fc32c802SMatthew Dillon# Packets received via fxp0 cannot come from the LAN1 or LAN2 233fc32c802SMatthew Dillon# blocks. We can't protect 10.0.0.x here, the internet router 234fc32c802SMatthew Dillon# must do that for us. 235fc32c802SMatthew Dillon# 236fc32c802SMatthew Dillonadd 01500 deny all from not 10.0.1.0/24 in via fxp1 237fc32c802SMatthew Dillonadd 01500 deny all from not 10.0.2.0/24 in via fxp2 238fc32c802SMatthew Dillonadd 01501 deny all from 10.0.1.0/24 in via fxp0 239fc32c802SMatthew Dillonadd 01501 deny all from 10.0.2.0/24 in via fxp0 240fc32c802SMatthew Dillon 241fc32c802SMatthew Dillon# In this example rule set there are no restrictions between 242fc32c802SMatthew Dillon# internal hosts, even those on the exposed LAN (as long as 243fc32c802SMatthew Dillon# they use an internal IP address). This represents a 244fc32c802SMatthew Dillon# potential security hole (what if an exposed host is 245fc32c802SMatthew Dillon# compromised?). If you want full restrictions to apply 246fc32c802SMatthew Dillon# between the three LANs, firewalling them off from each 247fc32c802SMatthew Dillon# other for added security, remove these two rules. 248fc32c802SMatthew Dillon# 249fc32c802SMatthew Dillon# If you want to isolate LAN1 and LAN2, but still want 250fc32c802SMatthew Dillon# to give exposed hosts free reign with each other, get 251fc32c802SMatthew Dillon# rid of rule 01010 and keep rule 01011. 252fc32c802SMatthew Dillon# 253fc32c802SMatthew Dillon# (commented out, uncomment for less restrictive firewall) 254fc32c802SMatthew Dillon#add 01010 allow all from 10.0.0.0/8 to 10.0.0.0/8 255fc32c802SMatthew Dillon#add 01011 allow all from 192.100.5.0/24 to 192.100.5.0/24 256fc32c802SMatthew Dillon# 257fc32c802SMatthew Dillon 258fc32c802SMatthew Dillon# SPECIFIC SERVICES ALLOWED FROM SPECIFIC LANS 259fc32c802SMatthew Dillon# 260fc32c802SMatthew Dillon# If using a more restrictive firewall, allow specific LANs 261fc32c802SMatthew Dillon# access to specific services running on the firewall itself. 262fc32c802SMatthew Dillon# In this case we assume LAN1 needs access to filesharing running 263fc32c802SMatthew Dillon# on the firewall. If using a less restrictive firewall 264fc32c802SMatthew Dillon# (allowing rule 01010), you don't need these rules. 265fc32c802SMatthew Dillon# 266fc32c802SMatthew Dillonadd 01012 allow tcp from 10.0.1.0/8 to 10.0.1.1 139 267fc32c802SMatthew Dillonadd 01012 allow udp from 10.0.1.0/8 to 10.0.1.1 137,138 268fc32c802SMatthew Dillon 269fc32c802SMatthew Dillon# GENERAL SERVICES ALLOWED TO CROSS INTERNAL AND EXPOSED LANS 270fc32c802SMatthew Dillon# 271fc32c802SMatthew Dillon# We allow specific UDP services through: DNS lookups, ntalk, and ntp. 272fc32c802SMatthew Dillon# Note that internal services are protected by virtue of having 273fc32c802SMatthew Dillon# spoof-proof internal IP addresses (10. net), so these rules 274fc32c802SMatthew Dillon# really only apply to services bound to exposed IPs. We have 275fc32c802SMatthew Dillon# to allow UDP fragments or larger fragmented UDP packets will 276fc32c802SMatthew Dillon# not survive the firewall. 277fc32c802SMatthew Dillon# 278fc32c802SMatthew Dillon# If we want to expose high-numbered temporary service ports 279fc32c802SMatthew Dillon# for things like DNS lookup responses we can use a port range, 280fc32c802SMatthew Dillon# in this example 4000-65535, and we set to /etc/rc.conf variables 281fc32c802SMatthew Dillon# on all exposed machines to make sure they bind temporary ports 282fc32c802SMatthew Dillon# to the exposed port range (see rc.conf example above) 283fc32c802SMatthew Dillon# 284fc32c802SMatthew Dillonadd 02000 allow udp from any to any 4000-65535,domain,ntalk,ntp 285fc32c802SMatthew Dillonadd 02500 allow udp from any to any frag 286fc32c802SMatthew Dillon 287fc32c802SMatthew Dillon# Allow similar services for TCP. Again, these only apply to 288fc32c802SMatthew Dillon# services bound to exposed addresses. NOTE: we allow 'auth' 289fc32c802SMatthew Dillon# through but do not actually run an identd server on any exposed 290fc32c802SMatthew Dillon# port. This allows the machine being authed to respond with a 291fc32c802SMatthew Dillon# TCP RESET. Throwing the packet away would result in delays 292fc32c802SMatthew Dillon# when connecting to remote services that do reverse ident lookups. 293fc32c802SMatthew Dillon# 294fc32c802SMatthew Dillon# Note that we do not allow tcp fragments through, and that we do 295fc32c802SMatthew Dillon# not allow fragments in general (except for UDP fragments). We 296fc32c802SMatthew Dillon# expect the TCP mtu discovery protocol to work properly so there 297fc32c802SMatthew Dillon# should be no TCP fragments. 298fc32c802SMatthew Dillon# 299fc32c802SMatthew Dillonadd 03000 allow tcp from any to any http,https 300fc32c802SMatthew Dillonadd 03000 allow tcp from any to any 4000-65535,ssh,smtp,domain,ntalk 301fc32c802SMatthew Dillonadd 03000 allow tcp from any to any auth,pop3,ftp,ftp-data 302fc32c802SMatthew Dillon 303fc32c802SMatthew Dillon# It is important to allow certain ICMP types through: 304fc32c802SMatthew Dillon# 305fc32c802SMatthew Dillon# 0 Echo Reply 306fc32c802SMatthew Dillon# 3 Destination Unreachable 307fc32c802SMatthew Dillon# 4 Source Quench (typically not allowed) 308fc32c802SMatthew Dillon# 5 Redirect (typically not allowed - can be dangerous!) 309fc32c802SMatthew Dillon# 8 Echo 310fc32c802SMatthew Dillon# 11 Time Exceeded 311fc32c802SMatthew Dillon# 12 Parameter Problem 312fc32c802SMatthew Dillon# 13 Timestamp 313fc32c802SMatthew Dillon# 14 Timestamp Reply 314fc32c802SMatthew Dillon# 315fc32c802SMatthew Dillon# Sometimes people need to allow ICMP REDIRECT packets, which is 316fc32c802SMatthew Dillon# type 5, but if you allow it make sure that your internet router 317fc32c802SMatthew Dillon# disallows it. 318fc32c802SMatthew Dillon 319fc32c802SMatthew Dillonadd 04000 allow icmp from any to any icmptypes 0,5,8,11,12,13,14 320fc32c802SMatthew Dillon 321fc32c802SMatthew Dillon# log any remaining fragments that get through. Might be useful, 322fc32c802SMatthew Dillon# otherwise don't bother. Have a final deny rule as a safety to 323fc32c802SMatthew Dillon# guarentee that your firewall is inclusive no matter how the kernel 324fc32c802SMatthew Dillon# is configured. 325fc32c802SMatthew Dillon# 326fc32c802SMatthew Dillonadd 05000 deny log ip from any to any frag 327fc32c802SMatthew Dillonadd 06000 deny all from any to any 328fc32c802SMatthew Dillon.Ed 329fc32c802SMatthew Dillon.Sh PORT BINDING INTERNAL AND EXTERNAL SERVICES 330fc32c802SMatthew DillonWe've mentioned multi-homing hosts and binding services to internal or 331fc32c802SMatthew Dillonexternal addresses but we haven't really explained it. When you have a 332fc32c802SMatthew Dillonhost with multiple IP addresses assigned to it, you can bind services run 333fc32c802SMatthew Dillonon that host to specific IPs or interfaces rather then all IPs. Take 334fc32c802SMatthew Dillonthe firewall machine for example: With three interfaces 335fc32c802SMatthew Dillonand two exposed IP addresses 336fc32c802SMatthew Dillonon one of those interfaces, the firewall machine is known by 5 different 337fc32c802SMatthew DillonIP addresses (10.0.0.1, 10.0.1.1, 10.0.2.1, 192.100.5.5, and say 338fc32c802SMatthew Dillon192.100.5.1). If the firewall is providing file sharing services to the 339fc32c802SMatthew Dillonwindows LAN segment (say it is LAN1), you can use samba's 'bind interfaces' 340fc32c802SMatthew Dillondirective to specifically bind it to just the LAN1 IP address. That 341fc32c802SMatthew Dillonway the file sharing services will not be made available to other LAN 342fc32c802SMatthew Dillonsegments. The same goes for NFS. If LAN2 has your UNIX engineering 343fc32c802SMatthew Dillonworkstations, you can tell nfsd to bind specifically to 10.0.2.1. You 344fc32c802SMatthew Dilloncan specify how to bind virtually every service on the machine and you 345fc32c802SMatthew Dilloncan use a light 346fc32c802SMatthew Dillon.Xr jail 8 347fc32c802SMatthew Dillonto indirectly bind services that do not otherwise give you the option. 348fc32c802SMatthew Dillon.Sh SEE ALSO 349fc32c802SMatthew Dillon.Xr ipnat 1 , 3505521ff5aSRuslan Ermilov.Xr dummynet 4 , 351fc32c802SMatthew Dillon.Xr ipnat 5 , 3525521ff5aSRuslan Ermilov.Xr rc.conf 5 , 3535521ff5aSRuslan Ermilov.Xr smb.conf 5 [ /usr/ports/net/samba ] , 3545521ff5aSRuslan Ermilov.Xr samba 7 [ /usr/ports/net/samba ] , 3555521ff5aSRuslan Ermilov.Xr config 8 , 3565521ff5aSRuslan Ermilov.Xr ipfw 8 , 357fc32c802SMatthew Dillon.Xr jail 8 , 358fc32c802SMatthew Dillon.Xr natd 8 , 3595521ff5aSRuslan Ermilov.Xr nfsd 8 360fc32c802SMatthew Dillon.Sh ADDITIONAL READING 361fc32c802SMatthew Dillon.Xr ipf 5 , 362fc32c802SMatthew Dillon.Xr ipf 8 , 363fc32c802SMatthew Dillon.Xr ipfstat 8 364fc32c802SMatthew Dillon.Sh HISTORY 365fc32c802SMatthew DillonThe 366fc32c802SMatthew Dillon.Nm 367fc32c802SMatthew Dillonmanual page was originally written by 368fc32c802SMatthew Dillon.An Matthew Dillon 369fc32c802SMatthew Dillonand first appeared 370fc32c802SMatthew Dillonin 371fc32c802SMatthew Dillon.Fx 4.3 , 372fc32c802SMatthew DillonMay 2001. 373