11.1SitojunConfiguring FAITH IPv6-to-IPv4 TCP relay
21.1Sitojun
31.1SitojunKazu Yamamoto and Jun-ichiro itojun Hagino
41.11Sitojun$KAME: README,v 1.9 2002/05/09 14:10:06 itojun Exp $
51.1Sitojun
61.1Sitojun
71.1SitojunIntroduction
81.1Sitojun============
91.1Sitojun
101.1SitojunFAITH is a IPv6-to-IPv4 TCP relay.  It performs tcp relay just as some of
111.1Sitojunfirewall-oriented gateway does, but between IPv6 and IPv4 with address
121.4Sitojuntranslation.
131.4SitojunTCP connections has to be made from IPv6 node to IPv4 node.  FAITH will
141.1Sitojunnot relay connections for the opposite direction.
151.1SitojunTo perform relays, FAITH daemon needs to be executed on a router between
161.1Sitojunyour local IPv6 site and outside IPv4 network.  The daemon needs to be
171.1Sitojuninvoked per each TCP services (TCP port number).
181.1Sitojun
191.1Sitojun	IPv4 node "dest" = 123.4.5.6
201.1Sitojun		|
211.1Sitojun	[[[[ outside IPv4 ocean ]]]]
221.1Sitojun		|
231.1Sitojun	node that runs FAITH-daemon (usually a router)
241.1Sitojun		|
251.1Sitojun	==+=====+===+==== IPv6, or IPv4/v6 network in your site ^
261.1Sitojun	  |	    |						| connection
271.1Sitojun	clients	  IPv6 node "src"				|
281.1Sitojun
291.1SitojunYou will have to allocate an IPv6 address prefix to map IPv4 addresses into.
301.9SitojunThe following description uses 3ffe:0501:ffff:0000:: as example.
311.1SitojunPlease use a prefix which belongs to your site.
321.1SitojunFAITH will make it possible to make a IPv6 TCP connection From IPv6 node
331.1Sitojun"src", toward IPv4 node "dest", by specifying FAITH-mapped address
341.9Sitojun3ffe:0501:ffff:0000::123.4.5.6
351.9Sitojun(which is, 3ffe:0501:ffff:0000:0000:0000:7b04:0506).
361.10SlukemThe address mapping can be performed by hand:-), by special nameserver on
371.1Sitojunthe network, or by special resolver on the source node.
381.1Sitojun
391.1Sitojun
401.1SitojunSetup
411.1Sitojun=====
421.1Sitojun
431.1SitojunThe following example assumes:
441.9Sitojun- You have assigned 3ffe:0501:ffff:0000:: as FAITH adderss prefix.
451.1Sitojun- You are willing to provide IPv6-to IPv4 TCP relay for telnet.
461.1Sitojun
471.1Sitojun<<On the translating router on which faithd runs>>
481.1Sitojun
491.1Sitojun(1) If you have IPv6 TCP server for the "telnet" service, i.e. telnetd via
501.1Sitojun    inet6d, disable that daemon.  Comment out the line from "inet6d.conf"
511.1Sitojun    and send the HUP signal to "inet6d".
521.1Sitojun
531.1Sitojun(2) Execute sysctl as root to enable FAITH support in the kernel.
541.1Sitojun
551.1Sitojun        # sysctl -w net.inet6.ip6.keepfaith=1
561.1Sitojun
571.1Sitojun(3) Route packets toward FAITH prefix into "faith0" interface.
581.1Sitojun
591.9Sitojun	# ifconfig faith0 up
601.9Sitojun	# route add -inet6 3ffe:0501:ffff:0000:: -prefixlen 64 ::1
611.9Sitojun	# route change -inet6 3ffe:0501:ffff:0000:: -prefixlen 64 -ifp faith0
621.1Sitojun
631.1Sitojun(4) Execute "faithd" by root as follows:
641.1Sitojun
651.5Sitojun	# faithd telnet /usr/libexec/telnetd telnetd
661.1Sitojun
671.1Sitojun    1st argument is a service name you are willing to provide TCP relay.
681.1Sitojun	(it can be specified either by number "23" or by string "telnet")
691.1Sitojun    2nd argument is a path name for local IPv6 TCP server.  If there is a
701.1Sitojun    connection toward the router itself, this program will be invoked.
711.1Sitojun    3rd and the following arguments are arguments for the local IPv6 TCP
721.1Sitojun    server.  (3rd argument is typically the program name without its path.)
731.1Sitojun
741.1Sitojun    More examples:
751.1Sitojun
761.5Sitojun	# faithd ftpd /usr/libexec/ftpd ftpd -l
771.1Sitojun	# faithd sshd
781.1Sitojun
791.9SitojunIf inetd(8) on your platform have special support for faithd, it is possible
801.9Sitojunto setup faithd services via inetd(8).  Consult manpage for details.
811.9Sitojun
821.1Sitojun
831.1Sitojun<<Routing>>
841.1Sitojun
851.1Sitojun(4) Make sure that packets whose destinations match the prefix can
861.1Sitojunreach from the IPv6 host to the translating router.
871.1Sitojun
881.1Sitojun<<On the IPv6 host>>
891.1Sitojun
901.1SitojunThere are two ways to translate IPv4 address to IPv6 address:
911.1Sitojun	(a) Faked by DNS
921.1Sitojun	(b) Faked by /etc/hosts.
931.1Sitojun
941.1Sitojun(5.a) Install "newbie" and set up FAITH mode. See kit/ports/newbie.
951.1Sitojun
961.1Sitojun(5.b) Add an entry into /etc/hosts so that you can resolve hostname into
971.13Sgrantfaked IPv6 address.  For example, add the following line for
981.13Sgrantwww.NetBSD.org:
991.1Sitojun
1001.12Sgrant	3ffe:0501:ffff:0000::140.160.140.252	www.NetBSD.org
1011.1Sitojun
1021.1Sitojun<<On the translating router on which faithd runs.>>
1031.1Sitojun
1041.1Sitojun(6) To see if "faithd" works, watch "/var/log/daemon". Note: please
1051.1Sitojunsetup "/etc/syslog.conf" so that LOG_DAEMON messages are to be stored
1061.1Sitojunin "/var/log/daemon".
1071.1Sitojun
1081.1Sitojun	<e.g.>
1091.1Sitojun	daemon.*   /var/log/daemon
1101.1Sitojun
1111.1Sitojun
1121.9SitojunAccess control
1131.9Sitojun==============
1141.9Sitojun
1151.9SitojunSince faithd implements TCP relaying service, it is critical to implement
1161.9Sitojunproper access control to cope with malicious use.  Bad guy may try to
1171.9Sitojunuse your relay router to circumvent access controls, or may try to
1181.9Sitojunabuse your network (like sending SPAMs from IPv4 address that belong to you).
1191.9SitojunInstall IPv6 packet filter directives that would reject traffic from
1201.9Sitojununwanted source.  If you are using inetd-based setup, you may be able to
1211.9Sitojunuse access control mechanisms in inetd.
1221.9Sitojun
1231.9Sitojun
1241.1SitojunAdvanced configuration
1251.1Sitojun======================
1261.1Sitojun
1271.1SitojunIf you would like to restrict IPv4 destination for translation, you may
1281.1Sitojunwant to do the following:
1291.1Sitojun
1301.9Sitojun	# route add -inet6 3ffe:0501:ffff:0000::123.0.0.0 -prefixlen 104 ::1
1311.9Sitojun	# route change -inet6 3ffe:0501:ffff:0000::123.0.0.0 -prefixlen 104 \
1321.9Sitojun		-ifp faith0
1331.1Sitojun
1341.1SitojunBy this way, you can restrict IPv4 destination to 123.0.0.0/8.
1351.9SitojunYou may also want to reject packets toward 3ffe:0501:ffff:0000::/64 which
1361.9Sitojunis not in 3ffe:0501:ffff:0000::123.0.0.0/104.  This will be left as excerside
1371.1Sitojunfor the reader.
1381.1Sitojun
1391.1SitojunBy doing this, you will be able to provide your IPv4 web server to outside
1401.1SitojunIPv6 customers, without risks of unwanted open relays.
1411.1Sitojun
1421.6Sitojun	[[[[ IPv6 network outside ]]]]			|
1431.1Sitojun		|					| connection
1441.1Sitojun	node that runs FAITH-daemon (usually a router)	v
1451.1Sitojun		|
1461.6Sitojun	========+======== IPv4/v6 network in your site
1471.1Sitojun		|			(123.0.0.0/8)
1481.1Sitojun	IPv4 web server
149