From fddf22dbf4e3c1082eb6e6465e7905296fcc5232 Mon Sep 17 00:00:00 2001 From: hubertf Date: Sun, 11 Feb 2001 05:24:29 +0000 Subject: Add 6to4-1.0, a script to setup automatic 6to4 IPv6 tunneling. For easy IPv6 connectivity, do: * make install * cd /usr/pkg/etc * cp 6to4.conf-example 6to4.conf * in 6to4.conf, change "out_if" to match your outgoing interface: ppp0 if you're on a modem, else your ethernet card's interface. * 6to4 -v start * ping6 www.kame.net --- net/6to4/Makefile | 38 +++++++++ net/6to4/files/6to4 | 148 +++++++++++++++++++++++++++++++++ net/6to4/files/6to4.8 | 166 +++++++++++++++++++++++++++++++++++++ net/6to4/files/6to4.conf | 17 ++++ net/6to4/files/6to4.html | 210 +++++++++++++++++++++++++++++++++++++++++++++++ net/6to4/pkg/COMMENT | 1 + net/6to4/pkg/DEINSTALL | 20 +++++ net/6to4/pkg/DESCR | 8 ++ net/6to4/pkg/MESSAGE | 3 + net/6to4/pkg/PLIST | 5 ++ 10 files changed, 616 insertions(+) create mode 100644 net/6to4/Makefile create mode 100755 net/6to4/files/6to4 create mode 100644 net/6to4/files/6to4.8 create mode 100644 net/6to4/files/6to4.conf create mode 100644 net/6to4/files/6to4.html create mode 100644 net/6to4/pkg/COMMENT create mode 100644 net/6to4/pkg/DEINSTALL create mode 100644 net/6to4/pkg/DESCR create mode 100644 net/6to4/pkg/MESSAGE create mode 100644 net/6to4/pkg/PLIST (limited to 'net/6to4') diff --git a/net/6to4/Makefile b/net/6to4/Makefile new file mode 100644 index 00000000000..cab91db14ce --- /dev/null +++ b/net/6to4/Makefile @@ -0,0 +1,38 @@ +# $NetBSD: Makefile,v 1.1.1.1 2001/02/11 05:24:29 hubertf Exp $ +# + +DISTNAME= 6to4-1.0 +CATEGORIES= net +MASTER_SITES= # empty +DISTFILES= # empty + +MAINTAINER= hubertf@netbsd.org +HOMEPAGE= http://www.netbsd.org/packages/net/6to4/files/6to4.html + +USE_PERL5= YES +DEINSTALL_FILE= ${WRKDIR}/DEINSTALL + +EXTRACT_ONLY= # empty +NO_WRKSUBDIR= yes +NO_CHECKSUM= yes +NO_PATCH= yes +NO_CONFIGURE= yes + +do-build: +.for FILE in 6to4 + ${SED} -e 's|@PREFIX@|${PREFIX}|g' \ + -e 's|@LOCALBASE@|${LOCALBASE}|g' \ + < ${FILESDIR}/${FILE} \ + > ${WRKSRC}/${FILE} +.endfor + ${SED} \ + -e 's,@PREFIX@,${PREFIX},' \ + <${PKGDIR}/DEINSTALL >${DEINSTALL_FILE} + +do-install: + ${INSTALL_SCRIPT} ${WRKSRC}/6to4 ${PREFIX}/sbin/6to4 + ${INSTALL_MAN} ${FILESDIR}/6to4.8 ${PREFIX}/man/man8 + ${INSTALL_DATA} ${FILESDIR}/6to4.conf ${PREFIX}/etc/6to4.conf-example + ${INSTALL_DATA} ${FILESDIR}/6to4.html ${PREFIX}/share/doc/6to4.html + +.include "../../mk/bsd.pkg.mk" diff --git a/net/6to4/files/6to4 b/net/6to4/files/6to4 new file mode 100755 index 00000000000..4c4e5157777 --- /dev/null +++ b/net/6to4/files/6to4 @@ -0,0 +1,148 @@ +#!@LOCALBASE@/bin/perl +# +# Setup 6to4 IPv6, for NetBSD (and maybe others) +# +# (c) Copyright 2000 Hubert Feyrer +# + +#$etcdir="@PREFIX@/etc"; +$etcdir="/usr/pkg/etc"; + +require "$etcdir/6to4.conf"; + +use Getopt::Std; + +########################################################################### +sub run +{ + local($str) = @_; + + if ($not) { + print "$str\n"; + } else { + if ($verbose) { + print "$str\n"; + } + system($str); + } +} + +########################################################################### + +# +# Process options +# +getopts('nvh'); + +$not = 1 if $opt_n; +$verbose = 1 if $opt_v; + +if ($opt_h) { + print "Usage: $0 [-n] [-v] {start | stop | rtadvd-start | rtadvd-stop}\n"; + exit 0; +} + +# +# Some sanity checks +# +if (`ifconfig -a | grep fe80: | wc -l` <= 0 or + `ifconfig -a | grep stf | wc -l` <= 0) { + die "$0: It seems your kernel does not support IPv6 or 6to4 (stf).\n". + "Add 'options INET6' and 'pseudo-device stf 1' to your kernel and retry!\n"; +} + +# +# Figure out IP#s etc. +# +$localadr4 = `ifconfig $out_if inet | grep inet`; +$localadr4 =~ s/^.*inet\s*//; +$localadr4 =~ s/\s.*$//; +chomp($localadr4); + +@l4c = split('\.', $localadr4); +$prefix = sprintf("2002:%02x%02x:%02x%02x", @l4c[0..3]); + +$localadr6 = sprintf("$prefix:%04x", $v6_net); + +chomp($remoteadr4 = `host $peer`); +$remoteadr4 =~ s/^.*address //; + +chomp($remoteadr6 = `host -t AAAA $peer`); +$remoteadr6 =~ s/^.*address //; + + +if ($verbose) { + print "remote v4 address: $remoteadr4\n"; + print "local v4 address: $localadr4\n"; + print "remote v6 address: $remoteadr6\n"; + print "local v6 address: $localadr6:$hostbits6\n"; + print "\n"; +} + + +# +# Handle commands +# + +# stop: +if ( $ARGV[0] eq "stop" ) { + run("ifconfig stf0 down"); + $cmd="ifconfig stf0 inet6 " . + "| grep inet6 " . + "| sed -e 's/inet6//' " . + "-e 's/prefix.*//g' " . + "-e 's/^[ ]*//' " . + "-e 's/[ ]*\$//'"; + foreach $ip ( split('\s+', `$cmd`)) { + run("ifconfig stf0 inet6 -alias $ip"); + } + run("route delete -inet6 default"); +} + +# start: +if ( $ARGV[0] eq "start" ) { + run("ifconfig stf0 inet6 $localadr6:$hostbits6 prefixlen $v6_prefixlen alias"); + run("route add -inet6 default $remoteadr6"); + if ($in_if ne "") { + run("ifconfig $in_if inet6 $prefix:$v6_innernet:$hostbits6"); + } +} + +# rtadvd-stop: +if ($ARGV[0] eq "rtadvd-stop" or $ARGV[0] eq "stop-rtadvd") { + if ( -f "/var/run/rtadvd.pid" ) { + $pid = `cat /var/run/rtadvd.pid`; + run ("kill -TERM $pid"); + run ("rm -f /var/run/rtadvd.pid"); + run ("rm -f /var/run/6to4-rtadvd.conf.$pid"); + } else { + print "no rtadvd running!\n"; + } +} + +# rtadvd-start: +# Write config file for rtadvd to /tmp and start rtadvd: +if ($ARGV[0] eq "rtadvd-start" or $ARGV[0] eq "start-rtadvd" ) { + if ( -f "/var/run/rtadvd.pid" ) { + print "rtadvd already running!\n"; + } else { + $tmpname="/var/run/rtadvd.conf-6to4.$$"; + + print "cat >$tmpname <$tmpname") || die "Can't write to "; + print RC "$in_if\\\n"; + print RC "\t:addrs#1:addr=\"${prefix}:${v6_innernet}::\":prefixlen#64:tc=ether:\n"; + close(RC); + + run("rtadvd -c $tmpname $in_if"); + run("sysctl -w net.inet6.ip6.forwarding=1"); + + print "\n"; + print "XXX on your Clients, run:\n"; + print "XXX route add -inet6 default $prefix:$v6_innernet:$hostbits6\n"; + } +} diff --git a/net/6to4/files/6to4.8 b/net/6to4/files/6to4.8 new file mode 100644 index 00000000000..d58794ab16a --- /dev/null +++ b/net/6to4/files/6to4.8 @@ -0,0 +1,166 @@ +.\" $NetBSD: 6to4.8,v 1.1.1.1 2001/02/11 05:24:29 hubertf Exp $ +.Dd February 11, 2001 +.Dt 6to4 8 +.Os +.Sh NAME +.Nm 6to4 +.Nd setup automatic 6to4 IPv6 tunnelling +.Sh SYNOPSIS +.Nm +.Op Fl vn +.Ar command +.Sh DESCRIPTION +The +.Nm +script can be used to setup IPv6 on your home machine and +network for exploring IPv6 without any registrations. 6to4 is a +mechanism by which your IPv6 address(es) are derived from an assigned +IPv4 address, and which involves automatic tunnelling to one or more +remove 6to4 hubs, which will then forward your v6 packets on the 6bone +etc. Replies are routed back to you over IPv4 via (possibly) other +6to4 capable remote gateways. As such, IPv6-in-IPv4-encapsulated +packets are accepted from all v4-hosts. +.Pp +From your (single) IPv4 address, you get a whole IPv6 /48 network, +which allows you to split your network in 2^16 subnets, with 2^64 +hosts each. You need to setup routing for your internal network +properly, help is provided for setting up the border router here. +.Pp +This script takes the burden to calculate your IPv6 address from +existing IPv4 address and runs the commands to setup (and tear down) +automatic 6to4 IPv6 tunnelling. In a seperate step, router +advertisement for the inside network can be started and stopped. +.Pp +Possible options are: +.Bl -tag -width xxx +.It Fl n +Do not. Only print the commands that would be run, but do not execute +them. +.It Fl v +Verbose operation. Print the commands that are about to be run, before +running them. Displays some additional information. +.It Fl h +Show usage. +.El +.Pp +Possible commands are: +.Bl -tag -width rtadvd-start +.It Sy start +Configure 6to4 IPv6. The +.Xr stf 4 +interface is configured, and a default route to a remote 6to4 +gateway is established. In addition, the internal +network interface is assigned an address. +.It Sy stop +Stops 6to4 IPv6. All addresses are removed from the +.Xr stf 4 +device, and the default route is removed. +.It Sy rtadvd-start +Starts router advertizement and IPv6 packet forwarding, +turning the machine into a IPv6 router. +.Xr rtadvd 8 +is invoked with a custom config file created under +.Pa /var/run . +Clients need to be told to use the router as +default (IPv6) router, e.g. by adding a static route. +Follow the on-screen instructions to do so. +.It Sy rtadvd-stop +Stops router advertizement and IPv6 packet forwarding. +.Xr rtadvd 8 +is stopped, and the +.Xr rtadvd.conf 5 +config file is removed from +.Pa /var/run . +.El +.Sh REQUIREMENTS +Besides IPv4 connectivity, you need support for IPv6 and the +.Xr stf 4 +device in your kernel. While the GENERIC NetBSD 1.5 kernel does +support IPv6, it does not contain support for the +.Xr stf 4 +device. +.Pp +Make sure you have the following options in your kernel config file: +.Bd -literal -offset +options INET # IP + ICMP + TCP + UDP +options INET6 # IPV6 +pseudo-device stf 1 # 6to4 IPv6 over IPv4 encapsulation +.Ed +.Pp +No special values are needed in +.Pa /etc/rc.conf . +.Sh CONFIGURATION +The +.Nm +script reads it's configuration from a config file named +.Pa 6to4.conf. +The +.Pa 6to4.conf +file is in +.Xr perl 1 +syntax, and contains several +variables that can be tuned to adjust your setup. Default values +should work for use on a modem dialup. +.Bl -tag -width rtadvd-stop +.It Sy out_if +The outbound interface that has a valid IPv4 address +assigned, that can be used to derive the IPv6 +addresses from. Usually +.Dq ppp0 +for a modem setup, or your ethernet interface if you have +IPv4 connectivity via LAN. This +can't be empty, and is assigned the IPv6 address +2002:x:x:v6_net:hostbits6, see below. +.It Sy in_if +The inside interface. If non-empty, this interface is +assigned the IPv6 address +2002:x:x:v6_innernet:hostbits6, see below. +This is only useful on machines that +have more than one network interfaces, e.g. with a modem and a +local ethernet. +.It Sy v6_net +The subnet address you want to use on the address of +your outbound interface. Defaults to +.Dq 1 . +.It Sy v6_innernet +The subnet address you want to use on the address of +your inbound interface. Defaults to +.Dq 2 . +.It Sy hostbits6 +The lower 64 bits of both the inbound and outbound interface's +addresses. +.It Sy peer +Name of the remote 6to4 server that'll take our +IPv6-in-IPv4 encapsulated packets and route them on +via IPv6. Several possible values are given in the +example config file. +.El +.Sh EXAMPLE USAGE +The +.Nm +script can be run automatically by +.Xr pppd 8 +when a connection is made. For this, put the following into +.Pa /etc/ppp/ip-up : +.Bd -literal -offset +( /usr/pkg/sbin/6to4 stop + /usr/pkg/sbin/6to4 start ) & +.Ed +.Pp +To shut down properly, put this into +.Pa /etc/ppp/ip-down : +.Bd -literal -offset +/usr/pkg/sbin/6to4 stop +.Ed +.Sh SEE ALSO +.Xr stf 4 , +.Dq 6to4 IPv6 Explained +at +.Pa http://www.feyrer.de/NetBSD/6to4.html , +NetBSD IPv6 Documentation at +.Pa http://www.netbsd.org/Documentation/network/ipv6/ . +.Sh HISTORY +The +.Nm +utility and manpage were writte by +Hubert Feyrer . diff --git a/net/6to4/files/6to4.conf b/net/6to4/files/6to4.conf new file mode 100644 index 00000000000..9d527752d15 --- /dev/null +++ b/net/6to4/files/6to4.conf @@ -0,0 +1,17 @@ +# 6to4.conf +# + +$out_if="ppp0"; # Our outgoing (uplink) interface +$in_if=""; # Inside (ethernet) interface + +$v6_net="1"; # 2002:x:x:v6_net:: +$v6_innernet="2"; # 2002:x:x:v6_innernet:: +$v6_prefixlen=16; # Change for more +$hostbits6=":1"; # should be determined via MAC of $in_if + +# Possible remote 6to4 routers: +$peer="6to4.ipv6.fh-regensburg.de"; # Germany, Europe +#$peer="asterix.ipv6.bt.com"; # Great Britain, Europe +#$peer="6to4.kfu.com"; # USA, West coast +#$peer="6to4.ipv6.microsoft.com"; # USA, West coast +#$peer="ipv6-router.cisco.com"; # USA, West coast; register at http://www.cisco.com/ipv6/ diff --git a/net/6to4/files/6to4.html b/net/6to4/files/6to4.html new file mode 100644 index 00000000000..16654733ba0 --- /dev/null +++ b/net/6to4/files/6to4.html @@ -0,0 +1,210 @@ + + + + February 11, 2001 6to4 8 + + + + + +

