

       FreeBSD


Marc Silver

<marcs@draenor.org>
$FreeBSD: doc/el_GR.ISO8859-7/articles/dialup-firewall/article.sgml,v 1.20
2008/12/08 03:10:51 keramida Exp $
 FreeBSD       FreeBSD Foundation.
          
           
 .           
      FreeBSD     
 ,      : [TM]  .
          
(firewall)   PPP     FreeBSD  
IPFW.  ,        
      IP .    
           PPP. 
         PPP 
   ppp(8).
-------------------------------------------------------------------------------

1 

           
   FreeBSD   IP      ISP
.             
  ,      ,   
      : <marcs@draenor.org>.
-------------------------------------------------------------------------------

2   

      IPFW,     
   .      
  ,   _____. 
            
     IPFW:


  options IPFIREWALL
            .

           :       
            5.X  FreeBSD    .  
             4.X,       
           IPFW2       ipfw(8) 
                 IPFW2. 
              USING IPFW2 IN FreeBSD-STABLE.


  options IPFIREWALL_VERBOSE
              log  .

  options IPFIREWALL_VERBOSE_LIMIT=500
               . 
                
                
       .   500      , 
                
        .

  options IPDIVERT
        divert sockets,      .


     :       
          !    
               . 
             
             .

-------------------------------------------------------------------------------

3   /etc/rc.conf      

           
          ,  
   /etc/rc.conf.     :

  firewall_enable="YES"
  firewall_script="/etc/firewall/fwrules"

          
,     /etc/defaults/rc.conf    man 
rc.conf(5)
-------------------------------------------------------------------------------

4       PPP

             
   FreeBSD,    ,   
      PPP (NAT).  
 ,    /etc/rc.conf   :

  ppp_enable="YES"
  ppp_mode="auto"
  ppp_nat="YES"
  ppp_profile="__"

   __        ,
      /etc/ppp/ppp.conf.
-------------------------------------------------------------------------------

5    firewall

           firewall. 
          
  dialup ,    ,    
       dialup. , , 
       IPFW    
      .
          . 
    '   .  
         
      .     
     :      
,         . 
           
         .
, ,         
 .         
/etc/firewall.         
fwrules        rc.conf.    
        .      
    .
          .

  # Define the firewall command (as in /etc/rc.firewall) for easy
  # reference.  Helps to make it easier to read.
  fwcmd="/sbin/ipfw"

  # Define our outside interface.  With userland-ppp this
  # defaults to tun0.
  oif="tun0"

  # Define our inside interface.  This is usually your network
  # card.  Be sure to change this to match your own network
  # interface.
  iif="fxp0"

  # Force a flushing of the current rules before we reload.
  $fwcmd -f flush

  # Divert all packets through the tunnel interface.
  $fwcmd add divert natd all from any to any via tun0

  # Check the state of all packets.
  $fwcmd add check-state

  # Stop spoofing on the outside interface.
  $fwcmd add deny ip from any to any in via $oif not verrevpath

  # Allow all connections that we initiate, and keep their state,
  # but deny established connections that don't have a dynamic rule.
  $fwcmd add allow ip from me to any out via $oif keep-state
  $fwcmd add deny tcp from any to any established in via $oif

  # Allow all connections within our network.
  $fwcmd add allow ip from any to any via $iif

  # Allow all local traffic.
  $fwcmd add allow all from any to any via lo0
  $fwcmd add deny all from any to 127.0.0.0/8
  $fwcmd add deny ip from 127.0.0.0/8 to any

  # Allow internet users to connect to the port 22 and 80.
  # This example specifically allows connections to the sshd and a
  # webserver.
  $fwcmd add allow tcp from any to me dst-port 22,80 in via $oif setup keep-
  state

  # Allow ICMP packets: remove type 8 if you don't want your host
  # to be pingable.
  $fwcmd add allow icmp from any to any via $oif icmptypes 0,3,8,11,12

  # Deny and log all the rest.
  $fwcmd add deny log ip from any to any

     ,      22
 80          
.     .    
        .   
    ,       
   ,     email.
-------------------------------------------------------------------------------

6 



  6.1. ___limit_500_reached_on_entry_2800____
  ___________
  _.____firewall_;

  6.2. ____.______
  __.

6.1.   limit 500 reached on entry 2800     
           
.    firewall ;
          (logging)
   .       ,   
          
  .        

  # ipfw resetlog

,          
    IPFIREWALL_VERBOSE_LIMIT   . 
     (        
 reboot)   sysctl(8)  net.inet.ip.fw.verbose_limit.
6.2.    .       
 .
       userland-ppp,    
     tun0 interface,   
      ppp(8) (    user-ppp). 
     tun1,   tun2   .
       pppd(8)   interface ppp0,
        pppd(8)    
 tun0  ppp0.          
 firewall .         
fwrules_tun0.

            % cd /etc/firewall
              /etc/firewall% su
              Password:
              /etc/firewall# mv fwrules fwrules_tun0
              /etc/firewall# cat fwrules_tun0 | sed s/tun0/ppp0/g > fwrules

      ppp(8)   pppd(8)  
    ifconfig(8)     . .., 
      pppd(8)     
(    ):

            % ifconfig
              (skipped...)
              ppp0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1524
                      inet xxx.xxx.xxx.xxx --> xxx.xxx.xxx.xxx netmask
  0xff000000
              (skipped...)

  ,        ppp(8) (user-ppp) 
       :

            % ifconfig
              (skipped...)
              ppp0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
              (skipped...)
              tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1524
                      (IPv6 stuff skipped...)
                      inet xxx.xxx.xxx.xxx --> xxx.xxx.xxx.xxx netmask
  0xffffff00
                      Opened by PID xxxxx
              (skipped...)

-------------------------------------------------------------------------------
  ,   ,     ftp://ftp.FreeBSD.org/
                               pub/FreeBSD/doc/.
          FreeBSD,     
                   <questions@FreeBSD.org>.
             ,  e-mail 
                              <doc@FreeBSD.org>.
