File: ip-up

package info (click to toggle)
cipe 1.5.4free-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 908 kB
  • ctags: 730
  • sloc: ansic: 5,976; sh: 358; makefile: 315; asm: 200; perl: 45
file content (59 lines) | stat: -rwxr-xr-x 1,753 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/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