- import of strongswan-2.7.0

- applied patch for charon
This commit is contained in:
Martin Willi
2006-04-28 07:14:48 +00:00
parent 52923c9acb
commit 997358a6c4
2043 changed files with 346842 additions and 0 deletions
+150
View File
@@ -0,0 +1,150 @@
-------------------------------
strongSwan UML - Installation
-------------------------------
Contents
--------
1. Making the host system UML-capable
2. Installing the required files
3. Creating the UML testing environment
1. Making the host system UML-capable
----------------------------------
UML instances can be run on both Linux 2.4 and Linux 2.6 kernels.
If you are using a vanilla kernel from kernel.org then you must first
apply the host SKAS patch available from
http://www.user-mode-linux.org/~blaisorblade/patches/
and recompile and reboot your host kernel. Some Linux distributions as e.g.
SuSE already include the SKAS patch in their kernels.
You will also need the UML utilities (uml_mconsole and uml_switch)
available from
http://prdownloads.sourceforge.net/user-mode-linux/uml_utilities_20040406.tar.bz2
Many Linux distributions offer the UML utilities as a package.
2. Installing the required files
-----------------------------
First create a directory where you want the strongSwan UML testing environment
to be located.The default directory is "~/strongswan-testing". If you choose a
different location, please adapt the UMLTESTDIR variable in "testing.conf"
accordingly.
mkdir ~/strongswan-testing
Now copy the "testing" subdirectory coming with the strongSwan distribution to
the UML testing environment:
cp -r testing ~/strongswan-testing
Next you need to copy several files into the ~/strongswan-testing directory that
are required for the strongSwan testing environment:
* A vanilla Linux kernel on which the UML kernel will be based on.
We recommend the use of
http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.16.9.tar.bz2
* Starting with Linux kernel 2.6.9 no patch must be applied any more in order
to make the vanilla kernel UML-capable. For older kernels you'll find
a matching UML patch at
http://prdownloads.sourceforge.net/user-mode-linux/
* The matching .config file required to compile the UML kernel:
http://download.strongswan.org/uml/.config-2.6.16
* A gentoo-based UML file system (compressed size 130 MBytes) found at
http://download.strongswan.org/uml/gentoo-fs-20060330.tar.bz2
* The latest strongSwan distribution
http://download.strongswan.org/strongswan-2.7.0.tar.gz
3. Creating the environment
------------------------
Now change into the testing subdirectory
cd ~/strongswan-testing/testing
and make the UML testing environment:
./make-testing <hosts>
The "make-testing" script calls a series of subscripts which can be
enabled or disabled individually by setting the corresponding flags
in "testing.conf":
if [ $ENABLE_BUILD_UMLKERNEL = "yes" ]
then
scripts/build-umlkernel
fi
builds an UML kernel out of the vanilla Linux kernel and the corresponding
UML kernel patch.
if [ $ENABLE_BUILD_HOSTCONFIG = "yes" ]
then
scripts/build-hostconfig
fi
generates the default configurations for the UML hosts alice, venus, moon,
carol, winnetou, dave, sun, and bob by replacing the wildcards PH_IP_ALICE,
etc. by the actual IP addresses defined in "testing.conf".
if [ $ENABLE_BUILD_UMLROOTFS = "yes" ]
then
scripts/build-umlrootfs
fi
takes the gentoo-based UML file system and compiles the latest strongSwan
distribution into it.
if [ $ENABLE_BUILD_SSHKEYS = "yes" ]
then
scripts/build-sshkeys
fi
adds the common RSA public key of the UML instances to your ~/.ssh/known_hosts
directory so that you can log onto the UML instances using ssh without typing
in a password. The "scripts/build-sshkeys" script should only be run once.
if [ $ENABLE_BUILD_UMLHOSTFS = "yes" ]
then
scripts/build-umlhostfs <hosts>
fi
creates the customized UML file systems for the instances given as command line
arguments by adding the default host configurations to the UML root file system.
If the "make-starting" scripts is called without any arguments then by default
the UML file systems are created for the hosts alice, venus, moon, carol,
winnetou, dave, sun, and bob. Each UML root file system has as size defined by
the ROOTFSSIZE in testing.conf which by default is 544 MBytes. Thus all 8 UML
hosts plus the master copy will require a total of 5 GBytes of disk space.
if [ $ENABLE_START_TESTING = "yes" ]
then
./start-testing <hosts>
fi
starts the automated testing. More details on the tests you'll find in the
README document.
-----------------------------------------------------------------------------
This file is RCSID $Id: INSTALL,v 1.39 2006/04/24 16:58:03 as Exp $
+160
View File
@@ -0,0 +1,160 @@
------------------------------------
strongSwan UML - Running the Tests
------------------------------------
Contents
--------
1. Starting up the UML testing environment
2. Running the automated tests
3. Manual testing
1. Starting up the UML testing environment
---------------------------------------
When the strongSwan UML testing environment has been put into place by
running the "make-testing" script then you are ready to start up the
UML instances by calling
./start-testing <hosts>
This main script first calls the subscript
scripts/start-switches
that starts the three UML switches umlswitch0, umlswitch1, and umlswitch2
which are connecting the UML instances among each other and via tun/tap
devices also make them accessible from the host system.
Then depending on the setting of the UMLSTARTMODE variable defined
in "testing.conf", the UML instances given on the command line are started
up with different terminals:
If you are running the KDE graphical environment then by setting
UMLSTARTMODE=konsole
the script
scripts/kstart-umls <hosts>
is called which starts up each of the UML instances defined by <hosts> in
a KDE konsole. If
UMLSTARTMODE=xterm
is set then
scripts/xstart-umls <hosts>
starts up the UML instances in an xterm each. And with the choice
UMLSTARTMODE=screen
the instances are started up by
scripts/start-umls <hosts>
in the background but the Linux command "screen -r <host>" can be used to
connect a terminal to the UML instance <host> if desired.
if [ $ENABLE_DO_TESTS = "yes" ]
then
do-tests
fi
either executes all the tests defined in the "testing/tests" directory
if the variable SELECTEDTESTSONLY in "testing.conf" is set to "no" or the
selected tests defined by the string in SELELECTEDTESTS if SELECTEDTESTSONLY
is set to "yes".
if [ $ENABLE_STOP_TESTING = "yes" ]
then
stop-testing <hosts>
fi
stops the both the UML switches and the UML instances designated by the
<hosts> argument.
2. Running the automated tests
---------------------------
The script
./do-tests <testnames>
runs the automated tests. With an empty <testnames> argument the tests
as defined in "testing.conf" are executed, otherwise the tests enumerated
by the <testnames> argument will be run as shown in the example below.
./do-tests net2net-psk net2net-cert
Each test is divided into the following phases:
* scripts/load-testconfig <testname>
loads the UML hosts with test specific settings if such are provided.
* next the "pretest.dat" script found in each test directory is executed.
Among other commands, strongSwan is started on the IPsec hosts.
* the "evaltest.dat" script evaluates if the test has been successful.
* the "posttest.dat" script terminates the test e.g. by stopping
strongSwan on the IPsec hosts.
* scripts/restore-defaults <testname>
restores the default settings on the UML hosts.
The test results and configuration settings for all tests settings are stored
in a folder labeled with the current date in the directory
~/strongswan-testing/testresults
the same results are also automatically transferred to the Apache server
running on UML instance "winnetou" and can be accessed via the URL
http://192.168.0.150/testresults/
3. Manual testing
--------------
The greates flexibility can be achieved with manual testing. Just set
ENABLE_DO_TESTS="no"
ENABLE_STOP_TESTING="no"
in "testing.conf" and start the UML instances that you want to experiment with
by calling
./start-testing <hosts>
If you want to preload a test scenario with configurations differing from
the default values, e.g. when using Preshared Keys then you can do this
with the command
scripts/load-testconfig net2net-psk
You can then log onto any UML instance using its konsole, xterm or screen
terminal as root with the default password
tuxmux
You can then execute any commands the UML instances, including changing
and recompiling the strongSwan source code located in the /root directory.
After you have finished testing, the default configuration settings can
restored with the command
scripts/restore-defaults net2net-psk
-----------------------------------------------------------------------------
This file is RCSID $Id: README,v 1.2 2004/12/20 16:26:39 as Exp $
+458
View File
@@ -0,0 +1,458 @@
#!/bin/bash
# Automatically execute the strongSwan test cases
#
# Copyright (C) 2004 Eric Marchionni, Patrik Rayo
# Zuercher Hochschule Winterthur
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# RCSID $Id: do-tests,v 1.20 2006/02/08 21:27:59 as Exp $
DIR=`dirname $0`
source $DIR/scripts/function.sh
[ -f $DIR/testing.conf ] || die "Configuration file 'testing.conf' not found"
[ -d $DIR/hosts ] || die "Directory 'hosts' not found"
[ -d $DIR/tests ] || die "Directory 'tests' not found"
source $DIR/testing.conf
##############################################################################
# test if UMLs have been built at all
#
[ -d $BUILDDIR ] || die "Directory '$BUILDDIR' does not exist. Please run 'make-testing'first."
##############################################################################
# take care of new path and file variables
#
[ -d $TESTRESULTSDIR ] || mkdir $TESTRESULTSDIR
TESTDATE=`date +%Y%m%d-%H%M`
TODAYDIR=$TESTRESULTSDIR/$TESTDATE
mkdir $TODAYDIR
TESTRESULTSHTML=$TODAYDIR/index.html
DEFAULTTESTSDIR=$UMLTESTDIR/testing/tests
testnumber="0"
failed_cnt="0"
passed_cnt="0"
##############################################################################
# copy default tests to $BUILDDIR
#
TESTSDIR=$BUILDDIR/tests
[ -d $TESTSDIR ] || mkdir $TESTSDIR
rm -rf $TESTSDIR/*
cp -rfp $DEFAULTTESTSDIR/* $TESTSDIR
##############################################################################
# assign IP for each host to hostname
#
for host in $STRONGSWANHOSTS
do
eval ip_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $1 }' | awk '{ print $1 }'`"
case $host in
moon)
eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`"
searchandreplace PH_IP_MOON $ip_moon $TESTSDIR
searchandreplace PH_IP1_MOON $ip1_moon $TESTSDIR
;;
sun)
eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`"
searchandreplace PH_IP_SUN $ip_sun $TESTSDIR
searchandreplace PH_IP1_SUN $ip1_sun $TESTSDIR
;;
alice)
searchandreplace PH_IP_ALICE $ip_alice $TESTSDIR
;;
venus)
searchandreplace PH_IP_VENUS $ip_venus $TESTSDIR
;;
bob)
searchandreplace PH_IP_BOB $ip_bob $TESTSDIR
;;
carol)
eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`"
searchandreplace PH_IP_CAROL $ip_carol $TESTSDIR
searchandreplace PH_IP1_CAROL $ip1_carol $TESTSDIR
;;
dave)
eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`"
searchandreplace PH_IP_DAVE $ip_dave $TESTSDIR
searchandreplace PH_IP1_DAVE $ip1_dave $TESTSDIR
;;
winnetou)
searchandreplace PH_IP_WINNETOU $ip_winnetou $TESTSDIR
;;
esac
done
##############################################################################
# create header for the results html file
#
KERNEL_VERSION=`basename $KERNEL .tar.bz2`
IPSEC_VERSION=`basename $STRONGSWAN .tar.bz2`
cat > $TESTRESULTSHTML <<@EOF
<html>
<head>
<title>strongSwan UML Testing</title>
</head>
<body>
<h2>strongSwan UML Testing</h2>
<table border="0" cellspacing="2">
<tr><td><b>Host:</b></td><td>`uname -a`</td></tr>
<tr><td><b>UML kernel: &nbsp;</b></td><td>$KERNEL_VERSION</td></tr>
<tr><td><b>IPsec:</b></td><td>$IPSEC_VERSION</td></tr>
<tr><td><b>Date:</b></td><td>$TESTDATE</td></tr>
</table>
<p>
<table border="0" width="500">
<thead align="left"><th>Number</th><th>Test</th><th>Result</th></thead>
@EOF
cecho "UML kernel: $KERNEL_VERSION"
cecho "IPsec: $IPSEC_VERSION"
cecho "Date: $TESTDATE"
cecho ""
##############################################################################
# enter specific test directory
#
if [ $# -gt 0 ]
then
TESTS=$*
elif [ $SELECTEDTESTSONLY = "yes" ]
then
# set internal field seperator
TESTS=$SELECTEDTESTS
else
# set internal field seperator
TESTS="`ls $TESTSDIR`"
fi
for testname in $TESTS
do
let "testnumber += 1"
cecho-n " $testnumber $testname.."
if [ ! -d $TESTSDIR/${testname} ]
then
cecho "is missing..skipped"
continue
fi
[ -f $TESTSDIR/${testname}/description.txt ] || die "!! File 'description.txt' is missing"
[ -f $TESTSDIR/${testname}/test.conf ] || die "!! File 'test.conf' is missing"
[ -f $TESTSDIR/${testname}/pretest.dat ] || die "!! File 'pretest.dat' is missing"
[ -f $TESTSDIR/${testname}/posttest.dat ] || die "!! File 'posttest.dat' is missing"
[ -f $TESTSDIR/${testname}/evaltest.dat ] || die "!! File 'evaltest.dat' is missing"
TESTRESULTDIR=$TODAYDIR/$testname
mkdir $TESTRESULTDIR
CONSOLE_LOG=$TESTRESULTDIR/console.log
touch $CONSOLE_LOG
##########################################################################
# copy test specific configurations to uml hosts and clear auth.log files
#
$DIR/scripts/load-testconfig $testname
source $TESTSDIR/$testname/test.conf
##########################################################################
# run tcpdump in the background
#
if [ "$TCPDUMPHOSTS" != "" ]
then
echo -e "TCPDUMP\n" >> $CONSOLE_LOG 2>&1
for host_iface in $TCPDUMPHOSTS
do
host=`echo $host_iface | awk -F ":" '{print $1}'`
iface=`echo $host_iface | awk -F ":" '{if ($2 != "") { print $2 } else { printf("eth0") }}'`
tcpdump_cmd="tcpdump -i $iface not port ssh and not port domain and not arp > /tmp/tcpdump.log 2>&1 &"
echo "${host}# $tcpdump_cmd" >> $CONSOLE_LOG
ssh root@`eval echo \\\$ip_$host '$tcpdump_cmd'`
eval TDUP_${host}="true"
done
fi
##########################################################################
# execute pre-test commands
#
cecho-n "pre.."
echo -e "\nPRE-TEST\n" >> $CONSOLE_LOG 2>&1
eval `awk -F "::" '{
if ($2 != "")
{
printf("echo \"%s# %s\"; ", $1, $2)
printf("ssh root@\044ip_%s \"%s\"; ", $1, $2)
printf("echo;\n")
}
}' $TESTSDIR/${testname}/pretest.dat` >> $CONSOLE_LOG 2>&1
##########################################################################
# stop tcpdump
#
function stop_tcpdump {
echo "${1}# killall tcpdump" >> $CONSOLE_LOG
eval ssh root@\$ip_${1} killall tcpdump
eval TDUP_${1}="false"
echo ""
}
##########################################################################
# get and evaluate test results
#
cecho-n "test.."
echo -e "\nTEST\n" >> $CONSOLE_LOG 2>&1
STATUS="passed"
eval `awk -F "::" '{
host=$1
command=$2
pattern=$3
hit=$4
if (command != "")
{
if (command == "tcpdump")
{
printf("if [ \044TDUP_%s == \"true\" ]; then stop_tcpdump %s; fi; \n", host, host)
printf("echo \"%s# cat /tmp/tcpdump.log | grep \047%s\047 [%s]\"; ", host, pattern, hit)
printf("ssh root@\044ip_%s cat /tmp/tcpdump.log | grep \"%s\"; ", host, pattern)
}
else
{
printf("echo \"%s# %s | grep \047%s\047 [%s]\"; ", host, command, pattern, hit)
printf("ssh root@\044ip_%s %s | grep \"%s\"; ", host, command, pattern)
}
printf("cmd_exit=\044?; ")
printf("echo; ")
printf("if [ \044cmd_exit -eq 0 -a \"%s\" = \"NO\" ] ", hit)
printf("|| [ \044cmd_exit -ne 0 -a \"%s\" = \"YES\" ] ", hit)
printf("; then STATUS=\"failed\"; fi; \n")
}
}' $TESTSDIR/${testname}/evaltest.dat` >> $CONSOLE_LOG 2>&1
##########################################################################
# set counters
#
if [ $STATUS = "failed" ]
then
let "failed_cnt += 1"
else
let "passed_cnt += 1"
fi
##########################################################################
# log statusall and listall output
# get copies of ipsec.conf, ipsec.secrets
# create index.html for the given test case
cat > $TESTRESULTDIR/index.html <<@EOF
<html>
<head>
<title>Test $testname</title>
</head>
<body>
<table border="0" width="600">
<tr><td>
<h2>Test $testname</h2>
<h3>Description</h3>
@EOF
cat $TESTSDIR/${testname}/description.txt >> $TESTRESULTDIR/index.html
cat >> $TESTRESULTDIR/index.html <<@EOF
<ul>
<li><a href="console.log">console.log</a></li>
</ul>
<img src="../images/$DIAGRAM" alt="$UMLHOSTS">
@EOF
for host in $IPSECHOSTS
do
eval HOSTLOGIN=root@\$ip_${host}
for command in statusall listall
do
ssh $HOSTLOGIN ipsec $command \
> $TESTRESULTDIR/${host}.$command 2>/dev/null
done
for file in ipsec.conf ipsec.secrets
do
scp $HOSTLOGIN:/etc/$file \
$TESTRESULTDIR/${host}.$file > /dev/null 2>&1
done
cat >> $TESTRESULTDIR/index.html <<@EOF
<h3>$host</h3>
<ul>
<li><a href="$host.ipsec.conf">ipsec.conf</a></li>
<li><a href="$host.ipsec.secrets">ipsec.secrets</a></li>
<li><a href="$host.statusall">ipsec statusall</a></li>
<li><a href="$host.listall">ipsec listall</a></li>
<li><a href="$host.auth.log">auth.log</a></li>
</ul>
@EOF
done
cat >> $TESTRESULTDIR/index.html <<@EOF
</td></tr>
<tr><td align="right">
<b><a href="../index.html">Back</a></b>
</td></tr>
</table>
</body>
</html>
@EOF
##########################################################################
# execute post-test commands
#
cecho-n "post.."
echo -e "\nPOST-TEST\n" >> $CONSOLE_LOG 2>&1
eval `awk -F "::" '{
if ($2 != "")
{
printf("echo \"%s# %s\"; ", $1, $2)
printf("ssh root@\044ip_%s \"%s\"; ", $1, $2)
printf("echo;\n")
}
}' $TESTSDIR/${testname}/posttest.dat` >> $CONSOLE_LOG 2>&1
##########################################################################
# get a copy of /var/log/auth.log
#
for host in $IPSECHOSTS
do
eval HOSTLOGIN=root@\$ip_${host}
ssh $HOSTLOGIN grep pluto /var/log/auth.log \
> $TESTRESULTDIR/${host}.auth.log
done
##########################################################################
# stop tcpdump if necessary
#
for host in $TCPDUMPHOSTS
do
if [ "`eval echo \\\$TDUP_${host}`" = "true" ]
then
echo "${host}# killall tcpdump" >> $CONSOLE_LOG
eval ssh root@\$ip_$host killall tcpdump
eval TDUP_${host}="false"
fi
done
##########################################################################
# copy default host config back if necessary
#
$DIR/scripts/restore-defaults $testname
##########################################################################
# write test status to html file
#
cecho "$STATUS"
if [ $STATUS = "passed" ]
then
COLOR="green"
else
COLOR="red"
fi
cat >> $TESTRESULTSHTML << @EOF
<tr>
<td>$testnumber</td>
<td><a href="$testname/">$testname</a></td>
<td><a href="$testname/console.log"><font color="$COLOR">$STATUS</font></a></td>
</tr>
@EOF
done
##############################################################################
# finish the results html file
#
cat >> $TESTRESULTSHTML << @EOF
</table>
<p>
<b>Passed: &nbsp; $passed_cnt</b><br>
<b>Failed: &nbsp; $failed_cnt</b><br>
<p>
</body>
</html>
@EOF
cecho ""
cecho "Passed: $passed_cnt"
cecho "Failed: $failed_cnt"
cecho ""
##############################################################################
# copy the test results to the apache server
#
HTDOCS="/var/www/localhost/htdocs"
cecho-n "Copying test results to winnetou.."
ssh root@${ip_winnetou} mkdir -p $HTDOCS/testresults > /dev/null 2>&1
scp -r $TODAYDIR root@${ip_winnetou}:$HTDOCS/testresults > /dev/null 2>&1
ssh root@${ip_winnetou} ln -s $HTDOCS/images $HTDOCS/testresults/$TESTDATE/images > /dev/null 2>&1
cecho "done"
cecho ""
cecho "The results are available in $TODAYDIR"
cecho "or via the link http://$ip_winnetou/testresults/$TESTDATE"
+1
View File
@@ -0,0 +1 @@
HOSTNAME=alice
+11
View File
@@ -0,0 +1,11 @@
# /etc/conf.d/net:
# This is basically the ifconfig argument without the ifconfig $iface
#
iface_lo="127.0.0.1 netmask 255.0.0.0"
iface_eth0="PH_IP_ALICE broadcast 10.1.255.255 netmask 255.255.0.0"
# For setting the default gateway
#
gateway="eth0/PH_IP1_MOON"
+74
View File
@@ -0,0 +1,74 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
opts="start stop reload"
depend() {
before net
need logger
}
start() {
ebegin "Starting firewall"
# default policy is DROP
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT DROP
/sbin/iptables -P FORWARD DROP
# allow IKE
iptables -A INPUT -i eth0 -p udp --sport 500 --dport 500 -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
# allow NAT-T
iptables -A INPUT -i eth0 -p udp --sport 4500 --dport 4500 -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp --dport 4500 --sport 4500 -j ACCEPT
# allow crl fetch from winnetou
iptables -A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
# allow ssh
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
eend $?
}
stop() {
ebegin "Stopping firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
if [ $a == nat ]; then
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT
elif [ $a == mangle ]; then
/sbin/iptables -t mangle -P PREROUTING ACCEPT
/sbin/iptables -t mangle -P INPUT ACCEPT
/sbin/iptables -t mangle -P FORWARD ACCEPT
/sbin/iptables -t mangle -P OUTPUT ACCEPT
/sbin/iptables -t mangle -P POSTROUTING ACCEPT
elif [ $a == filter ]; then
/sbin/iptables -t filter -P INPUT ACCEPT
/sbin/iptables -t filter -P FORWARD ACCEPT
/sbin/iptables -t filter -P OUTPUT ACCEPT
fi
done
eend $?
}
reload() {
ebegin "Flushing firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
done;
eend $?
start
}
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+25
View File
@@ -0,0 +1,25 @@
# /etc/ipsec.conf - strongSwan IPsec configuration file
version 2.0 # conforms to second version of ipsec.conf specification
config setup
plutodebug=control
crlcheckinterval=180
strictcrlpolicy=no
nat_traversal=yes
conn %default
ikelifetime=60m
keylife=20m
rekeymargin=3m
keyingtries=1
conn nat-t
left=%defaultroute
leftcert=aliceCert.pem
[email protected]
leftfirewall=yes
right=PH_IP_SUN
[email protected]
rightsubnet=10.2.0.0/16
auto=add
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDtTCCAp2gAwIBAgIBADANBgkqhkiG9w0BAQQFADBFMQswCQYDVQQGEwJDSDEZ
MBcGA1UEChMQTGludXggc3Ryb25nU3dhbjEbMBkGA1UEAxMSc3Ryb25nU3dhbiBS
b290IENBMB4XDTA0MDkxMDExMDE0NVoXDTE0MDkwODExMDE0NVowRTELMAkGA1UE
BhMCQ0gxGTAXBgNVBAoTEExpbnV4IHN0cm9uZ1N3YW4xGzAZBgNVBAMTEnN0cm9u
Z1N3YW4gUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL/y
X2LqPVZuWLPIeknK86xhz6ljd3NNhC2z+P1uoCP3sBMuZiZQEjFzhnKcbXxCeo2f
FnvhOOjrrisSuVkzuu82oxXD3fIkzuS7m9V4E10EZzgmKWIf+WuNRfbgAuUINmLc
4YGAXBQLPyzpP4Ou48hhz/YQo58Bics6PHy5v34qCVROIXDvqhj91P8g+pS+F21/
7P+CH2jRcVIEHZtG8M/PweTPQ95dPzpYd2Ov6SZ/U7EWmbMmT8VcUYn1aChxFmy5
gweVBWlkH6MP+1DeE0/tL5c87xo5KCeGK8Tdqpe7sBRC4pPEEHDQciTUvkeuJ1Pr
K+1LwdqRxo7HgMRiDw8CAwEAAaOBrzCBrDAPBgNVHRMBAf8EBTADAQH/MAsGA1Ud
DwQEAwIBBjAdBgNVHQ4EFgQUXafdcAZRMn7ntm2zteXgYOouTe8wbQYDVR0jBGYw
ZIAUXafdcAZRMn7ntm2zteXgYOouTe+hSaRHMEUxCzAJBgNVBAYTAkNIMRkwFwYD
VQQKExBMaW51eCBzdHJvbmdTd2FuMRswGQYDVQQDExJzdHJvbmdTd2FuIFJvb3Qg
Q0GCAQAwDQYJKoZIhvcNAQEEBQADggEB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StSTaxfN2vI72rt6sz0WzJdD
idD7X3oezzboXwjaIANDqkV6LhGwuLXa898/yCLjErRzZ0kzptiRCnT3w9pjrK3w
/rN7v2sCgYAEwfgrwjb7+JUaSSaf6TlbM9/ZuTRBVN0OTQz2JVhokeAePeFjHzXt
nzJI2ETYlIu6e1VaFzHb6dp84PzWfLV7Kk8hZqJeCQN4RmQ04oNBllWoOZPbN7oa
8pAMk/DCsBxcM/GvnDQJlDVLQRyY64zJU8EI0rF1t+zosIyGtXom/A==
-----END RSA PRIVATE KEY-----
+9
View File
@@ -0,0 +1,9 @@
# /etc/ipsec.secrets - strongSwan IPsec secrets file
: RSA aliceKey.pem
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+1
View File
@@ -0,0 +1 @@
HOSTNAME=bob
+10
View File
@@ -0,0 +1,10 @@
# /etc/conf.d/net:
# This is basically the ifconfig argument without the ifconfig $iface
#
iface_lo="127.0.0.1 netmask 255.0.0.0"
iface_eth0="PH_IP_BOB broadcast 10.2.255.255 netmask 255.255.0.0"
# For setting the default gateway
#
gateway="eth0/PH_IP1_SUN"
+74
View File
@@ -0,0 +1,74 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
opts="start stop reload"
depend() {
before net
need logger
}
start() {
ebegin "Starting firewall"
# default policy is DROP
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT DROP
/sbin/iptables -P FORWARD DROP
# allow IKE
iptables -A INPUT -i eth0 -p udp --dport 500 -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp --sport 500 -j ACCEPT
# allow NAT-T
iptables -A INPUT -i eth0 -p udp --dport 4500 -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp --sport 4500 -j ACCEPT
# allow crl fetch from winnetou
iptables -A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
# allow ssh
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
eend $?
}
stop() {
ebegin "Stopping firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
if [ $a == nat ]; then
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT
elif [ $a == mangle ]; then
/sbin/iptables -t mangle -P PREROUTING ACCEPT
/sbin/iptables -t mangle -P INPUT ACCEPT
/sbin/iptables -t mangle -P FORWARD ACCEPT
/sbin/iptables -t mangle -P OUTPUT ACCEPT
/sbin/iptables -t mangle -P POSTROUTING ACCEPT
elif [ $a == filter ]; then
/sbin/iptables -t filter -P INPUT ACCEPT
/sbin/iptables -t filter -P FORWARD ACCEPT
/sbin/iptables -t filter -P OUTPUT ACCEPT
fi
done
eend $?
}
reload() {
ebegin "Flushing firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
done;
eend $?
start
}
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+24
View File
@@ -0,0 +1,24 @@
# /etc/ipsec.conf - strongSwan IPsec configuration file
version 2.0 # conforms to second version of ipsec.conf specification
config setup
plutodebug=control
crlcheckinterval=180
strictcrlpolicy=no
nat_traversal=yes
conn %default
ikelifetime=60m
keylife=20m
rekeymargin=3m
keyingtries=1
conn nat-t
left=%defaultroute
leftcert=bobCert.pem
[email protected]
leftfirewall=yes
right=%any
rightsubnetwithin=10.1.0.0/16
auto=add
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDtTCCAp2gAwIBAgIBADANBgkqhkiG9w0BAQQFADBFMQswCQYDVQQGEwJDSDEZ
MBcGA1UEChMQTGludXggc3Ryb25nU3dhbjEbMBkGA1UEAxMSc3Ryb25nU3dhbiBS
b290IENBMB4XDTA0MDkxMDExMDE0NVoXDTE0MDkwODExMDE0NVowRTELMAkGA1UE
BhMCQ0gxGTAXBgNVBAoTEExpbnV4IHN0cm9uZ1N3YW4xGzAZBgNVBAMTEnN0cm9u
Z1N3YW4gUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL/y
X2LqPVZuWLPIeknK86xhz6ljd3NNhC2z+P1uoCP3sBMuZiZQEjFzhnKcbXxCeo2f
FnvhOOjrrisSuVkzuu82oxXD3fIkzuS7m9V4E10EZzgmKWIf+WuNRfbgAuUINmLc
4YGAXBQLPyzpP4Ou48hhz/YQo58Bics6PHy5v34qCVROIXDvqhj91P8g+pS+F21/
7P+CH2jRcVIEHZtG8M/PweTPQ95dPzpYd2Ov6SZ/U7EWmbMmT8VcUYn1aChxFmy5
gweVBWlkH6MP+1DeE0/tL5c87xo5KCeGK8Tdqpe7sBRC4pPEEHDQciTUvkeuJ1Pr
K+1LwdqRxo7HgMRiDw8CAwEAAaOBrzCBrDAPBgNVHRMBAf8EBTADAQH/MAsGA1Ud
DwQEAwIBBjAdBgNVHQ4EFgQUXafdcAZRMn7ntm2zteXgYOouTe8wbQYDVR0jBGYw
ZIAUXafdcAZRMn7ntm2zteXgYOouTe+hSaRHMEUxCzAJBgNVBAYTAkNIMRkwFwYD
VQQKExBMaW51eCBzdHJvbmdTd2FuMRswGQYDVQQDExJzdHJvbmdTd2FuIFJvb3Qg
Q0GCAQAwDQYJKoZIhvcNAQEEBQADggEBAJrXTj5gWS37myHHhii9dr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Y1QdZaYl356DaqP1dRuEAJ/UDE/fUQj
DlIWT/Re0pFRwQxwaUAY+oOStZHUsL8G9SliB43a1FO0jm/h8LIoZBBCX+ItUGfY
RBZ+UwKBgCToB2oPwDfrfCkScNozV7GPfcmHTR5bvvpYgRMGyuE1hAwLIWW9V4u9
1Bp1vCR/C4kiUSBpYsGXLRqJ1GURueQoEbREE4ZvkmNV+t40uX3Fd8/OchAGi934
0jYmd3dvN4MtF7O02YwpBzuH/wAwdxK0iDbdv+KEZb7TLdL37IN1
-----END RSA PRIVATE KEY-----
+8
View File
@@ -0,0 +1,8 @@
# /etc/ipsec.secrets - strongSwan IPsec secrets file
: RSA bobKey.pem
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+1
View File
@@ -0,0 +1 @@
HOSTNAME=carol
+10
View File
@@ -0,0 +1,10 @@
# /etc/conf.d/net:
# This is basically the ifconfig argument without the ifconfig $iface
#
iface_lo="127.0.0.1 netmask 255.0.0.0"
iface_eth0="PH_IP_CAROL broadcast 192.168.0.255 netmask 255.255.255.0"
# For setting the default gateway
#
gateway="eth0/192.168.0.254"
+73
View File
@@ -0,0 +1,73 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
opts="start stop reload"
depend() {
before net
need logger
}
start() {
ebegin "Starting firewall"
# default policy is DROP
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT DROP
/sbin/iptables -P FORWARD DROP
# allow esp
iptables -A INPUT -i eth0 -p 50 -j ACCEPT
iptables -A OUTPUT -o eth0 -p 50 -j ACCEPT
# allow IKE
iptables -A INPUT -i eth0 -p udp --sport 500 --dport 500 -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
# allow crl fetch from winnetou
iptables -A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
# allow ssh
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
eend $?
}
stop() {
ebegin "Stopping firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
if [ $a == nat ]; then
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT
elif [ $a == mangle ]; then
/sbin/iptables -t mangle -P PREROUTING ACCEPT
/sbin/iptables -t mangle -P INPUT ACCEPT
/sbin/iptables -t mangle -P FORWARD ACCEPT
/sbin/iptables -t mangle -P OUTPUT ACCEPT
/sbin/iptables -t mangle -P POSTROUTING ACCEPT
elif [ $a == filter ]; then
/sbin/iptables -t filter -P INPUT ACCEPT
/sbin/iptables -t filter -P FORWARD ACCEPT
/sbin/iptables -t filter -P OUTPUT ACCEPT
fi
done
eend $?
}
reload() {
ebegin "Flushing firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
done;
eend $?
start
}
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+29
View File
@@ -0,0 +1,29 @@
# /etc/ipsec.conf - strongSwan IPsec configuration file
version 2.0 # conforms to second version of ipsec.conf specification
config setup
plutodebug=control
crlcheckinterval=180
strictcrlpolicy=no
conn %default
ikelifetime=60m
keylife=20m
rekeymargin=3m
keyingtries=1
conn home
left=PH_IP_CAROL
leftnexthop=%direct
leftcert=carolCert.pem
[email protected]
leftfirewall=yes
right=PH_IP_MOON
rightsubnet=10.1.0.0/16
[email protected]
auto=add
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDtTCCAp2gAwIBAgIBADANBgkqhkiG9w0BAQQFADBFMQswCQYDVQQGEwJDSDEZ
MBcGA1UEChMQTGludXggc3Ryb25nU3dhbjEbMBkGA1UEAxMSc3Ryb25nU3dhbiBS
b290IENBMB4XDTA0MDkxMDExMDE0NVoXDTE0MDkwODExMDE0NVowRTELMAkGA1UE
BhMCQ0gxGTAXBgNVBAoTEExpbnV4IHN0cm9uZ1N3YW4xGzAZBgNVBAMTEnN0cm9u
Z1N3YW4gUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL/y
X2LqPVZuWLPIeknK86xhz6ljd3NNhC2z+P1uoCP3sBMuZiZQEjFzhnKcbXxCeo2f
FnvhOOjrrisSuVkzuu82oxXD3fIkzuS7m9V4E10EZzgmKWIf+WuNRfbgAuUINmLc
4YGAXBQLPyzpP4Ou48hhz/YQo58Bics6PHy5v34qCVROIXDvqhj91P8g+pS+F21/
7P+CH2jRcVIEHZtG8M/PweTPQ95dPzpYd2Ov6SZ/U7EWmbMmT8VcUYn1aChxFmy5
gweVBWlkH6MP+1DeE0/tL5c87xo5KCeGK8Tdqpe7sBRC4pPEEHDQciTUvkeuJ1Pr
K+1LwdqRxo7HgMRiDw8CAwEAAaOBrzCBrDAPBgNVHRMBAf8EBTADAQH/MAsGA1Ud
DwQEAwIBBjAdBgNVHQ4EFgQUXafdcAZRMn7ntm2zteXgYOouTe8wbQYDVR0jBGYw
ZIAUXafdcAZRMn7ntm2zteXgYOouTe+hSaRHMEUxCzAJBgNVBAYTAkNIMRkwFwYD
VQQKExBMaW51eCBzdHJvbmdTd2FuMRswGQYDVQQDExJzdHJvbmdTd2FuIFJvb3Qg
Q0GCAQAwDQYJKoZIhvcNAQEEBQADggEBAJrXT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EpBpTHCIrWky
fvSBZ+EXngyQi2J4qyYOXijdNpBvbNrLOeEPSNv4di39D05DLITbLJgoUBnwy3Fj
ZWNR+QKBgEKn19f5QWs/O1DPWBXfvCSc01cuSUx20a6Z3B6Lxj+7MuXBjVxPkGge
kEaZnNzwgm+QQ1C51nIn9gY4LZx7OxMy0idEss76aRq4Lb7I6XakBrCQLQ9IiTkv
gNOeJYGsQv7tkIWWRlBIXjSBGwT6HzTEfN5cvdHSDzARGFGjwYfK
-----END RSA PRIVATE KEY-----
+7
View File
@@ -0,0 +1,7 @@
# /etc/ipsec.secrets - strongSwan IPsec secrets file
: RSA carolKey.pem
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+1
View File
@@ -0,0 +1 @@
HOSTNAME=dave
+10
View File
@@ -0,0 +1,10 @@
# /etc/conf.d/net:
# This is basically the ifconfig argument without the ifconfig $iface
#
iface_lo="127.0.0.1 netmask 255.0.0.0"
iface_eth0="PH_IP_DAVE broadcast 192.168.0.255 netmask 255.255.255.0"
# For setting the default gateway
#
gateway="eth0/192.168.0.254"
+73
View File
@@ -0,0 +1,73 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
opts="start stop reload"
depend() {
before net
need logger
}
start() {
ebegin "Starting firewall"
# default policy is DROP
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT DROP
/sbin/iptables -P FORWARD DROP
# allow esp
iptables -A INPUT -i eth0 -p 50 -j ACCEPT
iptables -A OUTPUT -o eth0 -p 50 -j ACCEPT
# allow IKE
iptables -A INPUT -i eth0 -p udp --sport 500 --dport 500 -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
# allow crl fetch from winnetou
iptables -A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
# allow ssh
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
eend $?
}
stop() {
ebegin "Stopping firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
if [ $a == nat ]; then
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT
elif [ $a == mangle ]; then
/sbin/iptables -t mangle -P PREROUTING ACCEPT
/sbin/iptables -t mangle -P INPUT ACCEPT
/sbin/iptables -t mangle -P FORWARD ACCEPT
/sbin/iptables -t mangle -P OUTPUT ACCEPT
/sbin/iptables -t mangle -P POSTROUTING ACCEPT
elif [ $a == filter ]; then
/sbin/iptables -t filter -P INPUT ACCEPT
/sbin/iptables -t filter -P FORWARD ACCEPT
/sbin/iptables -t filter -P OUTPUT ACCEPT
fi
done
eend $?
}
reload() {
ebegin "Flushing firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
done;
eend $?
start
}
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+24
View File
@@ -0,0 +1,24 @@
# /etc/ipsec.conf - strongSwan IPsec configuration file
version 2.0 # conforms to second version of ipsec.conf specification
config setup
plutodebug=control
crlcheckinterval=180
strictcrlpolicy=no
conn %default
ikelifetime=60m
keylife=20m
rekeymargin=3m
keyingtries=1
conn home
left=PH_IP_DAVE
leftcert=daveCert.pem
[email prot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Atz8NWlG5mvFxExFaRjX9QcEXlu/KnECkbE3Qs/wewNEXkk3f+VywSfkAJ3f/P
6bVvot0CgYBA1B9SXYhclR3KNZJPRuTn9OQ/TqLmcCMN62dIhPW4WZo2ixZH3YdS
PE/bYmYfZUPt7MnOSNSnuLKineIf1Dipz0gjuSyFGAs5DE+N+8GWYo00n+0e3TLL
pcBj4nOdIVPTZ31IFeVbi06dCYmzLPAGDeLe1M1Z7fakNky1Wv+Sdg==
-----END RSA PRIVATE KEY-----
+7
View File
@@ -0,0 +1,7 @@
# /etc/ipsec.secrets - strongSwan IPsec secrets file
: RSA daveKey.pem
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+34
View File
@@ -0,0 +1,34 @@
# /etc/hosts: This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server. Just add the names, addresses
# and any aliases to this file...
#
127.0.0.1 localhost
192.168.0.254 uml0.strongswan.org uml0
10.1.0.254 uml1.strongswan.org uml1
10.2.0.254 uml1.strongswan.org uml2
PH_IP_ALICE alice.strongswan.org alice
PH_IP_VENUS venus.strongswan.org venus
PH_IP1_MOON moon1.strongswan.org moon1
PH_IP_MOON moon.strongswan.org moon
PH_IP_CAROL carol.strongswan.org carol
PH_IP1_CAROL carol1.strongswan.org carol1
PH_IP_WINNETOU winnetou.strongswan.org winnetou crl.strongswan.org ocsp.strongswan.org ldap.strongswan.org
PH_IP_DAVE dave.strongswan.org dave
PH_IP1_DAVE dave1.strongswan.org dave1
PH_IP_SUN sun.strongswan.org sun
PH_IP1_SUN sun1.strongswan.org sun1
PH_IP_BOB bob.strongswan.org bob
# IPV6 versions of localhost and co
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
+1
View File
@@ -0,0 +1 @@
HOSTNAME=moon
+11
View File
@@ -0,0 +1,11 @@
# /etc/conf.d/net:
# This is basically the ifconfig argument without the ifconfig $iface
#
iface_lo="127.0.0.1 netmask 255.0.0.0"
iface_eth0="PH_IP_MOON broadcast 192.168.0.255 netmask 255.255.255.0"
iface_eth1="PH_IP1_MOON broadcast 10.1.255.255 netmask 255.255.0.0"
# For setting the default gateway
#
gateway="eth0/192.168.0.254"
+76
View File
@@ -0,0 +1,76 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
opts="start stop reload"
depend() {
before net
need logger
}
start() {
ebegin "Starting firewall"
# enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
# default policy is DROP
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT DROP
/sbin/iptables -P FORWARD DROP
# allow esp
iptables -A INPUT -i eth0 -p 50 -j ACCEPT
iptables -A OUTPUT -o eth0 -p 50 -j ACCEPT
# allow IKE
iptables -A INPUT -i eth0 -p udp --sport 500 --dport 500 -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
# allow crl fetch from winnetou
iptables -A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
# allow ssh
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
eend $?
}
stop() {
ebegin "Stopping firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
if [ $a == nat ]; then
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT
elif [ $a == mangle ]; then
/sbin/iptables -t mangle -P PREROUTING ACCEPT
/sbin/iptables -t mangle -P INPUT ACCEPT
/sbin/iptables -t mangle -P FORWARD ACCEPT
/sbin/iptables -t mangle -P OUTPUT ACCEPT
/sbin/iptables -t mangle -P POSTROUTING ACCEPT
elif [ $a == filter ]; then
/sbin/iptables -t filter -P INPUT ACCEPT
/sbin/iptables -t filter -P FORWARD ACCEPT
/sbin/iptables -t filter -P OUTPUT ACCEPT
fi
done
eend $?
}
reload() {
ebegin "Flushing firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
done;
eend $?
start
}
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+36
View File
@@ -0,0 +1,36 @@
# /etc/ipsec.conf - strongSwan IPsec configuration file
version 2.0 # conforms to second version of ipsec.conf specification
config setup
plutodebug=control
crlcheckinterval=180
strictcrlpolicy=no
conn %default
ikelifetime=60m
keylife=20m
rekeymargin=3m
keyingtries=1
left=192.168.0.1
leftnexthop=%direct
leftcert=moonCert.pem
[email protected]
leftfirewall=yes
conn net-net
leftsubnet=10.1.0.0/16
right=192.168.0.2
rightsubnet=10.2.0.0/16
[email protected]
auto=add
conn host-host
right=192.168.0.2
[email protected]
auto=add
conn rw
leftsubnet=10.1.0.0/16
right=%any
auto=add
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDtTCCAp2gAwIBAgIBADANBgkqhkiG9w0BAQQFADBFMQswCQYDVQQGEwJDSDEZ
MBcGA1UEChMQTGludXggc3Ryb25nU3dhbjEbMBkGA1UEAxMSc3Ryb25nU3dhbiBS
b290IENBMB4XDTA0MDkxMDExMDE0NVoXDTE0MDkwODExMDE0NVowRTELMAkGA1UE
BhMCQ0gxGTAXBgNVBAoTEExpbnV4IHN0cm9uZ1N3YW4xGzAZBgNVBAMTEnN0cm9u
Z1N3YW4gUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL/y
X2LqPVZuWLPIeknK86xhz6ljd3NNhC2z+P1uoCP3sBMuZiZQEjFzhnKcbXxCeo2f
FnvhOOjrrisSuVkzuu82oxXD3fIkzuS7m9V4E10EZzgmKWIf+WuNRfbgAuUINmLc
4YGAXBQLPyzpP4Ou48hhz/YQo58Bics6PHy5v34qCVROIXDvqhj91P8g+pS+F21/
7P+CH2jRcVIEHZtG8M/PweTPQ95d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TZ0oGNdgt5phyc3ROBSH
cjqZdzpim1gXGm4ocGvwg3APNQN6DLBknJNZmHzPd7RLSz2UxhTHRTfHAltQPcmW
cJVBHsrsS0QnvDndXfzLuLq12S6UZasR5eBdcxkCgYEAizBuOI6DdGG4nceG8lbH
mRwY8xtq3h66d7skLMBxp9ByaVS76bYsrCZVn6Fl0EtlNuMUb52uRzPIO3F9FwUA
MFHoHpC1YibKwYdAwKcAm07T7950x/eVDm+NLB2VHDBHfruLQogiubEF4/VKSaA2
Xm1/iVaD9bJzAZw7vWY9/BkCgYB/Xe9uErGmgkB0BaLIuiNWxfKFOn+id4v01uNk
yHtOW10TgCNCdDi3sdpjs1CIuAhXDdDuav7itLuwdMOCkFI16+EdF29Mwv7TaW4h
sq01i5R9BO03zZIg6Z7ZZr4Dg+OM3fNzs65RSn/KcE0V/kYwa/So8MVw5/VIauYn
MmnYmQKBgDEFWQPyPH242olRqtE0yDp8qVHEjJp7mU822YFbyCyAUnttqOS+/5/u
Z7H95QZHGaQESL1tcNnaiRASJAKDWjKOdM/TTotWjCn65v+DHvgk/IJeYJVHoGBS
pBE+wJ8AZJu3t9GVp3PxFxHIjxUrEKG0rli7bYv8F245+Wx8DeXI
-----END RSA PRIVATE KEY-----
+7
View File
@@ -0,0 +1,7 @@
# /etc/ipsec.secrets - strongSwan IPsec secrets file
: RSA moonKey.pem
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+1
View File
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAsxKfTm05po6leGD8C+M0eAR5EE4s1pQXc0D/dVlqrmfZ65h5BFQY9lnwpCvapV6OVqKWx8ICmeIH3OhaPxPPNKlU81f3d0xgh8BRJpWh459DYkRVa5f7ax5eeFE1lelj9s1d0seUl/IZolpJ8Wmt9TN1hwJ0mrkwN4670rb3urc=
+1
View File
@@ -0,0 +1 @@
HOSTNAME=sun
+13
View File
@@ -0,0 +1,13 @@
# /etc/conf.d/net:
# This is basically the ifconfig argument without the ifconfig $iface
#
iface_lo="127.0.0.1 netmask 255.0.0.0"
iface_eth0="PH_IP_SUN broadcast 192.168.0.255 netmask 255.255.255.0"
iface_eth1="PH_IP1_SUN broadcast 10.2.255.255 netmask 255.255.0.0"
# For setting the default gateway
#
gateway="eth0/192.168.0.254"
+80
View File
@@ -0,0 +1,80 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
opts="start stop reload"
depend() {
before net
need logger
}
start() {
ebegin "Starting firewall"
# enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
# default policy is DROP
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT DROP
/sbin/iptables -P FORWARD DROP
# allow esp
iptables -A INPUT -i eth0 -p 50 -j ACCEPT
iptables -A OUTPUT -o eth0 -p 50 -j ACCEPT
# allow IKE
iptables -A INPUT -i eth0 -p udp --dport 500 -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp --sport 500 -j ACCEPT
# allow NAT-T
iptables -A INPUT -i eth0 -p udp --dport 4500 -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp --sport 4500 -j ACCEPT
# allow crl fetch from winnetou
iptables -A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
# allow ssh
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
eend $?
}
stop() {
ebegin "Stopping firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
if [ $a == nat ]; then
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT
elif [ $a == mangle ]; then
/sbin/iptables -t mangle -P PREROUTING ACCEPT
/sbin/iptables -t mangle -P INPUT ACCEPT
/sbin/iptables -t mangle -P FORWARD ACCEPT
/sbin/iptables -t mangle -P OUTPUT ACCEPT
/sbin/iptables -t mangle -P POSTROUTING ACCEPT
elif [ $a == filter ]; then
/sbin/iptables -t filter -P INPUT ACCEPT
/sbin/iptables -t filter -P FORWARD ACCEPT
/sbin/iptables -t filter -P OUTPUT ACCEPT
fi
done
eend $?
}
reload() {
ebegin "Flushing firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
done;
eend $?
start
}
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+37
View File
@@ -0,0 +1,37 @@
# /etc/ipsec.conf - strongSwan IPsec configuration file
version 2.0 # conforms to second version of ipsec.conf specification
config setup
plutodebug=control
crlcheckinterval=180
strictcrlpolicy=no
nat_traversal=yes
conn %default
ikelifetime=60m
keylife=20m
rekeymargin=3m
keyingtries=1
left=PH_IP_SUN
leftcert=sunCert.pem
[email protected]
leftfirewall=yes
conn net-net
leftsubnet=10.2.0.0/16
right=PH_IP_MOON
rightsubnet=10.1.0.0/16
[email protected]
auto=add
conn host-host
right=PH_IP_MOON
[email protected]
auto=add
conn nat-t
leftsubnet=10.2.0.0/16
right=%any
rightsubnetwithin=10.1.0.0/16
auto=add
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDtTCCAp2gAwIBAgIBADANBgkqhkiG9w0BAQQFADBFMQswCQYDVQQGEwJDSDEZ
MBcGA1UEChMQTGludXggc3Ryb25nU3dhbjEbMBkGA1UEAxMSc3Ryb25nU3dhbiBS
b290IENBMB4XDTA0MDkxMDExMDE0NVoXDTE0MDkwODExMDE0NVowRTELMAkGA1UE
BhMCQ0gxGTAXBgNVBAoTEExpbnV4IHN0cm9uZ1N3YW4xGzAZBgNVBAMTEnN0cm9u
Z1N3YW4gUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL/y
X2LqPVZuWLPIeknK86xhz6ljd3NNhC2z+P1uoCP3sBMuZiZQEjFzhnKcbXxCeo2f
FnvhOOjrrisSuVkzuu82oxXD3fIkzuS7m9V4E10EZzgmKWIf+WuNRfbgAuUINmLc
4YGAXBQLPyzpP4Ou48hhz/YQo58Bics6PHy5v34qCVROIXDvqhj91P8g+pS+F21/
7P+CH2jRcVIEHZtG8M/PweTPQ95dPzpYd2Ov6SZ/U7EWmbMmT8VcUYn1aChxFmy5
gweVBWlkH6MP+1DeE0/tL5c87xo5KCeGK8Tdqpe7sBRC4pPEEHDQciTUvkeuJ1Pr
K+1LwdqRxo7HgMRiDw8CAwEAAaOBrzCBrDAPBgNVHRMBAf8EBTADAQH/MAsGA1Ud
DwQEAwIBBjAdBgNVHQ4EFgQUXafdcAZRMn7ntm2zteXgYOouTe8wbQYDVR0jBGYw
ZIAUXafdcAZRMn7ntm2zteXgYOouTe+hSaRHMEUxCzAJBgNVBAYTAkNIMRkw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o4k
ECOlPeBryN5brGTY4w58IwKBgQC0ukRF2I+qoP/mNg4Yu2KtfM4jlG4072G+P9eF
PhSO9p+pCkhKbFD8RWDWUsslJmL09OXIkmkP4zIYmvieLOLFEjLHZi2YGER/SuMg
9B74EQsKW5sK5hF9AXOsIaQI04Hu0lFAlHbC11euAiMShOdNiMG4d3ArSVVK+bb+
hsAP0QKBgHcJuTJ6dv77evW3MFZPRjFH25pike40PWmSLgCt5PV25DRL2UG0pOut
uybN9biQK5v377/3GD7eOL+acxHODjWmmfeEFW0YlJ1oUb/P8NlqsSnHvUoIqa24
JmTXS/XzjgxQFFfzo0c1/1JLdG6r5CLTWxHq1EhIOJsowTlrCzX/
-----END RSA PRIVATE KEY-----
+8
View File
@@ -0,0 +1,8 @@
# /etc/ipsec.secrets - strongSwan IPsec secrets file
: RSA sunKey.pem
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+1
View File
@@ -0,0 +1 @@
HOSTNAME=venus
+11
View File
@@ -0,0 +1,11 @@
# /etc/conf.d/net:
# This is basically the ifconfig argument without the ifconfig $iface
#
iface_lo="127.0.0.1 netmask 255.0.0.0"
iface_eth0="PH_IP_VENUS broadcast 10.1.255.255 netmask 255.255.0.0"
# For setting the default gateway
#
gateway="eth0/PH_IP1_MOON"
+74
View File
@@ -0,0 +1,74 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
opts="start stop reload"
depend() {
before net
need logger
}
start() {
ebegin "Starting firewall"
# default policy is DROP
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT DROP
/sbin/iptables -P FORWARD DROP
# allow IKE
iptables -A INPUT -i eth0 -p udp --sport 500 --dport 500 -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
# allow NAT-T
iptables -A INPUT -i eth0 -p udp --sport 4500 --dport 4500 -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp --dport 4500 --sport 4500 -j ACCEPT
# allow crl fetch from winnetou
iptables -A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
# allow ssh
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
eend $?
}
stop() {
ebegin "Stopping firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
if [ $a == nat ]; then
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT
elif [ $a == mangle ]; then
/sbin/iptables -t mangle -P PREROUTING ACCEPT
/sbin/iptables -t mangle -P INPUT ACCEPT
/sbin/iptables -t mangle -P FORWARD ACCEPT
/sbin/iptables -t mangle -P OUTPUT ACCEPT
/sbin/iptables -t mangle -P POSTROUTING ACCEPT
elif [ $a == filter ]; then
/sbin/iptables -t filter -P INPUT ACCEPT
/sbin/iptables -t filter -P FORWARD ACCEPT
/sbin/iptables -t filter -P OUTPUT ACCEPT
fi
done
eend $?
}
reload() {
ebegin "Flushing firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
done;
eend $?
start
}
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+25
View File
@@ -0,0 +1,25 @@
# /etc/ipsec.conf - strongSwan IPsec configuration file
version 2.0 # conforms to second version of ipsec.conf specification
config setup
plutodebug=control
crlcheckinterval=180
strictcrlpolicy=no
nat_traversal=yes
conn %default
ikelifetime=60m
keylife=20m
rekeymargin=3m
keyingtries=1
conn nat-t
left=%defaultroute
leftcert=venusCert.pem
[email protected]
leftfirewall=yes
right=PH_IP_SUN
[email protected]
rightsubnet=10.2.0.0/16
auto=add
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDtTCCAp2gAwIBAgIBADANBgkqhkiG9w0BAQQFADBFMQswCQYDVQQGEwJDSDEZ
MBcGA1UEChMQTGludXggc3Ryb25nU3dhbjEbMBkGA1UEAxMSc3Ryb25nU3dhbiBS
b290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PRIVATE KEY-----
+8
View File
@@ -0,0 +1,8 @@
# /etc/ipsec.secrets - strongSwan IPsec secrets file
: RSA venusKey.pem
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDtTCCAp2gAwIBAgIBADANBgkqhkiG9w0BAQQFADBFMQswCQYDVQQGEwJDSDEZ
MBcGA1UEChMQTGludXggc3Ryb25nU3dhbjEbMBkGA1UEAxMSc3Ryb25nU3dhbiBS
b290IENBMB4XDTA0MDkxMDExMDE0NVoXDTE0MDkwODExMDE0NVowRTELMAkGA1UE
BhMCQ0gxGTAXBgNVBAoTEExpbnV4IHN0cm9uZ1N3YW4xGzAZBgNVBAMTEnN0cm9u
Z1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MVhAI2+uA1ZqY9twpwryT6VZ3eK4DXF/COQntiBW5pLOpaqTOnKqiVmZFwfbo3u
cq8n5jkCgYEA5zgzRLifbM0q34c2HX8pTegh+BH7MGCxtcoU2uRPaXiGkqQObHI9
aItrgUQp+pAmKSBnEWJKgKsOh2Uf5ogjIeNuruGG/AXw/Pw2ORHNueenhDuhu69T
E2I4yxT3PPYbdzJ4ylBElfgm9WTrv7Wi7wSSfgQ6rEFdWukXa5vvsqMCgYEA1K+q
m1Jv9MGVIVc6MxhuOOj2Ym+qcWt/Pjvg78rR8SRsKwHlGTuv1rdWUSXYDr3f2Nf7
6DdbJtaSx5f8gY/UG34yGZx5FFbYV03vcCYBaLXsi/b6H7vb/VW74Y5g6bXqnprv
4mcdVU7xfyNFgdbLPAP9sYVLijPYDwm0Qq3cz/8CgYBKSJz4BBR8AQI4JBl3qoXb
mKtpJmW76iTN0amXlWgJ64XYkMptftpJvxj/w6V08WDBL77NL/XdlpcpWozAJJac
6ZOCrcQPLd15eZH2Dck5Y7pG2l2gjbgz7wdt/0NbG3pBdj6mSNlwEPR7PDwdMD6z
aZWi1LsA4lMaxO4YTVXZ3wKBgQCoFhTNH/+e/YawjNFQJFSn4WUnMn0Pmhc7xfLl
T/NPkqtx6dN3d7ZmCQrMow33yJOqOje5tFXzgc0KtNE4S8Uj3T4XA5SlQGVFyjAa
/85JRM2naA8RGVSpCCKuBeoNilnb8zL2SOvjyboN8oAyNuDzk2vh6ihjFsoASHkP
4XwLXQKBgQC0k6rzt/plIwEiP56XXOqwOxJj6kuE/hx1zGIiGT6lWiOsih20Ym2T
kYegVFvuDIWmSIAxGONWyee1lfnJbEuaHRixWQTnHUpqrU0FSnZTubnR3q/faZat
hrvLDdpa0ydAKoMEn3qUPSrh3CdBfi3KTQAQn2Mlk7bGHh9ICWi3vA==
-----END RSA PRIVATE KEY-----
+52
View File
@@ -0,0 +1,52 @@
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/strongswan/testing/hosts/winnetou/etc/conf.d/apache2,v 1.2 2006/01/06 12:21:21 as Exp $
# Config file for /etc/init.d/apache2
# An example from /etc/apache2/conf/modules.d/40_mod_ssl.conf:
#
# <IfDefine SSL>
# <IfModule !mod_ssl.c>
# LoadModule ssl_module extramodules/mod_ssl.so
# </IfModule>
# </IfDefine>
#
# This means that the mod_ssl.so DSO module is only loaded
# into the server when you pass "-D SSL" at startup. To
# enable WebDAV, add "-D DAV -D DAV_FS". If you installed
# mod_php then add "-D PHP4". For more options, please
# read the files in the /etc/apache2/conf/modules.d directory.
APACHE2_OPTS="-D SSL -D DEFAULT_VHOST"
# Extended options for advanced uses of Apache ONLY
# You don't need to edit these unless you are doing crazy Apache stuff
# As not having them set correctly, or feeding in an incorrect configuration
# via them will result in Apache failing to start
# YOU HAVE BEEN WARNED.
# ServerRoot setting
#SERVERROOT=/etc/apache2
# Configuration file location
# - If this does NOT start with a '/', then it is treated relative to
# $SERVERROOT by Apache
#CONFIGFILE=conf/apache2.conf
# Location to log startup errors to
# They are normally dumped to your terminal.
#STARTUPERRORLOG="/var/log/apache2/startuperror.log"
# PID file location
# Note that this MUST match the setting in your configuration file!
PIDFILE=/var/run/apache2.pid
# Restart style
# see http://httpd.apache.org/docs-2.0/stopping.html for more details
# the default is 'graceful', the other possible value is 'restart'
# If you use 'graceful', completion of the command does NOT imply that the system
# has finished restarting. Restart is finished only when all child processes
# have finished serving their current request sets. Read the URL for details.
#RESTARTSTYLE="restart"
RESTARTSTYLE="graceful"
@@ -0,0 +1 @@
HOSTNAME=winnetou
+10
View File
@@ -0,0 +1,10 @@
# /etc/conf.d/net:
# This is basically the ifconfig argument without the ifconfig $iface
#
iface_lo="127.0.0.1 netmask 255.0.0.0"
iface_eth0="PH_IP_WINNETOU broadcast 192.168.0.255 netmask 255.255.255.0"
# For setting the default gateway
#
gateway="eth0/192.168.0.254"
+8
View File
@@ -0,0 +1,8 @@
# conf.d file for the openldap-2.1 series
#
# To enable both the standard unciphered server and the ssl encrypted
# one uncomment this line or set any other server starting options
# you may desire.
#
# OPTS="-h 'ldaps:// ldap:// ldapi://%2fvar%2frun%2fopenldap%2fslapd.sock'"
OPTS="-4"
+1
View File
@@ -0,0 +1 @@
winnetou
+78
View File
@@ -0,0 +1,78 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
opts="${opts} reload"
[ "x${SERVERROOT}" != "x" ] && APACHE2_OPTS="${APACHE2_OPTS} -d ${SERVERROOT}"
[ "x${CONFIGFILE}" != "x" ] && APACHE2_OPTS="${APACHE2_OPTS} -f ${CONFIGFILE}"
[ "x${STARTUPERRORLOG}" != "x" ] && APACHE2_OPTS="${APACHE2_OPTS} -E ${STARTUPERRORLOG}"
# set a default for PIDFILE/RESTARTSTYLE for those that FAILED to follow
# instructiosn and update the conf.d/apache2 file.
# (bug #38787)
[ -z "${PIDFILE}" ] && PIDFILE=/var/run/apache2.pid
[ -z "${RESTARTSTYLE}" ] && RESTARTSTYLE="graceful"
checkconfig() {
local myconf="/etc/apache2/conf/apache2.conf"
if [ "x${CONFIGFILE}" != "x" ]; then
if [ ${CONFIGFILE:0:1} = "/" ]; then
myconf="${CONFIGFILE}"
else
myconf="${SERVERROOT:-/usr/lib/apache2}/${CONFIGFILE}"
fi
fi
if [ ! -r "${myconf}" ]; then
eerror "Unable to read configuration file: ${myconf}"
return 1
fi
if [ -z "${PIDFILE}" ]; then
eerror "\$PIDFILE is not set!"
eerror "Did you etc-update /etc/conf.d/apache2?"
return 1
fi
if [ -z "${RESTARTSTYLE}" ]; then
eerror "\$RESTARTSTYLE is not set!"
eerror "Did you etc-update /etc/conf.d/apache2?"
return 1
fi
/usr/sbin/apache2 -t ${APACHE2_OPTS} 1>/dev/null 2>&1
ret=$?
if [ $ret -ne 0 ]; then
eerror "Apache2 has detected a syntax error in your configuration files:"
/usr/sbin/apache2 -t ${APACHE2_OPTS}
fi
return $ret
}
depend() {
need net
use mysql dns logger netmount postgres
after sshd
}
start() {
checkconfig || return 1
ebegin "Starting apache2"
[ -f /var/log/apache2/ssl_scache ] && rm /var/log/apache2/ssl_scache
[ -f /usr/lib/apache2/build/envvars ] && . /usr/lib/apache2/build/envvars
env -i PATH=$PATH /sbin/start-stop-daemon --quiet \
--start --startas /usr/sbin/apache2 \
--pidfile ${PIDFILE} -- -k start ${APACHE2_OPTS}
eend $?
}
stop() {
ebegin "Stopping apache2"
/usr/sbin/apache2ctl stop >/dev/null
start-stop-daemon -o --quiet --stop --pidfile ${PIDFILE}
eend $?
}
reload() {
# restarting apache2 is much easier than apache1. The server handles most of the work for us.
# see http://httpd.apache.org/docs-2.0/stopping.html for more details
ebegin "Restarting apache2"
/usr/sbin/apache2 ${APACHE2_OPTS} -k ${RESTARTSTYLE}
eend $?
}
+314
View File
@@ -0,0 +1,314 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/net
if [[ -n $NET_DEBUG ]]; then
set -x
devnull=/dev/stderr
else
devnull=/dev/null
fi
# For pcmcia users. note that pcmcia must be added to the same
# runlevel as the net.* script that needs it.
depend() {
use hotplug pcmcia
}
checkconfig() {
if [[ -z "${ifconfig_IFACE}" ]]; then
eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"
eerror "(or \$iface_$IFACE for old-style configuration)"
return 1
fi
if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then
eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"
return 1
fi
}
# Fix bug 50039 (init.d/net.eth0 localization)
# Some other commands in this script might need to be wrapped, but
# we'll get them one-by-one. Note that LC_ALL trumps LC_anything_else
# according to locale(7)
ifconfig() {
LC_ALL=C /sbin/ifconfig "$@"
}
# setup_vars: setup variables based on $1 and content of /etc/conf.d/net
# The following variables are set, which should be declared local by
# the calling routine.
# status_IFACE (up or '')
# vlans_IFACE (space-separated list)
# ifconfig_IFACE (array of ifconfig lines, replaces iface_IFACE)
# dhcpcd_IFACE (command-line args for dhcpcd)
# routes_IFACE (array of route lines)
# inet6_IFACE (array of inet6 lines)
# ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
setup_vars() {
local i iface="${1//\./_}"
status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )
eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )
eval ifconfig_fallback_IFACE=( \"\$\{ifconfig_fallback_$iface\[@\]\}\" )
# BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array
# if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)
eval local iface_IFACE=\"\$\{iface_$iface\}\"
if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then
# Make sure these get evaluated as arrays
local -a aliases broadcasts netmasks
# Start with the primary interface
ifconfig_IFACE=( "${iface_IFACE}" )
# ..then add aliases
eval aliases=( \$\{alias_$iface\} )
eval broadcasts=( \$\{broadcast_$iface\} )
eval netmasks=( \$\{netmask_$iface\} )
for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do
ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
done
fi
# BACKWARD COMPATIBILITY: check for space-separated inet6 addresses
if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then
inet6_IFACE=( ${inet6_IFACE} )
fi
}
iface_start() {
local IFACE=${1} i x retval
checkconfig || return 1
if [[ ${ifconfig_IFACE} != dhcp ]]; then
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Bringing ${IFACE} up (${i})"
else
ebegin "Bringing ${IFACE} up"
fi
# ifconfig does not always return failure ..
ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
# Check that eth0 was not brought up by the kernel ...
if [[ ${status_IFACE} == up ]]; then
einfo "Keeping kernel configuration for ${IFACE}"
else
ebegin "Bringing ${IFACE} up via DHCP"
/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
retval=$?
eend $retval
if [[ $retval == 0 ]]; then
# DHCP succeeded, show address retrieved
i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' |
cut -d: -f2)
[[ -n ${i} ]] && einfo " ${IFACE} received address ${i}"
elif [[ -n "${ifconfig_fallback_IFACE}" ]]; then
# DHCP failed, try fallback.
# Show the address, but catch if this interface will be inet6 only
i=${ifconfig_fallback_IFACE%% *}
if [[ ${i} == *.*.*.* ]]; then
ebegin "Using fallback configuration (${i}) for ${IFACE}"
else
ebegin "Using fallback configuration for ${IFACE}"
fi
ifconfig ${IFACE} ${ifconfig_fallback_IFACE} >${devnull} && \
ifconfig ${IFACE} up &>${devnull}
eend $? || return $?
else
return $retval
fi
fi
fi
if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then
einfo " Adding aliases"
for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"
ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}
eend $?
done
fi
if [[ -n ${inet6_IFACE} ]]; then
einfo " Adding inet6 addresses"
for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do
ebegin " ${IFACE} inet6 add ${inet6_IFACE[i]}"
ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}
eend $?
done
fi
# Set static routes
if [[ -n ${routes_IFACE} ]]; then
einfo " Adding routes"
for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do
ebegin " ${routes_IFACE[i]}"
/sbin/route add ${routes_IFACE[i]}
eend $?
done
fi
# Set default route if applicable to this interface
if [[ ${gateway} == ${IFACE}/* ]]; then
local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')
local gw=${gateway#*/}
if [[ ${ogw} != ${gw} ]]; then
ebegin " Setting default gateway ($gw)"
# First delete any existing route if it was setup by kernel...
/sbin/route del default dev ${IFACE} &>${devnull}
# Second delete old gateway if it was set...
/sbin/route del default gw ${ogw} &>${devnull}
# Third add our new default gateway
/sbin/route add default gw ${gw} >${devnull}
eend $? || {
true # need to have some command in here
# Note: This originally called stop, which is obviously
# wrong since it's calling with a local version of IFACE.
# The below code works correctly to abort configuration of
# the interface, but is commented because we're assuming
# that default route failure should not cause the interface
# to be unconfigured.
#local error=$?
#ewarn "Aborting configuration of ${IFACE}"
#iface_stop ${IFACE}
#return ${error}
}
fi
fi
# Enabling rp_filter causes wacky packets to be auto-dropped by
# the kernel. Note that we only do this if it is not set via
# /etc/sysctl.conf ...
if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \
-z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then
echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
fi
}
# iface_stop: bring down an interface. Don't trust information in
# /etc/conf.d/net since the configuration might have changed since
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
local IFACE=${1} i x aliases inet6 count
# Try to do a simple down (no aliases, no inet6, no dhcp)
aliases="$(ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"
inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"
if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then
ebegin "Bringing ${IFACE} down"
ifconfig ${IFACE} down &>/dev/null
eend 0
return 0
fi
einfo "Bringing ${IFACE} down"
# Stop aliases before primary interface.
# Note this must be done in reverse order, since ifconfig eth0:1
# will remove eth0:2, etc. It might be sufficient to simply remove
# the base interface but we're being safe here.
for i in ${aliases} ${IFACE}; do
# Delete all the inet6 addresses for this interface
inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"
if [[ -n ${inet6} ]]; then
einfo " Removing inet6 addresses"
for x in ${inet6}; do
ebegin " ${IFACE} inet6 del ${x}"
ifconfig ${i} inet6 del ${x}
eend $?
done
fi
# Stop DHCP (should be N/A for aliases)
# Don't trust current configuration... investigate ourselves
if /sbin/dhcpcd -z ${i} &>${devnull}; then
ebegin " Releasing DHCP lease for ${IFACE}"
for ((count = 0; count < 9; count = count + 1)); do
/sbin/dhcpcd -z ${i} &>${devnull} || break
sleep 1
done
[[ ${count} -lt 9 ]]
eend $? "Timed out"
fi
ebegin " Stopping ${i}"
ifconfig ${i} down &>${devnull}
eend 0
done
return 0
}
start() {
# These variables are set by setup_vars
local status_IFACE vlans_IFACE dhcpcd_IFACE
local -a ifconfig_IFACE routes_IFACE inet6_IFACE
# Call user-defined preup function if it exists
if [[ $(type -t preup) == function ]]; then
einfo "Running preup function"
preup ${IFACE} || {
eerror "preup ${IFACE} failed"
return 1
}
fi
# Start the primary interface and aliases
setup_vars ${IFACE}
iface_start ${IFACE} || return 1
# Start vlans
local vlan
for vlan in ${vlans_IFACE}; do
/sbin/vconfig add ${IFACE} ${vlan} >${devnull}
setup_vars ${IFACE}.${vlan}
iface_start ${IFACE}.${vlan}
done
# Call user-defined postup function if it exists
if [[ $(type -t postup) == function ]]; then
einfo "Running postup function"
postup ${IFACE}
fi
}
stop() {
# Call user-defined predown function if it exists
if [[ $(type -t predown) == function ]]; then
einfo "Running predown function"
predown ${IFACE}
fi
# Don't depend on setup_vars since configuration might have changed.
# Investigate current configuration instead.
local vlan
for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do
iface_stop ${vlan}
/sbin/vconfig rem ${vlan} >${devnull}
done
iface_stop ${IFACE} || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
if [[ $(type -t postdown) == function ]]; then
einfo "Running postdown function"
postdown ${IFACE}
fi
}
# vim:ts=4
+25
View File
@@ -0,0 +1,25 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/strongswan/testing/hosts/winnetou/etc/init.d/slapd,v 1.2 2005/05/31 14:04:43 as Exp $
depend() {
need net
}
start() {
ebegin "Starting ldap-server"
eval start-stop-daemon --start --quiet --pidfile /var/run/openldap/slapd.pid --exec /usr/lib/openldap/slapd -- -u ldap -g ldap "${OPTS}"
eend $?
if [ ! -e /var/lib/openldap-data/objectClass.bdb ]
then
sleep 5
ldapadd -x -D "cn=Manager, o=Linux strongSwan, c=CH" -w tuxmux -f /etc/openldap/ldif.txt
fi
}
stop() {
ebegin "Stopping ldap-server"
start-stop-daemon --stop --signal 2 --quiet --pidfile /var/run/openldap/slapd.pid
eend $?
}
@@ -0,0 +1,40 @@
dn: o=Linux strongSwan, c=CH
objectclass: organization
o: Linux strongSwan
dn: cn=Manager,o=Linux strongSwan, c=CH
objectclass: organizationalRole
cn: Manager
dn: cn=strongSwan Root CA, o=Linux strongSwan, c=CH
objectClass: organizationalRole
cn: strongSwan Root CA
objectClass: certificationAuthority
authorityRevocationList;binary:< file:///etc/openssl/strongswan.crl
certificateRevocationList;binary:< file:///etc/openssl/strongswan.crl
cACertificate;binary:< file:///etc/openssl/strongswanCert.der
dn: ou=Research, o=Linux strongSwan, c=CH
objectclass: organizationalUnit
ou: Research
dn: cn=Research CA, ou=Research, o=Linux strongSwan, c=CH
objectClass: organizationalRole
cn: Research CA
objectClass: certificationAuthority
authorityRevocationList;binary:< file:///etc/openssl/research/research.crl
certificateRevocationList;binary:< file:///etc/openssl/research/research.crl
cACertificate;binary:< file:///etc/openssl/research/researchCert.der
dn: ou=Sales, o=Linux strongSwan, c=CH
objectclass: organizationalUnit
ou: Sales
dn: cn=Sales CA, ou=Sales, o=Linux strongSwan, c=CH
objectClass: organizationalRole
cn: Sales CA
objectClass: certificationAuthority
authorityRevocationList;binary:< file:///etc/openssl/sales/sales.crl
certificateRevocationList;binary:< file:///etc/openssl/sales/sales.crl
cACertificate;binary:< file:///etc/openssl/sales/salesCert.der
@@ -0,0 +1,68 @@
#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
include /etc/openldap/schema/core.schema
# Define global ACLs to disable default read access.
# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral ldap://root.openldap.org
pidfile /var/run/openldap/slapd.pid
argsfile /var/run/openldap/slapd.args
# Load dynamic backend modules:
# modulepath /usr/lib/openldap/openldap
# moduleload back_bdb.la
# moduleload back_ldap.la
# moduleload back_ldbm.la
# moduleload back_passwd.la
# moduleload back_shell.la
# Sample security restrictions
# Require integrity protection (prevent hijacking)
# Require 112-bit (3DES or better) encryption for updates
# Require 63-bit encryption for simple bind
# security ssf=1 update_ssf=112 simple_bind=64
# Sample access control policy:
# Root DSE: allow anyone to read it
# Subschema (sub)entry DSE: allow anyone to read it
# Other DSEs:
# Allow self write access
# Allow authenticated users read access
# Allow anonymous users to authenticate
# Directives needed to implement policy:
# access to dn.base="" by * read
# access to dn.base="cn=Subschema" by * read
# access to *
# by self write
# by users read
# by anonymous auth
#
# if no access controls are present, the default policy
# allows anyone and everyone to read anything but restricts
# updates to rootdn. (e.g., "access to * by * read")
#
# rootdn can always read and write EVERYTHING!
#######################################################################
# BDB database definitions
#######################################################################
database bdb
checkpoint 32 30 # <kbyte> <min>
suffix "o=Linux strongSwan,c=CH"
rootdn "cn=Manager,o=Linux strongSwan,c=CH"
# Cleartext passwords, especially for the rootdn, should
# be avoid. See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
rootpw tuxmux
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
directory /var/lib/openldap-data
# Indices to maintain
index objectClass eq
+35
View File
@@ -0,0 +1,35 @@
#! /bin/sh
# generate a certificate revocation list (CRL) for the strongswan CA.
#
# Copyright (C) 2004 Andreas Steffen
# Zuercher Hochschule Winterthur
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# RCSID $Id: generate-crl,v 1.2 2005/03/24 11:19:38 as Exp $
export COMMON_NAME=strongSwan
cd /etc/openssl
openssl ca -config /etc/openssl/openssl.cnf -gencrl -out crl.pem
openssl crl -in crl.pem -outform der -out strongswan.crl
cp strongswan.crl /var/www/localhost/htdocs/
cp strongswanCert.pem /var/www/localhost/htdocs/
cp index.html /var/www/localhost/htdocs/
cd /etc/openssl/research
openssl ca -config /etc/openssl/research/openssl.cnf -gencrl -out crl.pem
openssl crl -in crl.pem -outform der -out research.crl
cp research.crl /var/www/localhost/htdocs/
cd /etc/openssl/sales
openssl ca -config /etc/openssl/sales/openssl.cnf -gencrl -out crl.pem
openssl crl -in crl.pem -outform der -out sales.crl
cp sales.crl /var/www/localhost/htdocs/
@@ -0,0 +1,36 @@
<html>
<head>
<title>strongSwan Web Services</title>
<base target="_self">
</head>
<body bgcolor="#FFFFFF">
<table border=0 cellpadding=0 cellspacing=0 width=600>
<tr><td>
<h2>strongSwan Certification Authority</h2>
<ul>
<li>
<a href="strongswanCert.pem">Root CA Certificate</a>
</li>
</ul>
<ul>
<li>
<a href="strongswan.crl">Certificate Revocation List (CRL)</a>
</li>
</ul>
<h2>strongSwan UML Testing Environment</h2>
<ul>
<li>
<a href="testresults/">UML Test Results</a>
</li>
</ul>
<a href="images/umlArchitecture_large.png" target="_blank">
<img src="images/umlArchitecture_small.png" border="0">
</a>
<hr>
<address>Linux strongSwan (<a href="http://www.strongswan.org">www.strongswan.org</a>)</address>
</td></tr>
</table>
</body>
@@ -0,0 +1,15 @@
V 090909111334Z 01 unknown /C=CH/O=Linux strongSwan/CN=mars.strongswan.org
V 090909111553Z 02 unknown /C=CH/O=Linux strongSwan/CN=sun.strongswan.org
V 090909111725Z 03 unknown /C=CH/O=Linux strongSwan/CN=moon.strongswan.org
V 090909111826Z 04 unknown /C=CH/O=Linux strongSwan/CN=venus.strongswan.org
V 090909112439Z 05 unknown /C=CH/O=Linux strongSwan/OU=Sales/[email protected]
V 090909112534Z 06 unknown /C=CH/O=Linux strongSwan/OU=Research/[email protected]
R 090909112548Z 041226135423Z 07 unknown /C=CH/O=Linux strongSwan/OU=Research/[email protected]
V 090909112651Z 08 unknown /C=CH/O=Linux strongSwan/OU=Accounting/[email protected]
V 091118162928Z 09 unknown /C=CH/O=Linux strongSwan/OU=OCSP Signing Authority/CN=ocsp.strongswan.org
V 091231214318Z 0A unknown /C=CH/O=Linux strongSwan/OU=Research/[email protected]
V 100216084430Z 0B unknown /C=CH/O=Linux strongSwan/OU=Authorization Authority/[email protected]
R 140321062536Z 050621195214Z 0C unknown /C=CH/O=Linux strongSwan/OU=Research/CN=Research CA
V 140321062916Z 0D unknown /C=CH/O=Linux strongSwan/OU=Sales/CN=Sales CA
V 100607191714Z 0E unknown /C=CH/O=Linux strongSwan/CN=winnetou.strongswan.org
V 100620195806Z 0F unknown /C=CH/O=Linux strongSwan/OU=Research/CN=Research CA
@@ -0,0 +1 @@
unique_subject = yes
@@ -0,0 +1 @@
unique_subject = yes
@@ -0,0 +1,14 @@
V 090909111334Z 01 unknown /C=CH/O=Linux strongSwan/CN=mars.strongswan.org
V 090909111553Z 02 unknown /C=CH/O=Linux strongSwan/CN=sun.strongswan.org
V 090909111725Z 03 unknown /C=CH/O=Linux strongSwan/CN=moon.strongswan.org
V 090909111826Z 04 unknown /C=CH/O=Linux strongSwan/CN=venus.strongswan.org
V 090909112439Z 05 unknown /C=CH/O=Linux strongSwan/OU=Sales/[email protected]
V 090909112534Z 06 unknown /C=CH/O=Linux strongSwan/OU=Research/[email protected]
R 090909112548Z 041226135423Z 07 unknown /C=CH/O=Linux strongSwan/OU=Research/[email protected]
V 090909112651Z 08 unknown /C=CH/O=Linux strongSwan/OU=Accounting/[email protected]
V 091118162928Z 09 unknown /C=CH/O=Linux strongSwan/OU=OCSP Signing Authority/CN=ocsp.strongswan.org
V 091231214318Z 0A unknown /C=CH/O=Linux strongSwan/OU=Research/[email protected]
V 100216084430Z 0B unknown /C=CH/O=Linux strongSwan/OU=Authorization Authority/[email protected]
R 140321062536Z 050621195214Z 0C unknown /C=CH/O=Linux strongSwan/OU=Research/CN=Research CA
V 140321062916Z 0D unknown /C=CH/O=Linux strongSwan/OU=Sales/CN=Sales CA
V 100607191714Z 0E unknown /C=CH/O=Linux strongSwan/CN=winnetou.strongswan.org
@@ -0,0 +1,24 @@
-----BEGIN CERTIFICATE-----
MIIEDTCCAvWgAwIBAgIBATANBgkqhkiG9w0BAQQFADBFMQswCQYDVQQGEwJDSDEZ
MBcGA1UEChMQTGludXggc3Ryb25nU3dhbjEbMBkGA1UEAxMSc3Ryb25nU3dhbiBS
b290IENBMB4XDTA0MDkxMDExMTMzNFoXDTA5MDkwOTExMTMzNFowRjELMAkGA1UE
BhMCQ0gxGTAXBgNVBAoTEExpbnV4IHN0cm9uZ1N3YW4xHDAaBgNVBAMTE21hcnMu
c3Ryb25nc3dhbi5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA
zRlshdPlLggS7bpAlovamLpk9pxYUv3c8J4W0kV4knMPbSJywfctpce95iPZfU6V
ICV0fVOn/0utJG+0lMTYwcf5zvyIDPDccfsTT3WI+/PcaUpU6E5aaPAZxDG4na6w
UVUKiRcOyiuyXanulnu+b48nM7MgoMVZNDWY5q15enEZh1oO2Fy0DlKwweDKEuAi
8xSnu2RcZBFSZMDBCRCt3QgHGZygrzjP3vN6IgbvHL+YWIycMi5yiJR5EoCE6D17
AT1dh0C8R9m1a0LU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7yfoSLFzy0/cLFPdQvE
JA7w8crODCZpDgEKVHVyUWuyt1O46N3ydUfDcnKJoQ9HWHm3xCbDex5MHTnvm1lk
Stx71CGM7TE6VPy028UlrSw0JqEwCVwstei2cMzwgA==
-----END CERTIFICATE-----

Some files were not shown because too many files have changed in this diff Show More