+ NAME +

+6to4 +- setup automatic 6to4 IPv6 tunnelling +

+ SYNOPSIS +

+6to4 +[-vn] +command +

+ DESCRIPTION +

+The +6to4 +script can be used to setup IPv6 on your home machine and +network for exploring IPv6 without any registrations. 6to4 is a +mechanism by which your IPv6 address(es) are derived from an assigned +IPv4 address, and which involves automatic tunnelling to one or more +remove 6to4 hubs, which will then forward your v6 packets on the 6bone +etc. Replies are routed back to you over IPv4 via (possibly) other +6to4 capable remote gateways. As such, IPv6-in-IPv4-encapsulated +packets are accepted from all v4-hosts. +

+From your (single) IPv4 address, you get a whole IPv6 /48 network, +which allows you to split your network in 2^16 subnets, with 2^64 +hosts each. You need to setup routing for your internal network +properly, help is provided for setting up the border router here. +

+This script takes the burden to calculate your IPv6 address from +existing IPv4 address and runs the commands to setup (and tear down) +automatic 6to4 IPv6 tunnelling. In a seperate step, router +advertisement for the inside network can be started and stopped. +

+Possible options are: +

+

-n
+Do not. Only print the commands that would be run, but do not execute +them. +

-v
+Verbose operation. Print the commands that are about to be run, before +running them. Displays some additional information. +

