next up previous contents
Next: /etc/cipe/if-down Up: Příloha Previous: Příloha   Obsah

/etc/cipe/if-up

#!/bin/sh                                                                       
# ip-up <interface> <myaddr> <daemon-pid> <local> <remote> <arg>                
                                                                                
# Sample of the ip-up script.                                                   
# This is called when the CIPE interface is opened.                             
# Arguments:                                                                    
#  $1 interface     the CIPE interface                                          
#  $2 myaddr        our UDP address                                             
#  $3 daemon-pid    the daemon's process ID                                     
#  $4 local         IP address of our CIPE device                               
#  $5 remote        IP address of the remote CIPE device                        
#  $6 arg           argument supplied via options                               
                                                                                
# Purposes for this script: set up routes, set up proxy-arps, etc.              
# start daemons, logging...                                                     
                                                                                
umask 022                                                                       
PATH=/sbin:/bin:/usr/sbin:/usr/bin                                              
                                                                                
case `uname -r` in                                                              
2.0*)                                                                           
  # Under Linux 2.0, a minimal route to the remote CIPE is needed.              
  # 2.1 and later sets this one by itself.                                      
  route add -host $5 dev $1                                                     
  ;;                                                                            
esac                                                                            
                                                                                
# If this becomes our default route...                                          
#route add default gw $5                                                        
                                                                                
# just a logging example                                                        
now=`date "+%b %d %T"`                                                          
echo "$now UP   $*" >> /var/log/cipe.log                                        
                                                                                
# Create/update PID file. Note: PKCIPE needs this.                              
echo "$3 $1" >/var/run/cipe/${6:-$1}.pid                                        
                                                                                
# Trigger the key exchange procedure, useful when we're using SOCKS             
# This _must_ run delayed and in the background                                 
#(sleep 10; ping -c5 $5) &                                                      
                                                                                
# If the system runs gated, tell it what has happened                           
#gdc interface                                                                  
                                                                                
# The following are just ideas for further consideration                        
                                                                                
# Interconnect two 10. subnets through the Internet!                            
# Assuming $4 is in 10.1 and $5 in 10.2                                         
#route add -net 10.2.0.0 netmask 255.255.0.0 gw $5                              
                                                                                
# Proxy-ARP the peer's address on eth0                                          
#arp -i eth0 -Ds $5 eth0 pub                                                    
                                                                                
# Evil tricks department: masquerade the CIPE peer's /24 network to our IP      
#NA=`expr $5 : '\([0-9]*\.[0-9]*\.[0-9]*\.\)'`                                  
#ipfwadm -F -a accept -m -b -S $NA.0/24 -D 0.0.0.0/0                            
# the usual way for this would be a case selection on $5 or $6, however         
                                                                                
exit 0



Radek Jakoubek 2003-12-19