home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LINUX / HOWTO / mini / brfwall.txt < prev    next >
Text File  |  1997-07-07  |  19KB  |  546 lines

  1.  
  2.  
  3. Bridge+FIrewall mini-HOWTO, v1.1 by Peter Breuer            Dec. 23, 1996
  4. ptb@it.uc3m.es ptb@dit.upm.es ptb@eng.cam.ac.uk ptb@comlab.ox.ac.uk
  5. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6.  
  7. You should look at the original Bridging mini-HOWTO by Chris Cole for a
  8. different perspective on this.  He is "chris@polymer.uakron.edu".  The
  9. version of his HOWTO that I have based this document on (alternatively,
  10. ripped off) is 1.03 dated Aug 23 1996.
  11.  
  12. CONTENTS:
  13.  
  14. 1.0)   What and Why (and How?)
  15.  
  16.  
  17. BRIDGING
  18.  
  19. 1.1)   Software
  20. 1.2)   Prior Reading
  21. 1.3)   Boot configuration
  22. 1.4)   Kernel configuration
  23. 1.5)   Network addresses
  24. 1.6)   Network routing
  25. 1.7)   Card configuration
  26. 1.8)   Additional routing
  27. 1.9)   Bridge configuration
  28. 1.10)  Try it out
  29. 1.11)  Checks
  30.  
  31. FIREWALLING
  32.  
  33. 2.1)  Software and reading
  34. 2.2)  Preliminary checks
  35. 2.3)  Default rule
  36. 2.4)  Holes per address
  37. 2.5)  Holes per protocol
  38. 2.6)  Checks
  39.  
  40. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  41.  
  42. What:
  43.  
  44. A bridge is an intelligent connecting wire betwen two network cards. A
  45. firewall is an intelligent insulator.
  46.  
  47. Why:
  48.  
  49. You might want a bridge if you have several computers:
  50.  
  51.   a) to save the price of a new hub when you just happen to have an
  52.   extra ethernet card available.
  53.   
  54.   b) to save the bother of learning how to do IP-forwarding and
  55.   other tricks when you _have_ two cards in your computer.
  56.  
  57.   c) to avoid maintenance work in the future when things change 
  58.   around!
  59.  
  60. "Several computers" might be as few as three if those are routing or
  61. bridging or just moving around the room from time to time!  You also
  62. might want a bridge just for the fun of finding out what it does. b)
  63. was what I wanted a bridge for.
  64.  
  65. If you are really interested in a), you have to be one of the very few.
  66. Check the NET-2-HOWTO and the Serial-HOWTO for better tricks.
  67.  
  68.     sunsite.unc.edu:/pub/Linux/docs/HOWTO/NET-2-HOWTO
  69.     sunsite.unc.edu:/pub/Linux/docs/HOWTO/Serial-HOWTO
  70.  
  71. You want a firewall if
  72.  
  73.   a) you are trying to protect your network from external accesses, or
  74.  
  75.   b) you are trying to deny access to the world outside from your
  76.   network.
  77.  
  78. Curiously, I needed b) here too. Policy at my university presently is
  79. that we should not act as internet service providers to undergraduates.
  80.  
  81. How?
  82.  
  83. I started out bridging the two network cards in a firewalling machine
  84. and ended up firewalling without having cut the bridge. It seems to
  85. work and is more flexible than either configuration alone. I can take
  86. down the firewall and keep bridging or take down the bridge when I want
  87. to be more circumspect.
  88.  
  89. I would guess that the bridge code lives just above the physical device
  90. layer and the firewalling code lives one layer higher up, so that the
  91. bridging and firewalling configurations effectively act as though they
  92. are running connected together "in sequence" and not "in parallel"
  93. (ouch!).  Diagram:
  94.  
  95.  -> Bridge-in -> Firewall-in -> Kernel -> Firewall-out -> Bridge-out ->
  96.  
  97. There is no other way to explain how one machine can be a "conductor"
  98. and an "insulator" at the same time.  Anyway, it all seems to work
  99. together nicely.  Here is what you do ..
  100.   
  101. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  102. BRIDGING
  103.  
  104. 1.1)  Software
  105.  
  106. Get the bridge configuration utility from Alan Cox's home pages.  This
  107. is the same reference as in Chris' document.  I just didn't realize that
  108. it was an ftp and not an http URL ...
  109.  
  110.     ftp://shadow.cabi.net/pub/Linux/BRCFG.tgz
  111.  
  112.  
  113. 1.2)  Prior Reading.
  114.  
  115. Read the 'Multiple ethernet' HOWTO for some advice on getting more than
  116. one network card recognized and configured.
  117.  
  118.     sunsite.unc.edu:/pub/Linux/docs/HOWTO/mini/Multiple-Ethernet
  119.  
  120. Yet more details of the kind of boot magic that you may need are in the
  121. boot parameter howto:
  122.  
  123.     sunsite.unc.edu:/pub/Linux/docs/HOWTO/BootPrompt-HOWTO
  124.  
  125. You may be able to get away without the NET-2-HOWTO. It is a good long
  126. read and you will have to pick from it the details you need.
  127.  
  128.     sunsite.unc.edu:/pub/Linux/docs/HOWTO/NET-2-HOWTO
  129.  
  130.  
  131. 1.3) Boot configuration
  132.  
  133. The reading material above will tell you that you need to prepare the
  134. kernel to recognize a second ethernet device at boot up by adding this
  135. to your /etc/lilo.conf, and then re-run lilo:
  136.  
  137.     append = "ether=0,0,eth1"
  138.  
  139. Note the "eth1". "eth0" is the first card. "eth1" is the second card.
  140. You can always add the boot parameters in your response to the line that
  141. lilo offers you. This is for three cards:
  142.  
  143.     linux ether=0,0,eth1 ether=0,0,eth2
  144.  
  145. I use loadlin to boot my kernel from DOS:
  146.  
  147.         loadlin.exe c:\vmlinuz root=/dev/hda3 ro ether=0,0,eth1 ether=0,0,eth2
  148.  
  149.  
  150. Note that this trick makes the kernel probe at bootup.  That will not
  151. happen if you load the ethernet drivers as modules (for safety since the
  152. probe order can't be determined) so if you use modules you will have to
  153. add the appropriate IRQ and port parameters for the driver in your
  154. /etc/conf.modules.  I have at least
  155.  
  156.              alias eth0 3c509
  157.              alias eth1 de620
  158.              options 3c509 irq=5 io=0x210
  159.              options de620 irq=7 bnc=1
  160.  
  161. You can tell if you use modules by using "ps -aux" to see if kerneld is
  162. running and checking that there are .o files in a subdirectory of your
  163. /lib/modules directory.  You want the directory named with what uname -r
  164. tells you.  If you have kerneld and/or you have a foo.o then edit
  165. /etc/conf.modules and read the man page for depmod carefully.
  166.  
  167. Note also that until recently (kernel 2.0.25) the 3c509 driver could not be
  168. used for more than one card if used as a module.  I have seen a patch
  169. floating around that fixes the oversight.  It may be in the kernel when
  170. you read this.
  171.  
  172. 1.4) Kernel configuration
  173.  
  174. Recompile the kernel with bridging enabled.
  175.  
  176.  CONFIG_BRIDGE=y
  177.  
  178. I also compiled with firewalling and IP-forwarding and -masquerading and
  179. the rest enabled.  Only if you want firewalling too ...
  180.  
  181. CONFIG_FIREWALL=y
  182. CONFIG_NET_ALIAS=y
  183. CONFIG_INET=y
  184. CONFIG_IP_FORWARD=y
  185. CONFIG_IP_MULTICAST=y
  186. CONFIG_IP_FIREWALL=y
  187. CONFIG_IP_FIREWALL_VERBOSE=y
  188. CONFIG_IP_MASQUERADE=y
  189.  
  190. You don't need all of this. What you do need apart from this is the
  191. standard net configuration:
  192.  
  193. CONFIG_NET=y
  194.  
  195. and I do not think you need worry about any of the other networking
  196. options.  I have any options that I did not actually compile into
  197. the kernel available through kernel modules that I can add in later.
  198.  
  199.  
  200. Install the new kernel in place, rerun lilo and reboot with the new kernel.
  201. Nothing should have changed at this point!
  202.  
  203. 1.5)  Network addresses
  204.  
  205. Chris says that a bridge should not have an IP address but that is not
  206. the setup to be described here.
  207.  
  208. You are going to want to use the machine for connecting to the net so
  209. you need an address and you need to make sure that you have the loopback
  210. device configured in the normal way so that your software can talk to
  211. the places they expect to be able to talk to. If loopback is down the name
  212. resolver or other net sevices might fail. See the NET-2-HOWTO, but your
  213. standard configuration should already have done this bit:
  214.  
  215.    ifconfig lo 127.0.0.1
  216.    route add -net 127.0.0.0
  217.  
  218. You will have to give addresses to both your network cards. I altered
  219. the /etc/rc.d/rc.inet1 file in my slackware (3.x) to setup my two cards
  220. and you should also essentially just look for your net configuration
  221. file and double the number of instructions in it.  Suppose that you
  222. already have an address at
  223.  
  224.             192.168.2.100
  225.  
  226. (that is the private net reserved address space, but never mind - it
  227. won't hurt anybody if you use this address by mistake) then you probably
  228. already have a line like
  229.  
  230.   ifconfig eth0 192.168.2.100 netmask 255.255.255.0 metric 1
  231.  
  232. in your configuration.  The first thing you are going to probably want
  233. to do is cut the address space reached by this card in half so that you
  234. can eventually bridge the two halves.  So add a line which reduces the
  235. mask to address a smaller number of machines:
  236.  
  237.   ifconfig eth0 netmask 255.255.255.128
  238.  
  239. Try it too.  That restricts the card to at most the address space
  240. between .0 and .127. 
  241.  
  242. Now you can set your second card up in the other half of the local
  243. address space.  Make sure that nobody already has the address.  For
  244. symmetry I set it at 228=128+100