-h
+Show usage. +
+

+Possible commands are: +

+

start
+Configure 6to4 IPv6. The +stf(4) +interface is configured, and a default route to a remote 6to4 +gateway is established. In addition, the internal +network interface is assigned an address. +

stop
+Stops 6to4 IPv6. All addresses are removed from the +stf(4) +device, and the default route is removed. +

rtadvd-start
+Starts router advertizement and IPv6 packet forwarding, +turning the machine into a IPv6 router. +rtadvd(8) +is invoked with a custom config file created under +/var/run. +Clients need to be told to use the router as +default (IPv6) router, e.g. by adding a static route. +Follow the on-screen instructions to do so. +

rtadvd-stop
+Stops router advertizement and IPv6 packet forwarding. +rtadvd(8) +is stopped, and the +rtadvd.conf(5) +config file is removed from +/var/run. +
+

+ REQUIREMENTS +

+Besides IPv4 connectivity, you need support for IPv6 and the +stf(4) +device in your kernel. While the GENERIC NetBSD 1.5 kernel does +support IPv6, it does not contain support for the +stf(4) +device. +

+Make sure you have the following options in your kernel config file: +

+ +
+options         INET          # IP + ICMP + TCP + UDP
+options         INET6           # IPV6
+pseudo-device  stf  1    # 6to4 IPv6 over IPv4 encapsulation
+
+
+
+

