*** Static Tunnels ***

# Tunnel L3 GRE:

## Extremo1:
 ip tunnel add greipv6-0 mode gre remote 10.0.0.2                          
 ip link set greipv6-0 up                        
 ip -6 route add 2001:1::/64 dev greipv6-0       
 ip tunnel show 

## Extremo2:
 ip tunnel add greipv6-0 mode gre remote 10.0.0.1                          
 ip link set greipv6-0 up                        
 ip -6 route add 2001:0::/64 dev greipv6-0       
 ip tunnel show

# Tunnel L3 IPIPv6

## Extremo1:
 ip tunnel add ipipv6-0 mode sit remote 10.0.0.2                          
 ip link set ipipv6-0 up                        
 ip -6 route add 2001:1::/64 dev ipipv6-0       
 ip tunnel show 

## Extremo2:
 ip tunnel add ipipv6-0 mode sit remote 10.0.0.1                          
 ip link set ipipv6-0 up                        
 ip -6 route add 2001:0::/64 dev ipipv6-0       
 ip tunnel show

# Tunnel L3 6to4 (Actualmente desaconsejados, RFC-7526)

 Para que funcione adecuadamente las IP deberían ser públicas.
 192.88.99.1 es la IPv4 anycast del broker
 
 ipv4="10.0.0.1"; printf "2002:%02x%02x:%02x%02x::1" `echo -n $ipv4 | tr "." " "`
 2002:0a00:0001::1
 
 ipv4="10.0.0.2"; printf "2002:%02x%02x:%02x%02x::1" `echo -n $ipv4 | tr "." " "`
 2002:0a00:0002::1

## Extremo 1

 ip tunnel add tun6to4 mode sit remote any local 10.0.0.1
 ip link set dev tun6to4 up 
 ip -6 addr add 2002:0a00:0001::1/16 dev tun6to4
 ip -6 route add 2001:1::/64 via ::10.0.0.2 dev tun6to4 
 ip -6 route add default via ::192.88.99.1 dev tun6to4 
 
## Extremo 2

 ip tunnel add tun6to4 mode sit remote any local 10.0.0.2
 ip link set dev tun6to4 up 
 ip -6 addr add 2002:0a00:0002::1/16 dev tun6to4
 ip -6 route add 2001:0::/64 via ::10.0.0.1 dev tun6to4 
 ip -6 route add default via ::192.88.99.1 dev tun6to4 

# Tunnel L2 GRETAP

## Extremo 1

 ip link add name gretap1 type gretap local 10.0.0.1 remote 10.0.0.2
 ip link set gretap1 up
 brctl addbr br0
 ip link set br0 up
 brctl addif br0 eth1
 brctl addif br0 gretap1

## Extremo 2

 ip link add name gretap1 type gretap local 10.0.0.2 remote 10.0.0.1
 ip link set gretap1 up
 brctl addbr br0
 ip link set br0 up
 brctl addif br0 eth1
 brctl addif br0 gretap1

## Problemas con los MTU

root@n3:/tmp/pycore.33505/n3.conf# ping -s 1414 2001:0::11
PING 2001:0::11(2001::11) 1414 data bytes
1422 bytes from 2001::11: icmp_seq=1 ttl=64 time=0.133 ms
1422 bytes from 2001::11: icmp_seq=2 ttl=64 time=0.174 ms
^C
--- 2001:0::11 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1015ms
rtt min/avg/max/mdev = 0.133/0.153/0.174/0.023 ms

root@n3:/tmp/pycore.33505/n3.conf# ping -s 1415 2001:0::11
PING 2001:0::11(2001::11) 1415 data bytes
^C
--- 2001:0::11 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2029ms

root@n2:/tmp/pycore.33505/n2.conf# ip link show br0
7: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1462 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 00:00:00:aa:00:02 brd ff:ff:ff:ff:ff:ff

root@n2:/tmp/pycore.33505/n2.conf# ip link show eth1            
118: eth1@if119: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP mode DEFAULT group default qlen 1000
    link/ether 00:00:00:aa:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0

root@n2:/tmp/pycore.33505/n2.conf# ip link show gretap1
6: gretap1@NONE: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1462 qdisc fq_codel master br0 state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether d6:7e:5d:80:10:f1 brd ff:ff:ff:ff:ff:ff

### Solución 1:
 Achicar MTU en las LAN

root@n2:/tmp/pycore.33505/n1.conf# ip link set mtu 1462 dev eth1
root@n3:/tmp/pycore.33505/n3.conf# ip link set mtu 1462 dev eth0
root@n2:/tmp/pycore.33505/n2.conf#  ip link set mtu 1462 dev eth1
root@n3:/tmp/pycore.33505/n4.conf# ip link set mtu 1462 dev eth0

root@n3:/tmp/pycore.33505/n3.conf# ping -s 1415 2001:0::11
PING 2001:0::11(2001::11) 1415 data bytes
1423 bytes from 2001::11: icmp_seq=1 ttl=64 time=0.270 ms
1423 bytes from 2001::11: icmp_seq=2 ttl=64 time=0.238 ms
^C
--- 2001:0::11 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1014ms
rtt min/avg/max/mdev = 0.238/0.254/0.270/0.016 ms

# Tunnel L2 GENEVE

## Extremo 1

 ip link add name geneve0 type geneve id 1010 remote 10.0.0.2
 ip link set geneve0 up
 brctl addbr br0
 ip link set br0 up
 brctl addif br0 eth1
 brctl addif br0 geneve0

## Extremo 2

 ip link add name geneve0 type geneve id 1010 remote 10.0.0.1
 ip link set geneve0 up
 brctl addbr br0
 ip link set br0 up
 brctl addif br0 eth1
 brctl addif br0 geneve0

## No hay problema de MTU
root@n3:/tmp/pycore.33505/n3.conf# ping -s 2000 2001:0::11
PING 2001:0::11(2001::11) 2000 data bytes
2008 bytes from 2001::11: icmp_seq=1 ttl=64 time=0.242 ms
2008 bytes from 2001::11: icmp_seq=2 ttl=64 time=0.217 ms
2008 bytes from 2001::11: icmp_seq=3 ttl=64 time=0.334 ms
2008 bytes from 2001::11: icmp_seq=4 ttl=64 time=0.184 ms
2008 bytes from 2001::11: icmp_seq=5 ttl=64 time=0.272 ms
2008 bytes from 2001::11: icmp_seq=6 ttl=64 time=0.396 ms
2008 bytes from 2001::11: icmp_seq=7 ttl=64 time=0.346 ms
2008 bytes from 2001::11: icmp_seq=8 ttl=64 time=0.264 ms
2008 bytes from 2001::11: icmp_seq=9 ttl=64 time=0.263 ms



# Ref:
http://man7.org/linux/man-pages/man8/ip-tunnel.8.html

https://developers.redhat.com/blog/2019/05/17/an-introduction-to-linux-virtual-interfaces-tunnels/

https://mirrors.deepspace6.net/Linux+IPv6-HOWTO/chapter-configuring-ipv6-in-ipv4-tunnels.html
