MARWAN docs NOC knowledge base
DocsRouting and high availability

MARWAN 6in4 tunnel broker

Get IPv6 over an IPv4-only internet link with the MARWAN 6in4 tunnel broker, and configure the client side on a Cisco router or a Linux host.

Published Sami Ait Ali Oulahcen

Why a tunnel broker#

As part of the national IPv6 deployment plan for Moroccan public administrations, pilot sites needed IPv6 in their own premises to test it and report back. Internet service providers in Morocco did not offer IPv6 commercially, so MARWAN, the national research and education network, offered a tunnel broker to public administrations that wanted IPv6 access.

The service gives a site IPv6 connectivity and its own /48 prefix over its existing IPv4 internet link, without waiting for its provider.

How 6in4 works#

6in4 carries IPv6 traffic across the IPv4 internet. Each IPv6 packet is wrapped in an IPv4 header (IP protocol number 41) and sent to the MARWAN 6in4 server, which removes that header and forwards the IPv6 packet to its destination. Return traffic takes the same path in reverse.

                                +-------------+
                                |    IPv4     |
                                |   header    |
  +-------------+               +-------------+
  |    IPv6     |               |    IPv6     |
  |   header    |               |   header    |
  +-------------+               +-------------+
  |  Transport  |     ===>      |  Transport  |
  |   header    |               |   header    |
  +-------------+               +-------------+
  ~    Data     ~               ~    Data     ~
  +-------------+               +-------------+

The tunnel MTU is set to 1280 bytes, the minimum MTU every IPv6 link must support, so packets fit inside the IPv4 path without fragmentation problems.

The tunnel is point to point:

  • MARWAN side: a dual-stack 6in4 server, reachable over IPv4 at 196.200.160.40.
  • Your side: a device with a public IPv4 address, preferably a router. A Linux host or a firewall that can route also works.
  • Your prefix: MARWAN assigns your site a /48, so you can build a proper addressing plan and give IPv6 to every network you need.
  • Routing: all public IPv6 traffic (2000::/3) is routed into the tunnel.
flowchart LR
  LAN["Your LAN<br/>2001:4310:80xx::/48"] --- R["Your router<br/>public IPv4"]
  R -- "IPv4 internet<br/>(protocol 41)" --> S["MARWAN 6in4 server<br/>196.200.160.40<br/>dual stack"]
  R -. "6in4 tunnel<br/>2001:4310:f1:ffxx::2 โ†” ::1" .- S
  S --- V6["IPv6 internet"]
Your device must not be behind NAT

The tunnel runs between your public IPv4 address and the MARWAN server. A device behind NAT, a proxy or a firewall that rewrites addresses won't work. If a firewall sits in front of your router, allow IP protocol 41 (not a TCP or UDP port) between your public address and 196.200.160.40.

What MARWAN gives you#

Write these down before you configure anything:

Item Value
Tunnel destination (MARWAN server, IPv4) 196.200.160.40
Tunnel source the public IPv4 address of your router
MARWAN end of the tunnel (IPv6) 2001:4310:f1:ffxx::1
Your end of the tunnel (IPv6) 2001:4310:f1:ffxx::2/64, sent to you by MARWAN
Your site prefix 2001:4310:80xx::/48, sent to you by MARWAN
Your LAN addresses taken from your /48, for example 2001:4310:80xx::/64 for the first LAN

xx stands for the values MARWAN assigns to your site.

Configure a Cisco router#

Enable IPv6 routing, create the tunnel, give your LAN interface an address from your prefix, and send all public IPv6 traffic into the tunnel.

Cisco IOS
ipv6 unicast-routing
ipv6 cef
!
interface Tunnel0
 description 6in4 to MARWAN tunnel broker
 no ip address
 ipv6 address 2001:4310:f1:ffxx::2/64
 ipv6 enable
 ipv6 mtu 1280
 ipv6 tcp adjust-mss 1220
 tunnel source <your.public.ipv4.address>
 tunnel destination 196.200.160.40
 tunnel mode ipv6ip