+No special values are needed in +/etc/rc.conf. +

+ CONFIGURATION +

+The +6to4 +script reads it's configuration from a config file named +6to4.conf. +The +6to4.conf +file is in +perl(1) +syntax, and contains several +variables that can be tuned to adjust your setup. Default values +should work for use on a modem dialup. +
+

out_if
+The outbound interface that has a valid IPv4 address +assigned, that can be used to derive the IPv6 +addresses from. Usually +``ppp0'' +for a modem setup, or your ethernet interface if you have +IPv4 connectivity via LAN. This +can't be empty, and is assigned the IPv6 address +2002:x:x:v6_net:hostbits6, see below. +

in_if
+The inside interface. If non-empty, this interface is +assigned the IPv6 address +2002:x:x:v6_innernet:hostbits6, see below. +This is only useful on machines that +have more than one network interfaces, e.g. with a modem and a +local ethernet. +

v6_net
+The subnet address you want to use on the address of +your outbound interface. Defaults to +``1''. +

v6_innernet
+The subnet address you want to use on the address of +your inbound interface. Defaults to +``2''. +

hostbits6
+The lower 64 bits of both the inbound and outbound interface's +addresses. +

peer
+Name of the remote 6to4 server that'll take our +IPv6-in-IPv4 encapsulated packets and route them on +via IPv6. Several possible values are given in the +example config file. +
+

