home *** CD-ROM | disk | FTP | other *** search
/ Hackers Toolkit v2.0 / Hackers_Toolkit_v2.0.iso / HTML / archive / Unix / HOWTOs / FIREWALL < prev    next >
Text File  |  1999-11-04  |  54KB  |  1,327 lines

  1.   Firewalling and Proxy Server HOWTO
  2.   Mark Grennan, markg@netplus.net
  3.   v0.4, 8 November 1996
  4.  
  5.   This document is designed to teach the basics of firewall systems and
  6.   give you some detail on setting up both a filtering and proxy firewall
  7.   on a Linux based PC. An HTML version of this document is available at
  8.   http://okcforum.org/~markg/Firewall-HOWTO.html
  9.  
  10.   1.  Introduction
  11.  
  12.   This original Firewall-HOWTO was written by David Rudder,
  13.   drig@execpc.com.  I'd like to thank him for allowing me to update his
  14.   work.
  15.  
  16.   Firewalls have gained great fame recently as the ultimate in Internet
  17.   Security.  Like most things that gain fame, with that fame has come
  18.   misunderstanding.  This HOWTO will go over the basics of what a
  19.   firewall is, how to set one up, what proxy servers are, how to set up
  20.   proxy servers, and the applications of this technology outside of the
  21.   security realm.
  22.  
  23.   1.1.  Feedback
  24.  
  25.   Any feedback is very welcome. PLEASE REPORT ANY INACCURACIES IN THIS
  26.   PAPER!!!  I am human, and prone to making mistakes.  If you find any,
  27.   fixing them is of my highest interest.  I will try to answer all e-
  28.   mail, but I am busy, so don't get insulted if I don't.
  29.  
  30.   My email address is markg@netplus.net
  31.  
  32.   1.2.  Disclaimer
  33.  
  34.   I AM NOT RESPONSIBLE FOR ANY DAMAGES INCURRED DUE TO ACTIONS TAKEN
  35.   BASED ON THIS DOCUMENT. This document is meant as an introduction to
  36.   how firewalls and proxy servers work. I am not, nor do I pretend to
  37.   be, a security expert.  I am just some guy who has read to much and
  38.   likes computers more than most people. Please, I am writing this to
  39.   help get people acquainted with this subject, and I am not ready to
  40.   stake my life on the accuracy of what is in here.
  41.  
  42.   1.3.  Copyright
  43.  
  44.   Unless otherwise stated, Linux HOWTO documents are copyrighted by
  45.   their respective authors. Linux HOWTO documents may be reproduced and
  46.   distributed in whole or in part, in any medium physical or electronic,
  47.   as long as this copyright notice is retained on all copies. Commercial
  48.   redistribution is allowed and encouraged; however, the author would
  49.   like to be notified of any such distributions.
  50.  
  51.   All translations, derivative works, or aggregate works incorporating
  52.   any Linux HOWTO documents must be covered under this copyright notice.
  53.   That is, you may not produce a derivative work from a HOWTO and impose
  54.   additional restrictions on its distribution. Exceptions to these rules
  55.   may be granted under certain conditions; please contact the Linux
  56.   HOWTO coordinator.
  57.  
  58.   In short, we wish to promote dissemination of this information through
  59.   as many channels as possible. However, we do wish to retain copyright
  60.   on the HOWTO documents, and would like to be notified of any plans to
  61.   redistribute the HOWTOs.
  62.  
  63.   If you have any questions, please contact Mark Grennan at
  64.   <markg@netplus.net>.
  65.  
  66.   1.4.  My Reasons for Writing This
  67.  
  68.   Even though there were a lot of discussions on comp.os.linux.* over
  69.   the past year about firewalling, I found it difficult to find the
  70.   information I needed to setup a firewall.  The original version of
  71.   this HOWTO was helpful but still lacking.  I hope this beefed up
  72.   version of David Rudder's Firewall HOWTO will give everyone the
  73.   information they need to create a functioning firewall in hours, not
  74.   weeks.
  75.  
  76.   I also feel I should return something to the Linux community.
  77.  
  78.   1.5.  TODO
  79.  
  80.   ╖  Give some instructions on how to setup the clients
  81.  
  82.   ╖  Find a good UDP proxy server that works with Linux
  83.  
  84.   1.6.  Further Readings
  85.  
  86.   ╖  The NET-2 HOWTO
  87.  
  88.   ╖  The Ethernet HOWTO
  89.  
  90.   ╖  The Multiple Ethernet Mini HOWTO
  91.  
  92.   ╖  Networking with Linux
  93.  
  94.   ╖  The PPP HOWTO
  95.  
  96.   ╖  TCP/IP Network Administrator's Guide by O'Reilly and Associates
  97.  
  98.   ╖  The Documentation for the TIS Firewall Toolkit
  99.  
  100.   Trusted Information System's (TIS) web site has a great collection of
  101.   documentation on firewalls and related meterial. http://www.tis.com/
  102.  
  103.   Also, I am working on a security project called I am calling Secure
  104.   Linux. On the Secure Linux web site I am gathering all the
  105.   information, documemtation and programs you need to create a trusted
  106.   Linux system. Email me if you would like information.
  107.  
  108.   2.  Understanding Firewalls
  109.  
  110.   A firewall is a term used for a part of a car.  In cars, firewalls are
  111.   physical objects that separate the engine from the passengers.  They
  112.   are meant to protect the passenger in case the car's engine catches
  113.   fire while still providing the driver access to the engine's controls.
  114.  
  115.   A firewall in computers is a device that protects a private network
  116.   from the public part (the internet as a whole).
  117.  
  118.   The firewall computer, from now on named "firewall", can reach both
  119.   the protected network and the internet.  The protected network can't
  120.   reach the internet, and the internet can not reach the protected
  121.   network.
  122.  
  123.   For someone to reach the internet from inside the protected network,
  124.   they must telnet to firewall, and use the internet from there.
  125.  
  126.   The simplest form of a firewall is a dual homed system. (a system with
  127.   two network connections) If you can TRUST ALL your users, you can
  128.   simple setup a Linux (compile it with IP forwarding/gatewaying turned
  129.   OFF!) and give everyone accounts on it. The can then login to this
  130.   system and telnet, FTP, read mail, and use any other service you
  131.   provided. With this setup, the only computer on your private network
  132.   that knows anything about the outside world is the firewall. The other
  133.   system on your protected network dont even need a default route.
  134.  
  135.   This needs re-stating. For the above firewall to work  YOU MUST TRUST
  136.   ALL YOUR USERS!  I don't recommend it.
  137.  
  138.   2.1.  Drawbacks with Firewalls
  139.  
  140.   The problem with filtering firewalls are they inhibit the access to
  141.   your network from  the internet.  Only services on systems that have
  142.   pass filters can be accessed. With a proxy server users can login to
  143.   the firewall  and then access any system within the private network
  144.   they have access to.
  145.  
  146.   Also, new types of network clients and servers a coming out almost
  147.   daily. When they do you must find a new way to allow controled access
  148.   before these services can be used.
  149.  
  150.   2.2.  Types of Firewalls
  151.  
  152.   There are two types of firewalls.
  153.  
  154.   1. IP or Filtering Firewalls - that block all but selected network
  155.      traffic.
  156.  
  157.   2. Proxy Servers - that make the network connections for you.
  158.  
  159.   2.2.1.  IP Filtering Firewalls
  160.  
  161.   An IP filtering firewall works at the packet level. It is designed to
  162.   control the flow of packets based the source, destination, port and
  163.   packet type information contained in each packet.
  164.  
  165.   This type of firewall is very secure but lacks any sort of useful
  166.   logging. It can block people from accessing private system but it will
  167.   not tell you who accessed your public systems or who accessed the
  168.   internet from the inside.
  169.  
  170.   Filtering firewalls are absolute filters. Even if you want to give
  171.   someone on outside access to your private servers you can not without
  172.   giving everyone access to the servers.
  173.  
  174.   Linux has included packet filtering software in the kernel starting
  175.   with version 1.3.x.
  176.  
  177.   2.2.2.  Proxy Servers
  178.  
  179.   Proxy servers allow indirect internet access through the firewall. The
  180.   best example of how this works is a person telneting to a system and
  181.   then telneting from there to another. Only with a proxy server the
  182.   process is automatic. When you connect to a proxy server with your
  183.   client software, the proxy server starts it's client (proxy) software
  184.   and passes you the data.
  185.  
  186.   Because proxy servers are duplicating all the communications they can
  187.   log every thing they do.
  188.  
  189.   The great thing about proxy servers is that they are completely
  190.   secure, when configured correctly.  They will not allow someone in
  191.   through them. There are no direct IP routes.
  192.  
  193.   3.  Setting up the Firewall
  194.  
  195.   3.1.  Hardware requirements
  196.  
  197.   For our example, the computer is a 486-DX66 with 16 meg of memory and
  198.   a 500 meg Linux partition. This system has two network cards one
  199.   connected to our private LAN and the other connected to the a lan we
  200.   will call the de-militarized zone (DMZ). The DMZ has a router
  201.   connected to it with a connection to the internet.
  202.  
  203.   This is a pretty standard setup for a business. You could use one
  204.   network card and a modem with PPP to the internet. The point is, the
  205.   firewall must have two IP network numbers.
  206.  
  207.   I know a lot of people have small LANs at home with two or three
  208.   computers on them. Something you might consider is putting all your
  209.   modems in on Linux box (maybe an old 386) and connecting all of them
  210.   to the internet with load balancing.  With this setup when only one
  211.   person was pulling data they would get both modems doubling the
  212.   throughput. :-)
  213.  
  214.   4.  Firewalling Software
  215.  
  216.   4.1.  Available packages
  217.  
  218.   If all you want is a filtering firewall, you only need Linux and the
  219.   basic networking packages. One package that might not come with your
  220.   distribution is the IP Firewall Administration tool.
  221.  
  222.   (IPFWADM) Comes from http://www.xos.nl/linux/ipfwadm/
  223.  
  224.   If you want to setup a poxy server you will need one of these
  225.   packages.
  226.  
  227.   1. SOCKS
  228.  
  229.   2. TIS Firewall Toolkit (FWTK)
  230.  
  231.   4.2.  The TIS Firewall Toolkit vs SOCKS
  232.  
  233.   Trusted Information System (http://www.tis.com) has put out a
  234.   collection of programs designed to facilitate firewalling.  The
  235.   programs do basically the same thing as the SOCKS package, but with a
  236.   different design strategy.  Where Socks has one program that covers
  237.   all Internet transactions, TIS has provided one program for each
  238.   utility that wishes to use the firewall.
  239.  
  240.   To contrast the two, let's use the example of world wide web and
  241.   Telnet access.  With SOCKS, you set up one configuration file and one
  242.   daemon.  Through this file and daemon, both telnet and WWW are
  243.   enabled, as well as any other service that you have not disabled.
  244.  
  245.   With the TIS toolkit, you set up one daemon for each WWW and telnet,
  246.   as well as configuration files for each.  After you have done this,
  247.   other internet access is still prohibited until explicitly set up.  If
  248.   a daemon for a specific utility has not been provided (like talk),
  249.   there is a "plug-in" daemon, but it is neither as flexible, nor as
  250.   easy to set up, as the other tools.
  251.  
  252.   This might seem a minor, but it makes a major difference. SOCKS allows
  253.   you to be sloppy.  With a poorly set up SOCKS server, someone from the
  254.   inside could gain more access to the internet than was originally
  255.   intended.  With the TIS toolkit, the people on the inside have only
  256.   the access the system administrator wants them to have.
  257.  
  258.   SOCKS is easier to set up, easier to compile and allows for greater
  259.   flexibility.  The TIS toolkit is more secure if you want to regulate
  260.   the users inside the protected network.  Both provide absolute
  261.   protection from the outside.
  262.  
  263.   I will cover the installation and setup of both.
  264.  
  265.   5.  Preparing the Linux system
  266.  
  267.   5.1.  Compiling the Kernel
  268.  
  269.   Start with a clean installation of your Linux distribution. (I used
  270.   RedHat 3.0.3 and the examples here are based on this distribution.)
  271.   The less software you have loaded the less holes, backdoors and/or
  272.   bugs there will be to introduce security problems in your system, so
  273.   load only a minimal set of applications.
  274.  
  275.   Pick a stable kernel. I used the Linux 2.0.14 kernel for my system.
  276.   So this documentation is based on it's settings.
  277.  
  278.   You well need to recompile the Linux kernel with the appropriate
  279.   options.  At this point, you should look at the Kernel HOWTO, the
  280.   Ethernet HOWTO, and the NET-2 HOWTO if you haven't done this before.
  281.  
  282.   Here are the network related setting I know work in 'make config'
  283.  
  284.   1. Under General setup
  285.  
  286.      a. Turn Networking Support ON
  287.  
  288.   2. Under Networking Options
  289.  
  290.      a. Turn Network firewalls ON
  291.  
  292.      b. Turn TCP/IP Networking ON
  293.  
  294.      c. Turn IP forwarding/gatewaying OFF (UNLESS you wish to use IP
  295.         filtering)
  296.  
  297.      d. Turn IP Firewalling ON
  298.  
  299.      e. Turn IP firewall packet loggin ON (this is not required but it
  300.         is a good idea)
  301.  
  302.      f. Turn IP: masquerading OFF (I am not covering this subject here.)
  303.  
  304.      g. Turn IP: accounting ON
  305.  
  306.      h. Turn IP: tunneling OFF
  307.  
  308.      i. Turn IP: aliasing OFF
  309.  
  310.      j. Turn IP: PC/TCP compatibility mode OFF
  311.  
  312.      k. Turn IP: Reverse ARP OFF
  313.  
  314.      l. Turn Drop source routed frames ON
  315.  
  316.   3. Under Network device support
  317.  
  318.      a. Turn Network device support ON
  319.  
  320.      b. Turn Dummy net driver support ON
  321.  
  322.      c. Turn Ethernet (10 or 100Mbit) ON
  323.  
  324.      d. Select your network card
  325.  
  326.   Now you can recompile, reinstall the kernel and reboot.  Your network
  327.   card/s should show up in the boot-up sequence.  If not, go over the
  328.   other HOWTOs again until it is working.
  329.  
  330.   5.2.  Configuring two network cards
  331.  
  332.   If you have two network cards in your computer, you most likely will
  333.   need to add an append statement to your /etc/lilo.conf file to
  334.   describe the IRQ and address of both cards.  My lilo append statement
  335.   looks like this:
  336.  
  337.       append="ether=12,0x300,eth0 ether=15,0x340,eth1"
  338.  
  339.   5.3.  Configuring the Network Addresses
  340.  
  341.   This is the real interesting part.  Now you have a few decisions to
  342.   make.  Since we don't want the internet to have access to any part of
  343.   the private network, we do not need to use real addresses.  There are
  344.   a number of internet addresses set aside for private networks. Because
  345.   everyone needs more addresses and because these addresses can not
  346.   cross the Internet they are a good choice.
  347.  
  348.   Of these, 192.168.2.xxx, is set aside and we will use it in our
  349.   examples.
  350.  
  351.   Your proxy firewall will be a member of both networks and so it can
  352.   pass the data through to and from the private network.
  353.  
  354.               199.1.2.10   __________    192.168.2.1
  355.         _  __  _        \ |          | /           _______________
  356.        | \/  \/ |        \| Firewall |/           |               |
  357.       / Internet \--------|  System  |------------| Workstation/s |
  358.       \_/\_/\_/\_/        |__________|            |_______________|
  359.  
  360.   If your going to use a filtering firewall you can still use these
  361.   numbers.  You will need to use IP masquerading to make this happen.
  362.   With this process the firewall will forward packets and translate them
  363.   into  "REAL " " IP address to travel on the Internet.
  364.  
  365.   You must assign the real IP address to the network card on the
  366.   Internet (out) side. And, assign 192.168.2.1 to the Ethernet card on
  367.   inside.  This will be your proxy/gateway IP address.  You can assign
  368.   all the other machines in the protected network some number in that
  369.   192.168.2.xxx range. (192.168.2.2 through 192.168.2.254)
  370.  
  371.   Since I use RedHat Linux (Hey guys, want to give me a copy for the
  372.   plugs? ;-) to configure the network at boot time I added a 'ifcfg-
  373.   eth1' file in the /etc/sysconfig/network-scripts directory.  This file
  374.   is read during the boot process to set your network and routing
  375.   tables.
  376.  
  377.   Here is what my ifcfg-eth1 looks like;
  378.  
  379.       #!/bin/sh
  380.       #>>>Device type: ethernet
  381.       #>>>Variable declarations:
  382.       DEVICE=eth1
  383.       IPADDR=192.168.2.1
  384.       NETMASK=255.255.255.0
  385.       NETWORK=192.168.2.0
  386.       BROADCAST=192.168.2.255
  387.       GATEWAY=199.1.2.10
  388.       ONBOOT=yes
  389.       #>>>End variable declarations
  390.  
  391.   You can also use these scripts to automatically connect by modem to
  392.   your provider. Look at the ipup-ppp script.
  393.  
  394.   If your going to use a modem for your internet connection your outside
  395.   IP address will be assigned for you by your provider at connect time.
  396.  
  397.   5.4.  Testing your network
  398.  
  399.   Start by checking ifconfig and route.  If you have two network cards
  400.   your ifconfig should look something like:
  401.  
  402.     #ifconfig
  403.     lo        Link encap:Local Loopback
  404.               inet addr:127.0.0.0  Bcast:127.255.255.255  Mask:255.0.0.0
  405.               UP BROADCAST LOOPBACK RUNNING  MTU:3584  Metric:1
  406.               RX packets:1620 errors:0 dropped:0 overruns:0
  407.               TX packets:1620 errors:0 dropped:0 overruns:0
  408.  
  409.     eth0      Link encap:10Mbps Ethernet  HWaddr 00:00:09:85:AC:55
  410.               inet addr:199.1.2.10 Bcast:199.1.2.255  Mask:255.255.255.0
  411.               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  412.               RX packets:0 errors:0 dropped:0 overruns:0
  413.               TX packets:0 errors:0 dropped:0 overruns:0
  414.               Interrupt:12 Base address:0x310
  415.  
  416.     eth1      Link encap:10Mbps Ethernet  HWaddr 00:00:09:80:1E:D7
  417.               inet addr:192.168.2.1  Bcast:192.168.2.255  Mask:255.255.255.0
  418.               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  419.               RX packets:0 errors:0 dropped:0 overruns:0
  420.               TX packets:0 errors:0 dropped:0 overruns:0
  421.               Interrupt:15 Base address:0x350
  422.  
  423.   and your route table sould look like:
  424.  
  425.     #route -n
  426.     Kernel routing table
  427.     Destination     Gateway         Genmask         Flags MSS    Window Use Iface
  428.     199.1.2.0       *               255.255.255.0   U     1500   0       15 eth0
  429.     192.168.2.0     *               255.255.255.0   U     1500   0        0 eth1
  430.     127.0.0.0       *               255.0.0.0       U     3584   0        2 lo
  431.     default         199.1.2.10      *               UG    1500   0       72 eth0
  432.  
  433.   Note: 199.1.2.0 is the Internet side of this firewall and 192.168.2.0
  434.   is the private side.
  435.  
  436.   Now try to ping the internet from the firewall.  I used to use
  437.   nic.ddn.mil as my test point.  It's still a good test, but has proven
  438.   to be less reliable than I had hoped.  If it doesn't work at first,
  439.   try pinging a couple other places that are not connected to your LAN.
  440.   If this doesn't work, then your PPP is incorrectly setup.  Reread the
  441.   Net-2 HOWTO, and try again.
  442.  
  443.   Next, try pinging a host within the protected network from the
  444.   firewall.  All the computers should be able to ping each other.  If
  445.   not, go over the NET-2 HOWTO again and work on the network some more.
  446.  
  447.   Then, try to ping the outside address of firewall from inside the
  448.   protected network. (NOTE: this is not any of the 192.168.2.xxx IP
  449.   numbers.) If you can, then you have not turned off IP Forwarding.
  450.   Make sure this is the way you want it.  If you leave it turned on you
  451.   will have to go through the IP filtering section of this document as
  452.   well.
  453.  
  454.   Now try pinging the internet from behind your firewall. Use the same
  455.   address that worked for you before. (I.E. nic.ddn.mil) Again, if you
  456.   have IP Forwarding turned off, this should not work. But, if you have
  457.   it turned on, it should.
  458.  
  459.   If have IP Forwarding turned on and your using a  "REAL" (not
  460.   192.168.2.*)  IP address for your private network, and you can't ping
  461.   the internet but you can ping the internet side your firewall, check
  462.   if the next router up stream is routing packets for your private
  463.   network address. (Your provider may have to do this for you.)
  464.  
  465.   If you have assigned your protected network to 192.168.2.*, then no
  466.   can packets can be routed to it anyway.  If you have skipped ahead and
  467.   you already have IP masquerading turn on, this test should work.
  468.  
  469.   Now, you have your basic system setup.
  470.  
  471.   5.5.  Securing the Firewall
  472.  
  473.   A firewall isn't any good if it is left wide open to attacks through a
  474.   unused service.  A "bad guy" could gain access to the firewall and
  475.   modify it for their own needs.
  476.  
  477.   Start by turning off any unneeded services. Look at /etc/inetd.conf
  478.   file.  This file controls what are called the "super server".  It
  479.   controls a bunch of the server daemons and starts them as they are
  480.   requested.
  481.  
  482.   Definitely turn off netstat, systat, tftp, bootp, and finger.  To turn
  483.   a service off, put # as the first character of the service line.  When
  484.   your done, send a SIG-HUP to the process by typing "kill -HUP <pid>",
  485.   where <pid> is the process number of inetd.  This will make inetd re-
  486.   read its configuration file (inetd.conf) and restart.
  487.  
  488.   Test it out by telneting to port 15 on firewall, the netstat port.  If
  489.   you get an output of netstat, you have not restarted it correctly.
  490.  
  491.   6.  IP filtering setup (IPFWADM)
  492.  
  493.   To start, you should have IP Forwarding turned on in your kernel and
  494.   your system should be up and forwarding everything you send it. Your
  495.   routing tables should be in place and you should be able to access
  496.   everything, both from the inside out and from the outside in.
  497.  
  498.   But, we're building a firewall so we need to start chocking down what
  499.   everyone has access to.
  500.  
  501.   In my system I created a couple of scripts to set the firewall
  502.   forwarding policy and accounting policy. I call theses scripts from
  503.   the /etc/rc.d scripts so my system is configured at boot time.
  504.  
  505.   By default the IP Forwarding system in the Linux kernel forwards
  506.   everything.  Because of this, your firewall script should start by
  507.   denying access to everything and flushing any ipfw rules in place from
  508.   the last time it was run. This script will do the trick.
  509.  
  510.     #
  511.     # setup IP packet Accounting and Forwarding
  512.     #
  513.     #   Forwarding
  514.     #
  515.     # By default DENY all services
  516.     ipfwadm -F -p deny
  517.     # Flush all commands
  518.     ipfwadm -F -f
  519.     ipfwadm -I -f
  520.     ipfwadm -O -f
  521.  
  522.   Now we have the ultimate firewall. Nothing can get through. No doubt
  523.   you have some services you need to forward so here are a few examples
  524.   you should find useful.
  525.  
  526.     # Forward email to your server
  527.     ipfwadm -F -a accept -b -P tcp -S 0.0.0.0/0 1024:65535 -D 192.1.2.10 25
  528.  
  529.     # Forward email connections to outside email servers
  530.     ipfwadm -F -a accept -b -P tcp -S 196.1.2.10 25 -D 0.0.0.0/0 1024:65535
  531.  
  532.     # Forward Web connections to your Web Server
  533.     /sbin/ipfwadm -F -a accept -b -P tcp -S 0.0.0.0/0 1024:65535 -D 196.1.2.11 80
  534.  
  535.     # Forward Web connections to outside Web Server
  536.     /sbin/ipfwadm -F -a accept -b -P tcp -S 196.1.2.* 80 -D 0.0.0.0/0 1024:65535
  537.  
  538.     # Forward DNS traffic
  539.     /sbin/ipfwadm -F -a accept -b -P udp -S 0.0.0.0/0 53 -D 196.1.2.0/24
  540.  
  541.   You might also be interested in accounting for traffic going through
  542.   your firewall. This script will count ever packet.  You could add a
  543.   line or to to account for packets going to just a single system.
  544.  
  545.     # Flush the current accounting rules
  546.     ipfwadm -A -f
  547.     # Accounting
  548.     /sbin/ipfwadm -A -f
  549.     /sbin/ipfwadm -A out -i -S 196.1.2.0/24 -D 0.0.0.0/0
  550.     /sbin/ipfwadm -A out -i -S 0.0.0.0/0 -D 196.1.2.0/24
  551.     /sbin/ipfwadm -A in -i -S 196.1.2.0/24 -D 0.0.0.0/0
  552.     /sbin/ipfwadm -A in -i -S 0.0.0.0/0 -D 196.1.2.0/24
  553.  
  554.   If all you wanted was a filtering firewall you can stop here.  Enjoy
  555.   :-)
  556.  
  557.   7.  Installing the TIS Proxy server
  558.  
  559.   7.1.  Getting the software
  560.  
  561.   The TIS FWTK is avaible at ftp://ftp.tis.com/.
  562.  
  563.   Don't make the mistake I did. When you ftp files from TIS, READ THE
  564.   README's.  The TIS fwtk is locked up in a hidden directory on their
  565.   server.  TIS requires you send email to fwtk-request@tis.com with only
  566.   the word SEND in the body of the message to learn the name of this
  567.   hidden directory. No subject is needed in the message.  Their system
  568.   will then mails you back the directory name (good for 12 hours) to
  569.   download the source.
  570.  
  571.   As I'm writing this TIS is releasing version 2.0 (beta) of the FWTK.
  572.   This version seems to compile well (with a few exceptions) and
  573.   everything is working for me. This is the version I will be covering
  574.   here.  When they release the final code I'll update the HOWTO.
  575.  
  576.   To install the FWTK, create a fwtk-2.0 directory in your /usr/src
  577.   directory.  Move your copy of the FWTK (fwtk-2.0.tar.gz) to your this
  578.   directory and untar it (tar zxf fwtk-2.0.tar.gz).
  579.  
  580.   The FWTK does not proxy SSL web documents but there is an addon for it
  581.   written by Jean-Christophe Touvet. It is avaible at
  582.   ftp://ftp.edelweb.fr/pub/contrib/fwtk/ssl-gw.tar.Z. Touvet does not
  583.   support this code.
  584.  
  585.   I am using a modified version that includes access to Netscape secure
  586.   news servers written by Eric Wedel. It is available at
  587.   ftp://mdi.meridian-data.com/pub/tis.fwtk/ssl-gw/ssl-gw2.tar.Z.
  588.  
  589.   In our example I will use Eric Wedel's version.
  590.  
  591.   To install it, simply create a ssl-gw directory in your
  592.   /usr/src/fwtk-2.0 directory and put the files in it.
  593.  
  594.   When I installed this gateway it required a few changes before it
  595.   would compile with the rest of the toolkit.
  596.  
  597.   The first change was to the ssl-gw.c file. I found it didn't include a
  598.   needed include file.
  599.  
  600.     #if defined(__linux)
  601.     #include        <sys/ioctl.h>
  602.     #endif
  603.  
  604.   Second it didn't come with a Makefile. I copied one out of the other
  605.   gateway directories and replaced the gateway's name with ssl-gw.
  606.  
  607.   7.2.  Compiling the TIS FWTK
  608.  
  609.   Version 2.0 of the FWTK compiles much easier then any of the older
  610.   versions.  I still found a couple of things that needed to be changed
  611.   before the BETA version would compile cleanly. Hopefully these changes
  612.   will be make in the final version.
  613.  
  614.   To fix it up, start by changing to the /usr/src/fwtk/fwtk directory
  615.   and coping the Makefile.config.linux file over the Makefile.config
  616.   file.
  617.  
  618.   DON'T RUN FIXMAKE. The instructions tell you to run this. If you do it
  619.   will break the makefiles in each directory.
  620.  
  621.   I do have a fix for fixmake. The problem is the sed script add a '.'
  622.   and '' to the include line of ever Makefile. This sed script works.
  623.  
  624.     sed 's/^include[        ]*\([^  ].*\)/include \1/' $name .proto > $name
  625.  
  626.   Next we need to edit the Makefile.config file. There are two changes
  627.   you may need to make.
  628.  
  629.   The author set the source directory to his home directory.  We are
  630.   compiling our code in /usr/src so you should changed the FWTKSRCDIR
  631.   variable to reflect this.
  632.  
  633.     FWTKSRCDIR=/usr/src/fwtk/fwtk
  634.  
  635.   Second, at least some Linux system us the gdbm database. The
  636.   Makefile.config is using dbm. You might need to change this. I had to
  637.   for RedHat 3.0.3.
  638.  
  639.     DBMLIB=-lgdbm
  640.  
  641.   The last fix is in the x-gw. The bug in the BETA version is in the
  642.   socket.c code.  To fix it remove these lines of code.
  643.  
  644.     #ifdef SCM_RIGHTS  /* 4.3BSD Reno and later */
  645.                          + sizeof(un_name->sun_len) + 1
  646.     #endif
  647.  
  648.   If you added the ssl-gw to your FWTK source directory you will need to
  649.   add it to the list of directory in the Makefile.
  650.  
  651.     DIRS=   smap smapd netacl plug-gw ftp-gw tn-gw rlogin-gw http-gw x-gw ssl-gw
  652.  
  653.   Now run make.
  654.  
  655.   7.3.  Installing the TIS FWTK
  656.  
  657.   Run make install.
  658.  
  659.   The default installation directory is /usr/local/etc. You could change
  660.   this (I didn't) to a more secure directory. I chose to change the
  661.   access to this directory to 'chmod 700'.
  662.  
  663.   All last is left now is to configure the firewall.
  664.  
  665.   7.4.  Configuring the TIS FWTK
  666.  
  667.   Now the fun realy begins. We must teach the system to call theses new
  668.   services and create the tables to control them.
  669.  
  670.   I'm not going to try to re-write the TIS FWTK manual here. I will show
  671.   you the setting I found worked and explain the problems I ran into and
  672.   how I got around them.
  673.  
  674.   There are three files that make up these controls.
  675.  
  676.   ╖  /etc/services
  677.  
  678.   ╖  Tells the system what ports a services is on.
  679.  
  680.   ╖  /etc/inetd.conf
  681.  
  682.   ╖  Tells inetd what program to call when someone knocks on a service
  683.      port.
  684.  
  685.   ╖  /usr/local/etc/netperm-table
  686.  
  687.   ╖  Tells the FWTK services who to allow and deny service to.
  688.  
  689.   To get the FWTK functioning, you should edit these files from the
  690.   bottom up. Editing the services file without the inetd.conf or
  691.   netperm-table file set correctly could make your system inaccessible.
  692.  
  693.   7.4.1.  The netperm-table file
  694.  
  695.   This file controls who can access the services of the TIS FWTK. You
  696.   should think about the traffic using the firewall from both sides.
  697.   People outside your network should identify themselves before gaining
  698.   access, but the people inside your network might be allowed to just
  699.   pass through.
  700.  
  701.   So people can identify themselves, the firewall uses a program called
  702.   authsrv to keep a database of user IDs and passwords. The
  703.   authentication section of the netperm-table controls where the
  704.   database is keep and who can access it.
  705.  
  706.   I had some trouble closing the access to this service. Note the
  707.   premit-hosts line I show uses a '*' to give everyone access. The
  708.   correct setting for this line is '' authsrv: premit-hosts localhost if
  709.   you can get it working.
  710.  
  711.     #
  712.     # Proxy configuration table
  713.     #
  714.     # Authentication server and client rules
  715.     authsrv:      database /usr/local/etc/fw-authdb
  716.     authsrv:      permit-hosts *
  717.     authsrv:      badsleep 1200
  718.     authsrv:      nobogus true
  719.     # Client Applications using the Authentication server
  720.     *:            authserver 127.0.0.1 114
  721.  
  722.   To initialize the database, su to root, and run ./authsrv in the
  723.   /var/local/etc directory to create the administrative user record.
  724.   Here is a sample session.
  725.  
  726.   Read the FWTK documentation to learn how to add users and groups.
  727.  
  728.       #
  729.       # authsrv
  730.       authsrv# list
  731.       authsrv# adduser admin "Auth DB admin"
  732.       ok - user added initially disabled
  733.       authsrv# ena admin
  734.       enabled
  735.       authsrv# proto admin pass
  736.       changed
  737.       authsrv# pass admin "plugh"
  738.       Password changed.
  739.       authsrv# superwiz admin
  740.       set wizard
  741.       authsrv# list
  742.       Report for users in database
  743.       user   group  longname           ok?    proto   last
  744.       ------ ------ ------------------ -----  ------  -----
  745.       admin         Auth DB admin      ena    passw   never
  746.       authsrv# display admin
  747.       Report for user admin (Auth DB admin)
  748.       Authentication protocol: password
  749.       Flags: WIZARD
  750.       authsrv# ^D
  751.       EOT
  752.       #
  753.  
  754.   The telnet gateway (tn-gw) controls are straight forward and the first
  755.   you should set up.
  756.  
  757.   In my example, I premit host from inside the private network to pass
  758.   through without authenticating themselves. (permit-hosts 19961.2.*
  759.   -passok) But, any other user must enter their user ID and password to
  760.   use the proxy.  (permit-hosts * -auth)
  761.  
  762.   I also allow one other system (196.1.2.202) to access the firewall
  763.   directly without going through the firewall at all. The two inetacl-
  764.   in.telnetd lines do this.  I will explain how these lines are called
  765.   latter.
  766.  
  767.   The Telnet timeout should be keep short.
  768.  
  769.     # telnet gateway rules:
  770.     tn-gw:                denial-msg      /usr/local/etc/tn-deny.txt
  771.     tn-gw:                welcome-msg     /usr/local/etc/tn-welcome.txt
  772.     tn-gw:                help-msg        /usr/local/etc/tn-help.txt
  773.     tn-gw:                timeout 90
  774.     tn-gw:                permit-hosts 196.1.2.* -passok -xok
  775.     tn-gw:                permit-hosts * -auth
  776.     # Only the Administrator can telnet directly to the Firewall via Port 24
  777.     netacl-in.telnetd: permit-hosts 196.1.2.202 -exec /usr/sbin/in.telnetd
  778.  
  779.   The r-commands work the same way as telnet.
  780.  
  781.     # rlogin gateway rules:
  782.     rlogin-gw:    denial-msg      /usr/local/etc/rlogin-deny.txt
  783.     rlogin-gw:    welcome-msg     /usr/local/etc/rlogin-welcome.txt
  784.     rlogin-gw:    help-msg        /usr/local/etc/rlogin-help.txt
  785.     rlogin-gw:    timeout 90
  786.     rlogin-gw:    permit-hosts 196.1.2.* -passok -xok
  787.     rlogin-gw:    permit-hosts * -auth -xok
  788.     # Only the Administrator can telnet directly to the Firewall via Port
  789.     netacl-rlogind: permit-hosts 196.1.2.202 -exec /usr/libexec/rlogind -a
  790.  
  791.   You shouldn't have anyone accessing your firewall directly and that
  792.   includes FTP so don't put an FTP, server on you firewall.
  793.  
  794.   Again, the permit-hosts line allows anyone in the protected network
  795.   free access to the Internet and all others must authenticate
  796.   themselves.  I included logging of every file sent and received to my
  797.   controls.  (-log { retr stor })
  798.  
  799.   The ftp timeout controls how long it will take to drop a bad
  800.   connections as well as how long a connection will stay open with out
  801.   activity.
  802.  
  803.     # ftp gateway rules:
  804.     ftp-gw:               denial-msg      /usr/local/etc/ftp-deny.txt
  805.     ftp-gw:               welcome-msg     /usr/local/etc/ftp-welcome.txt
  806.     ftp-gw:               help-msg        /usr/local/etc/ftp-help.txt
  807.     ftp-gw:               timeout 300
  808.     ftp-gw:               permit-hosts 196.1.2.* -log { retr stor }
  809.     ftp-gw:               permit-hosts * -authall -log { retr stor }
  810.  
  811.   Web, gopher and browser based ftp are contorted by the http-gw.  The
  812.   first two lines create a directory to store ftp and web documents as
  813.   they are passing through the firewall. I make these files owned by
  814.   root and put the in a directory accessible only by root.
  815.  
  816.   The Web connection should be kept short. It controls how long the user
  817.   will wait on a bad connections.
  818.  
  819.     # www and gopher gateway rules:
  820.     http-gw:      userid          root
  821.     http-gw:      directory       /jail
  822.     http-gw:      timeout 90
  823.     http-gw:      default-httpd   www.afs.net
  824.     http-gw:      hosts           196.1.2.* -log { read write ftp }
  825.     http-gw:      deny-hosts      *
  826.  
  827.   The ssl-gw is really just a pass anything gateway. Be carefull with
  828.   it.  In this example I allow anyone inside the protected network to
  829.   connect to any server outside the network except the addresses
  830.   127.0.0.* and 192.1.1.* and then only on ports 443 through 563. Ports
  831.   443 through 563 are known SSL ports.
  832.  
  833.     # ssl gateway rules:
  834.     ssl-gw:         timeout 300
  835.     ssl-gw:         hosts           196.1.2.* -dest { !127.0.0.* !192.1.1.* *:443:563 }
  836.     ssl-gw:         deny-hosts      *
  837.  
  838.   Here is an example of how to use the plug-gw to allow connections to a
  839.   news server.  In this example I allow anyone inside the protected
  840.   network to connect to only one system and only to it's news port.
  841.  
  842.   The seconded line allows the news server to pass its data back to the
  843.   protected network.
  844.  
  845.   Because most clients expect to stay connected while the user read
  846.   news, the timeout for a news server should be long.
  847.  
  848.     # NetNews Pluged gateway
  849.     plug-gw:        timeout 3600
  850.     plug-gw: port nntp 196.1.2.* -plug-to 199.5.175.22 -port nntp
  851.     plug-gw: port nntp 199.5.175.22 -plug-to 196.1.2.* -port nntp
  852.  
  853.   The finger gateway is simple. Anyone inside the protected network must
  854.   login first and then we allow them to use the finger program on the
  855.   firewall. Anyone else just gets a message.
  856.  
  857.     # Enable finger service
  858.     netacl-fingerd: permit-hosts 196.1.2.* -exec /usr/libexec/fingerd
  859.     netacl-fingerd: permit-hosts * -exec /bin/cat /usr/local/etc/finger.txt
  860.  
  861.   I haven't setup the Mail and X-windows services so I'm not including
  862.   examples.  If anyone has a working example, please send me email.
  863.  
  864.   7.4.2.  The inetd.conf file
  865.  
  866.   Here is a complete /etc/inetd.conf file. All un-needed services have
  867.   been commented out. I have included the complete file to show what to
  868.   turn off, as well as how to setup the new firewall services.
  869.  
  870.     #echo stream  tcp  nowait  root       internal
  871.     #echo dgram   udp  wait    root       internal
  872.     #discard      stream  tcp  nowait  root       internal
  873.     #discard      dgram   udp  wait    root       internal
  874.     #daytime      stream  tcp  nowait  root       internal
  875.     #daytime      dgram   udp  wait    root       internal
  876.     #chargen      stream  tcp  nowait  root       internal
  877.     #chargen      dgram   udp  wait    root       internal
  878.     # FTP firewall gateway
  879.     ftp-gw      stream  tcp  nowait.400  root  /usr/local/etc/ftp-gw  ftp-gw
  880.     # Telnet firewall gateway
  881.     telnet        stream  tcp  nowait      root  /usr/local/etc/tn-gw /usr/local/etc/tn-gw
  882.     # local telnet services
  883.     telnet-a    stream  tcp  nowait      root  /usr/local/etc/netacl in.telnetd
  884.     # Gopher firewall gateway
  885.     gopher        stream  tcp  nowait.400  root  /usr/local/etc/http-gw /usr/local/etc/http-gw
  886.     # WWW firewall gateway
  887.     http  stream  tcp  nowait.400  root  /usr/local/etc/http-gw /usr/local/etc/http-gw
  888.     # SSL firewall gateway
  889.     ssl-gw  stream  tcp     nowait  root /usr/local/etc/ssl-gw   ssl-gw
  890.     # NetNews firewall proxy (using plug-gw)
  891.     nntp    stream  tcp     nowait  root    /usr/local/etc/plug-gw plug-gw nntp
  892.     #nntp stream  tcp     nowait  root    /usr/sbin/tcpd  in.nntpd
  893.     # SMTP (email) firewall gateway
  894.     #smtp stream  tcp     nowait  root    /usr/local/etc/smap smap
  895.     #
  896.     # Shell, login, exec and talk are BSD protocols.
  897.     #
  898.     #shell        stream  tcp     nowait  root    /usr/sbin/tcpd  in.rshd
  899.     #login        stream  tcp     nowait  root    /usr/sbin/tcpd  in.rlogind
  900.     #exec stream  tcp     nowait  root    /usr/sbin/tcpd  in.rexecd
  901.     #talk dgram   udp     wait    root    /usr/sbin/tcpd  in.talkd
  902.     #ntalk        dgram   udp     wait    root    /usr/sbin/tcpd  in.ntalkd
  903.     #dtalk        stream  tcp     waut    nobody  /usr/sbin/tcpd  in.dtalkd
  904.     #
  905.     # Pop and imap mail services et al
  906.     #
  907.     #pop-2   stream  tcp  nowait  root  /usr/sbin/tcpd    ipop2d
  908.     #pop-3   stream  tcp  nowait  root  /usr/sbin/tcpd    ipop3d
  909.     #imap    stream  tcp  nowait  root  /usr/sbin/tcpd    imapd
  910.     #
  911.     # The Internet UUCP service.
  912.     #
  913.     #uucp    stream  tcp  nowait  uucp  /usr/sbin/tcpd  /usr/lib/uucp/uucico -l
  914.     #
  915.     # Tftp service is provided primarily for booting.  Most sites
  916.     # run this only on machines acting as "boot servers." Do not uncomment
  917.     # this unless you *need* it.
  918.     #
  919.     #tftp dgram   udp     wait    root    /usr/sbin/tcpd  in.tftpd
  920.     #bootps       dgram   udp     wait    root    /usr/sbin/tcpd  bootpd
  921.     #
  922.     # Finger, systat and netstat give out user information which may be
  923.     # valuable to potential "system crackers."  Many sites choose to disable
  924.     # some or all of these services to improve security.
  925.     #
  926.     # cfinger is for GNU finger, which is currently not in use in RHS Linux
  927.     #
  928.     finger        stream  tcp  nowait  root   /usr/sbin/tcpd  in.fingerd
  929.     #cfinger      stream  tcp  nowait  root   /usr/sbin/tcpd  in.cfingerd
  930.     #systat       stream  tcp  nowait  guest  /usr/sbin/tcpd  /bin/ps -auwwx
  931.     #netstat      stream  tcp  nowait  guest  /usr/sbin/tcpd  /bin/netstat -f inet
  932.     #
  933.     # Time service is used for clock syncronization.
  934.     #
  935.     #time stream  tcp  nowait  root  /usr/sbin/tcpd  in.timed
  936.     #time dgram   udp  wait    root  /usr/sbin/tcpd  in.timed
  937.     #
  938.     # Authentication
  939.     #
  940.     auth          stream  tcp  wait    root  /usr/sbin/tcpd  in.identd -w -t120
  941.     authsrv       stream  tcp  nowait  root  /usr/local/etc/authsrv authsrv
  942.     #
  943.     # End of inetd.conf
  944.  
  945.   7.4.3.  The /etc/services file
  946.  
  947.   This is where it all begins. When a client connects to the firewall it
  948.   connects on a known port (less then 1024).  For example telnet
  949.   connects on port 23. The inetd deamon hears this connection and looks
  950.   up the name of these service in the /etc/services file. It then calls
  951.   the program assigned to the name in the /etc/inetd.conf file.
  952.  
  953.   Some of the services we are creating are not normally in the
  954.   /etc/services file. You can assign some of them to any port you want.
  955.   For example, I have assigned the administrator's telnet port (telnet-
  956.   a) to port 24.  You could assign it to port 2323 if you wished. For
  957.   the administrator (YOU) to connect directly to the firewall you will
  958.   need to telnet to port 24 not 23 and if you setup your netperm-table
  959.   file, like I did, you will only be able to to this from one system
  960.   inside your protected network.
  961.  
  962.     telnet-a        24/tcp
  963.     ftp-gw          21/tcp           # this named changed
  964.     auth            113/tcp   ident    # User Verification
  965.     ssl-gw          443/tcp
  966.  
  967.   8.  The SOCKS Proxy Server
  968.  
  969.   8.1.  Setting up the Proxy Server
  970.  
  971.   The SOCKS proxy server available from
  972.   ftp://sunsite.unc.edu/pub/Linux/system/Network/misc/socks-linux-
  973.   src.tgz.  There is also an example config file in that directory
  974.   called "socks-conf".  Uncompress and untar the files into a directory
  975.   on your system, and follow the instructions on how to make it.  I had
  976.   a couple problems when I made it.  Make sure that your Makefiles are
  977.   correct.
  978.  
  979.   One important thing to note is that the proxy server needs to be added
  980.   to /etc/inetd.conf.  You must add a line:
  981.  
  982.     socks  stream  tcp  nowait  nobody  /usr/local/etc/sockd  sockd
  983.  
  984.   to tell the server to run when requested.
  985.  
  986.   8.2.  Configuring the Proxy Server
  987.  
  988.   The SOCKS program needs two separate configuration files.  One to tell
  989.   the access allowed, and one to route the requests to the appropriate
  990.   proxy server.  The access file should be housed on the server.  The
  991.   routing file should be housed on every Un*x machine.  The DOS and,
  992.   presumably, Macintosh computers will do their own routing.
  993.  
  994.   8.2.1.  The Access File
  995.  
  996.   With socks4.2 Beta, the access file is called "sockd.conf".  It should
  997.   contain 2 lines, a permit and a deny line.   Each line will have three
  998.   entries:
  999.  
  1000.   ╖  The Identifier (permit/deny)
  1001.  
  1002.   ╖  The IP address
  1003.  
  1004.   ╖  The address modifier
  1005.  
  1006.   The identifier is either permit or deny.  You should have both a
  1007.   permit and a deny line.
  1008.  
  1009.   The IP address holds a four byte address in typical IP dot notation.
  1010.   I.E. 192.168.2.0.
  1011.  
  1012.   The address modifier is also a typical IP address four byte number.
  1013.   It works like a netmask.  Envision this number to be 32 bits (1s or
  1014.   0s). If the bit is a 1, the corresponding bit of the address that it
  1015.   is checking must match the corresponding bit in the IP address field.
  1016.   For instance, if the line is:
  1017.  
  1018.       permit 192.168.2.23 255.255.255.255
  1019.  
  1020.   it will permit only the IP address that matches every bit in
  1021.   192.168.2.23, eg, only 192.168.2.3.  The line:
  1022.  
  1023.       permit 192.168.2.0 255.255.255.0
  1024.  
  1025.   will permit every number within group 192.168.2.0 through
  1026.   192.168.2.255, the whole C Class domain.   One should not have the
  1027.   line:
  1028.  
  1029.       permit 192.168.2.0 0.0.0.0
  1030.  
  1031.   as this will permit every address, regardless.
  1032.  
  1033.   So, first permit every address you want to permit, and then deny the
  1034.   rest.  To allow everyone in the domain 192.168.2.xxx, the lines:
  1035.  
  1036.       permit 192.168.2.0 255.255.255.0
  1037.       deny 0.0.0.0 0.0.0.0
  1038.  
  1039.   will work nicely.  Notice the first "0.0.0.0" in the deny line.  With
  1040.   a modifier of 0.0.0.0, the IP address field does not matter.  All 0's
  1041.   is the norm because it is easy to type.
  1042.  
  1043.   More than one entry of each is allowed.
  1044.  
  1045.   Specific users can also be granted or denied access.  This is done via
  1046.   ident authentication.  Not all systems support ident, including
  1047.   Trumpet Winsock, so I will not go into it here.  The documentation
  1048.   with socks is quite adequate on this subject.
  1049.  
  1050.   8.2.2.  The Routing File
  1051.  
  1052.   The routing file in SOCKS is poorly named "socks.conf".  I say "poorly
  1053.   named" because it is so close to the name of the access file that it
  1054.   is easy to get the two confused.
  1055.  
  1056.   The routing file is there to tell the SOCKS clients when to use socks
  1057.   and when not to.  For instance, in our network, 192.168.2.3 will not
  1058.   need to use socks to talk with 192.168.2.1, firewall.  It has a direct
  1059.   connection in via Ethernet.  It defines 127.0.0.1, the loopback,
  1060.   automatically.  Of course you do not need SOCKS to talk to yourself.
  1061.   There are three entries:
  1062.  
  1063.   ╖  deny
  1064.  
  1065.   ╖  direct
  1066.  
  1067.   ╖  sockd
  1068.  
  1069.   Deny tells SOCKS when to reject a request.  This entry has the same
  1070.   three fields as in sockd.conf, identifier, address and modifier.
  1071.   Generally, since this is also handled by sockd.conf, the access file,
  1072.   the modifier field is set to 0.0.0.0.  If you want to preclude
  1073.   yourself from calling any place, you can do it here.
  1074.  
  1075.   The direct entry tells which addresses to not use socks for.  These
  1076.   are all the addresses that can be reached without the proxy server.
  1077.   Again we have the three fields, identifier, address and modifier.  Our
  1078.   example would have
  1079.  
  1080.       direct 192.168.2.0 255.255.255.0
  1081.  
  1082.   Thus going direct for any on our protected network.
  1083.  
  1084.   The sockd entry tells the computer which host has the socks server
  1085.   daemon on it.  The syntax is:
  1086.  
  1087.     sockd @=<serverlist> <IP address> <modifier>
  1088.  
  1089.   Notice the @= entry.  This allows you to set the IP addresses of a
  1090.   list of proxy servers.  In our example, we only use one proxy server.
  1091.   But, you can have many to allow a greater load and for redundancy in
  1092.   case of failure.
  1093.  
  1094.   The IP address and modifier fields work just like in the other
  1095.   examples.  You specify which addresses go where through these.  6.2.3.
  1096.   DNS from behind a Firewall
  1097.  
  1098.   Setting up Domain Name service from behind a firewall is a relatively
  1099.   simple task.  You need merely to set up the DNS on the firewalling
  1100.   machine.  Then, set each machine behind the firewall to use this DNS.
  1101.  
  1102.   8.3.  Working With a Proxy Server
  1103.  
  1104.   8.3.1.  Unix
  1105.  
  1106.   To have your applications work with the proxy server, they need to be
  1107.   "sockified".  You will need two different telnets, one for direct
  1108.   communication, one for communication via the proxy server.  SOCKS
  1109.   comes with instructions on how to SOCKify a program, as well as a
  1110.   couple pre-SOCKified programs.  If you use the SOCKified version to go
  1111.   somewhere direct, SOCKS will automatically switch over to the direct
  1112.   version for you.  Because of this, we want to rename all the programs
  1113.   on our protected network and replace them with the SOCKified programs.
  1114.   "Finger" becomes "finger.orig", "telnet" becomes "telnet.orig", etc.
  1115.   You must tell SOCKS about each of these via the include/socks.h file.
  1116.  
  1117.   Certain programs will handle routing and sockifying itself.  Netscape
  1118.   is one of these.  You can use a proxy server under Netscape by
  1119.   entering the server's address (192.168.2.1 in our case) in the SOCKs
  1120.   field under Proxies.  Each application will need at least a little
  1121.   messing with, regardless of how it handles a proxy server.
  1122.  
  1123.   8.3.2.  MS Windows with Trumpet Winsock
  1124.  
  1125.   Trumpet Winsock comes with built in proxy server capabilities.  In the
  1126.   "setup" menu, enter the IP address of the server, and the addresses of
  1127.   all the computers reachable directly.  Trumpet will then handle all
  1128.   outgoing packets.
  1129.  
  1130.   8.3.3.  Getting the Proxy Server to work with UDP Packets
  1131.  
  1132.   The SOCKS package works only with TCP packets, not UDP.  This makes it
  1133.   quite a bit less useful.  Many useful programs, such as talk and
  1134.   Archie, use UDP.  There is a package designed to be used as a proxy
  1135.   server for UDP packets called UDPrelay, by Tom Fitzgerald
  1136.   <fitz@wang.com>.  Unfortunately, at the time of this writing, it is
  1137.   not compatible with Linux.
  1138.  
  1139.   8.4.  Drawbacks with Proxy Servers
  1140.  
  1141.   The proxy server is, above all, a security device.  Using it to
  1142.   increase internet access with limited IP addresses will have many
  1143.   drawbacks.  A proxy server will allow greater access from inside the
  1144.   protected network to the outside, but will keep the inside completely
  1145.   unaccessible from the outside.  This means no servers, talk or archie
  1146.   connections, or direct mailing to the inside computers.  These
  1147.   drawbacks might seem slight, but think of it this way:
  1148.  
  1149.   ╖  You have left a report you are doing on your computer inside a
  1150.      firewall protected network.  You are at home, and decide that you
  1151.      would like to go over it.  You can not.  You can not reach your
  1152.      computer because it is behind the firewall.  You try to log into
  1153.      firewall first, but since everyone has proxy server access, no one
  1154.      has set up an account for you on it.
  1155.  
  1156.   ╖  Your daughter goes to college.  You want to email her.  You have
  1157.      some private things to talk about, and would rather have your mail
  1158.      sent directly to your machine.  You trust your systems
  1159.      administrator completely, but still, this is private mail.
  1160.  
  1161.   ╖  The inability to use UDP packets represents a big drawback with the
  1162.      proxy servers.  I imagine UDP capabilities will be coming shortly.
  1163.  
  1164.   FTP causes another problem with a proxy server.  When getting or doing
  1165.   an ls, the FTP server opens a socket on the client machine and sends
  1166.   the information through it.  A proxy server will not allow this, so
  1167.   FTP doesn't particularly work.
  1168.  
  1169.   And, proxy servers run slow.  Because of the greater overhead, almost
  1170.   any other means of getting this access will be faster.
  1171.  
  1172.   Basically, if you have the IP addresses, and you are not worried about
  1173.   security, do not use a firewall and/or proxy servers.  If you do not
  1174.   have the IP addresses, but you are also not worried about security,
  1175.   you might also want to look into using an IP emulator, like Term,
  1176.   Slirp or TIA.  Term is available from ftp://sunsite.unc.edu, Slirp is
  1177.   available from ftp://blitzen.canberra.edu.au/pub/slirp, and TIA is
  1178.   available from marketplace.com.  These packages will run faster, allow
  1179.   better connections, and provide a greater level of access to the
  1180.   inside network from the internet.  Proxy servers are good for those
  1181.   networks which have a lot of hosts that will want to connect to the
  1182.   internet on the fly, with one setup and little work after that.
  1183.  
  1184.   9.  Advanced Configurations
  1185.  
  1186.   There is one configuration I would like to go over before wrapping
  1187.   this document up.  The one I have just outlined will probably suffice
  1188.   for most people.  However, I think the next outline will show a more
  1189.   advanced configuration that can clear up some questions.  If you have
  1190.   questions beyond what I have just covered, or are just interested in
  1191.   the versatility of proxy servers and firewalls, read on.
  1192.  
  1193.   9.1.  A large network with emphasis on security
  1194.  
  1195.   Say, for instance, you are the leader of millisha and you wish to
  1196.   network your site.  You have 50 computers and a subnet of 32 (5 bits)
  1197.   IP numbers.  You need various levels of access within your network
  1198.   because you tell your followers different things.  Therefore, you'll
  1199.   need to protect certain parts of the network from the rest.
  1200.  
  1201.   The levels are:
  1202.  
  1203.   1. The external level.  This is the level that gets shown to
  1204.      everybody. This is where you rant and rave to get new volunteers.
  1205.  
  1206.   2. Troop  This is the level of people who have gotten beyond the
  1207.      external level.  Here is where you teach them about the evail
  1208.      goverment and how to make bombs.
  1209.  
  1210.   3. Mercenary  Here is where the real plans are keep.  In this level is
  1211.      stored all the information on how the 3rd world goverment is going
  1212.      to take over the world, your plans involving Newt Gingrich,
  1213.      Oklahoma City, lown care products and what realy is stored in that
  1214.      hangers at area 51.
  1215.  
  1216.   9.1.1.  The Network Setup
  1217.  
  1218.   The IP numbers are arranged as:
  1219.  
  1220.   ╖  1 number is 192.168.2.255, which is the broadcast address and is
  1221.      not usable.
  1222.  
  1223.   ╖  23 of the 32 IP addresses are allocated to 23 machines that will be
  1224.      accessible to the internet.
  1225.  
  1226.   ╖  1 extra IP goes to a linux box on that network
  1227.  
  1228.   ╖  1 extra goes to a different linux box on that network.
  1229.  
  1230.   ╖  2 IP #'s go to the router
  1231.  
  1232.   ╖  4 are left over, but given domain names paul, ringo, john, and
  1233.      george, just to confuse things a bit.
  1234.  
  1235.   ╖  The protected networks both have the addresses 192.168.2.xxx
  1236.  
  1237.   Then, two separate networks are built, each in different rooms.  They
  1238.   are routed via infrared Ethernet so that they are completely invisible
  1239.   to the outside room.  Luckily, infrared ethernet works just like
  1240.   normal ethernet.
  1241.  
  1242.   These networks are each connected to one of the linux boxes with an
  1243.   extra IP address.
  1244.  
  1245.   There is a file server connecting the two protected networks.  This is
  1246.   because the plans for taking over the world involves some of the
  1247.   higher Troops.  The file server holds the address 192.168.2.17 for the
  1248.   Troop network and 192.168.2.23 for the Mercenary network.  It has to
  1249.   have different IP addresses because it has to have different Ethernet
  1250.   cards.  IP Forwarding on it is turned off.
  1251.  
  1252.   IP Forwarding on both Linux boxes is also turned off.  The router will
  1253.   not forward packets destined for 192.168.2.xxx unless explicitly told
  1254.   to do so, so the internet will not be able to get in.  The reason for
  1255.   turning off IP Forwarding here is so that packets from the Troop's
  1256.   network will not be able to reach the Mercenary network, and vica
  1257.   versa.
  1258.  
  1259.   The NFS server can also be set to offer different files to the
  1260.   different networks.  This can come in handy, and a little trickery
  1261.   with symbolic links can make it so that the common files can be shared
  1262.   with all.  Using this setup and another ethernet card can offer this
  1263.   one file server for all three networks.
  1264.  
  1265.   9.1.2.  The Proxy Setup
  1266.  
  1267.   Now, since all three levels want to be able to monitor the network for
  1268.   their own devious purposes, all three need to have net access.  The
  1269.   external network is connected directly into the internet, so we don't
  1270.   have to mess with proxy servers here.  The Mercenary and Troop
  1271.   networks are behind firewalls, so it is necessary to set up proxy
  1272.   servers here.
  1273.  
  1274.   Both networks will be setup very similarly.  They both have the same
  1275.   IP addresses assigned to them.  I will throw in a couple of
  1276.   parameters, just to make things more interesting though.
  1277.  
  1278.   1. No one can use the file server for internet access.  This exposes
  1279.      the file server to viruses and other nasty things, and it is rather
  1280.      important, so its off limits.
  1281.  
  1282.   2. We will not allow troop access to the World Wide Web.  They are in
  1283.      training, and this kind of information retrieval power might prove
  1284.      to be damaging.
  1285.  
  1286.   So, the sockd.conf file on the Troop's linux box will have this line:
  1287.  
  1288.       deny 192.168.2.17 255.255.255.255
  1289.  
  1290.   and on the Mercenary machine:
  1291.  
  1292.       deny 192.168.2.23 255.255.255.255
  1293.  
  1294.   And, the Troop's linux box will have this line
  1295.  
  1296.       deny 0.0.0.0 0.0.0.0 eq 80
  1297.  
  1298.   This says to deny access to all machines trying to access the port
  1299.   equal (eq) to 80, the http port.  This will still allow all other
  1300.   services, just deny Web access.
  1301.  
  1302.   Then, both files will have:
  1303.  
  1304.       permit 192.168.2.0 255.255.255.0
  1305.  
  1306.   to allow all the computers on the 192.168.2.xxx network to use this
  1307.   proxy server except for those that have already been denied (ie. the
  1308.   file server and Web access from the Troop network).
  1309.  
  1310.   The Troop's sockd.conf file will look like:
  1311.  
  1312.       deny 192.168.2.17 255.255.255.255
  1313.       deny 0.0.0.0 0.0.0.0 eq 80
  1314.       permit 192.168.2.0 255.255.255.0
  1315.  
  1316.   and the Mercenary file will look like:
  1317.  
  1318.       deny 192.168.2.23 255.255.255.255
  1319.       permit 192.168.2.0 255.255.255.0
  1320.  
  1321.   This should configure everything correctly.  Each network is isolated
  1322.   accordingly, with the proper amount of interaction.  Everyone should
  1323.   be happy.
  1324.  
  1325.   Now, take over the world!
  1326.  
  1327.