liujp-arch / map646 Goto Github PK
View Code? Open in Web Editor NEWThis project forked from keiichishima/map646
A one to one address mapping program for tranlation from IPv4 packets to IPv6 packets and vice versa.
This project forked from keiichishima/map646
A one to one address mapping program for tranlation from IPv4 packets to IPv6 packets and vice versa.
/* * Copyright 2010, 2011, 2012 * IIJ Innovation Institute Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY IIJ INNOVATION INSTITUTE INC. ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL IIJ INNOVATION INSTITUTE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ============ INTRODUCTION ============ map646 is a one to one IPv4-IPv6 address mapping program for protocol translation. This program is used in a scenario when you have a pure IPv6 network but want to open some of the server services to IPv4 users. To do this, you need the following things. - IPv4 connectivity at the boundary of your IPv6 network. - Enough number of global IPv4 addresses that you want to map your IPv6 servers. ============== HOW TO COMPILE ============== Just type 'make'. The program is developed for the FreeBSD operating system and the Linux operating system, but if your operating system supports the tun interface, then you can probably compile the program. ================ HOW TO CONFIGURE ================ In this section, we assume that you have IPv6 address space 2001:db8:0:0::/64 for your pure IPv6 network. Also, we assume that you have 192.0.2.0/24 as global IPv4 address space. Your IPv6 nodes don't have any global IPv4 addresses, so they cannot communicate with IPv4 nodes. First we need to define the mapping information of your IPv6 servers and your global IPv4 addresses. As an example, let's define the following mapping. 192.0.2.1 <=> 2001:db8:0:0::100 192.0.2.2 <=> 2001:db8:0:0::500 With the above mapping, you are now exposing two of your IPv6 servers to the global IPv4 Internet, using 192.0.2.1 and 192.0.2.2. The program reads the configuration information from the configuration file located at /etc/map646.conf. The file contents should be as follows. ---- mapping-prefix 64:: map-static 192.0.2.1 2001:db8:0:0::100 map-static 192.0.2.2 2001:db8:0:0::500 ---- The first line defines the pseudo IPv6 prefix of the mapping system. When your IPv6 server communicates with an IPv4 node, the IPv4 node address is mapped to that prefix range. For example, if your server is contacting to 202.214.86.196, the endpoint address seen from your IPv6 server will be 64::cad6:56c4. The IPv4 addresses are mapped to the lower 4 bytes of the pseudo IPv6 address in a hexadecimal form (in this case, 0xCA (202), 0xD6 (214), 0x56 (86), and 0xC4 (196)). Similary, any IPv4 nodes can contact to your IPv6 server using the global address mapped to your server address. If the IPv4 node (which IPv4 address is 202.214.86.196) contacts to 192.0.2.2, then your IPv6 server (2001:db8:0:0::500) will receive an incoming packet from 64::cad6:56c5. To use the program, you need to setup your node as a router by enabling forwarding function. The following example is a sample startup operation procedure for the FreeBSD operating system. # (run map646 in background.) # sysctl -w net.inet.ip.forwarding=1 # sysctl -w net.inet6.ip6.forwarding=1 The below is an example in the Linux case. # (run map646 in background) # sysctl -w net.ipv4.conf.all.forwarding=1 # sysctl -w net.ipv6.conf.all.forwarding=1 Once you have done all the settings, your mapping server is ready. ================= DNS CONFIGURATION ================= You need to configure your IPv4 global addresses used to map your IPv6 servers in your DNS server database. The example entries are like below. your-ipv6-sever-1 IN A 192.0.2.1 your-ipv6-sever-2 IN A 192.0.2.2 Any IPv4 host can now contact to your IPv6 server 1 (2001:db8:0:0::100) by contacting your-ipv6-server-1.example.com. At this point, your IPv6 servers are fully accessible from any IPv4 hosts in the Internet. The reverse direction is a bit complicated. You need a modified DNS server for your pure IPv6 network, since the DNS server must reply a pseudo IPv6 address associated to the real IPv4 address that the server want to contact to. When your IPv6 server asks AAAA record of www.yahoo.com (assuming that it doesn't have IPv6 addresses and its IPv4 address is 72.30.2.43), your internal DNS server must reply 64::481e:22b. Unfortunately, this map646 package doesn't include the modified DNS server. You may be interested in using Trick Or Treat Daemon (totd) for this function (http://www.vermicelli.pasta.cs.uit.no/software/totd.html)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.