+ EXAMPLE USAGE +

+The +6to4 +script can be run automatically by +pppd(8) +when a connection is made. For this, put the following into +/etc/ppp/ip-up: +
+ +
+( /usr/pkg/sbin/6to4 stop
+  /usr/pkg/sbin/6to4 start ) &
+
+
+
+

+To shut down properly, put this into +/etc/ppp/ip-down: +

+ +
+/usr/pkg/sbin/6to4 stop
+
+
+
+

+ SEE ALSO +

+stf(4), +``6to4 IPv6 Explained'' +at +http://www.feyrer.de/NetBSD/6to4.html, +NetBSD IPv6 Documentation at +http://www.netbsd.org/Documentation/network/ipv6/. +

+ HISTORY +

+The +6to4 +utility and manpage were writte by +Hubert Feyrer . + + diff --git a/net/6to4/pkg/COMMENT b/net/6to4/pkg/COMMENT new file mode 100644 index 00000000000..a2c05c0d515 --- /dev/null +++ b/net/6to4/pkg/COMMENT @@ -0,0 +1 @@ +Enables 6to4 IPv6 automatic tunnels diff --git a/net/6to4/pkg/DEINSTALL b/net/6to4/pkg/DEINSTALL new file mode 100644 index 00000000000..7d573d8b752 --- /dev/null +++ b/net/6to4/pkg/DEINSTALL @@ -0,0 +1,20 @@ +#! /bin/sh +# +# $NetBSD: DEINSTALL,v 1.1.1.1 2001/02/11 05:24:29 hubertf Exp $ +# + +case "$2" in + DEINSTALL) + if [ -f @PREFIX@/etc/6to4.conf ]; then + cat <