!
interface <lan-interface>
 ipv6 address 2001:4310:80xx::1/64
 ipv6 enable
!
ipv6 route 2000::/3 Tunnel0

ipv6 tcp adjust-mss 1220 lowers the TCP MSS to fit the 1280-byte MTU, which avoids stalled downloads when ICMPv6 "packet too big" messages are filtered somewhere on the path.

Optional: hand out DNS to LAN clients#

With ipv6 unicast-routing on, the router already sends router advertisements on the LAN, so hosts configure their own address (SLAAC) and default route. To also give them a DNS server and domain, add stateless DHCPv6:

Cisco IOS
ipv6 dhcp pool marwan-tunnel-broker
 dns-server 2001:4310:f1:d::160
 domain-name marwan.ma
!
interface <lan-interface>
 ipv6 nd other-config-flag
 ipv6 dhcp server marwan-tunnel-broker

Replace the DNS server and domain with your own if you run them.

Configure a Linux host#

A Linux router or server can be the tunnel endpoint too. These iproute2 commands bring the tunnel up until the next reboot, which is handy for a first test:

ip tunnel add marwan6 mode sit remote 196.200.160.40 local <your.public.ipv4.address> ttl 64
ip link set marwan6 mtu 1280 up
ip -6 addr add 2001:4310:f1:ffxx::2/64 dev marwan6
ip -6 route add 2000::/3 dev marwan6

To make it permanent on Debian or Ubuntu with ifupdown:

/etc/network/interfaces
auto marwan6
iface marwan6 inet6 v4tunnel
    address 2001:4310:f1:ffxx::2
    netmask 64
    endpoint 196.200.160.40
    local <your.public.ipv4.address>
    ttl 64
    up ip link set mtu 1280 dev marwan6
    up ip -6 route add 2000::/3 dev marwan6

To route the rest of your /48 to a LAN behind this host, also turn on forwarding (sysctl -w net.ipv6.conf.all.forwarding=1) and give the LAN interface an address such as 2001:4310:80xx::1/64.

Check that it works#

On a Cisco router:

show interface Tunnel0
show ipv6 interface brief
ping 2001:4310:f1:ffxx::1
ping ipv6 2001:4860:4860::8888 source <lan-interface>
traceroute ipv6 docs.marwan.ma

On Linux:

$ ip -6 route
$ ping -6 -c 3 2001:4310:f1:ffxx::1
$ ping -6 -c 3 docs.marwan.ma

If the tunnel interface is up but the MARWAN end doesn't answer, check that protocol 41 is allowed in both directions and that your public address matches the one you gave MARWAN.

How the MARWAN side is set up#

For reference, and for other networks that want to run the same service: the 6in4 server is a dual-stack Ubuntu host. Each client gets one v4tunnel interface, plus a route that sends the client's /48 into that tunnel.

/etc/network/interfaces (server, one block per client)
auto 6in4-client1
iface 6in4-client1 inet6 v4tunnel
    address 2001:4310:f1:ffxx::1
    netmask 64
    endpoint <client.public.ipv4.address>
    ttl 64
    up ip link set mtu 1280 dev 6in4-client1
    up ip route add 2001:4310:80xx::/48 dev 6in4-client1

After systemctl restart networking, ip -6 route shows the tunnel /64 and the client's /48 on the tunnel interface:

$ ip -6 route list
2001:4310:f1:ffxx::/64 dev 6in4-client1 proto kernel metric 256 mtu 1280 pref medium
2001:4310:80xx::/48 dev 6in4-client1 metric 1024 pref medium
default via 2001:4310:f1::1 dev ens32 metric 1024 pref medium

Request a tunnel#

Public administrations and MARWAN member institutions can ask the MARWAN NOC for a tunnel by email at noc@marwan.ma. Send the public IPv4 address of the device that will terminate it. MARWAN replies with your tunnel addresses and your /48 prefix.