GRE (Generic Routing Encapsulation) ist ein Tunneling Protokoll, das in erster Linie dazu verwendet wird, Pakete zwischen verschiedenen Netzwerken zu transportieren. Es bietet eine Möglichkeit, IPv4- oder IPv6-Pakete in einem anderen IP-Header zu kapseln, um sie über ein Netzwerk zu übertragen, das nicht das ursprüngliche Netzwerkprotokoll unterstützt.
GRE selbst bietet **keine Sicherheitsfunktionen wie Verschlüsselung, Authentifizierung oder Integritätsschutz**. Daher ist es im Allgemeinen weniger sicher als VPN-Protokolle wie [[IPSec]].
GRE und IPSec können kombiniert werden. Diese Kombination wird als "GRE over IPSec" bezeichnet. Hierbei wird GRE verwendet, um ein Tunneling zu ermöglichen, und dann wird IPSec für die Sicherheit des Datenverkehrs innerhalb des GRE-Tunnels verwendet. Dies kann nützlich sein, wenn Sie die Vorteile von GRE für das Routing und Tunneling benötigen, aber auch die zusätzliche Sicherheit von IPSec wünschen. Siehe [[https://www.youtube.com/watch?v=anm84IVNBZU|GRE over IPsec - Kevin Wallace - Youtube]]
Auf Cisco ist ein Tunnel automatisch GRE wenn man kein anderes Protokoll angibt.
Es gibt auch Multipoint GRE für mehrere Teilnehmer. Siehe [[DMVPN]].
=====Beispiele=====
====Cisco====
{{gre_tunnel_lab_gns3.png}}
! R1
int fa0/0
ip addr 100.0.0.1 255.255.255.0
no shut
int fa1/0
ip addr 200.0.0.1 255.255.255.0
no shut
! R2
int fa0/0
ip add 100.0.0.2 255.255.255.0
no shut
int fa1/0
ip addr 192.168.1.1 255.255.255.0
no shut
int tun0
ip addr 10.0.0.1 255.255.255.0
tunnel source fa0/0
tunnel destination 200.0.0.2
exit
ip route 0.0.0.0 0.0.0.0 100.0.0.1
ip route 192.168.2.0 255.255.255.0 10.0.0.2
! R3
int fa0/0
ip addr 200.0.0.2 255.255.255.0
no shut
int fa1/0
ip addr 192.168.2.1 255.255.255.0
no shut
int tun0
ip addr 10.0.0.2 255.255.255.0
tunnel source fa0/0
tunnel destination 100.0.0.2
exit
ip route 0.0.0.0 0.0.0.0 200.0.0.1
ip route 192.168.1.0 255.255.255.0 10.0.0.1
====Fortigate====
{{gre_tunnel_lab_fortigate_gns3.png}}
# FG1
config system interface
edit "port1"
set mode static
set ip 100.0.0.2 255.255.255.0
set role wan
set alias "WAN"
next
edit "port2"
set ip 192.168.1.1 255.255.255.0
set role lan
set alias "LAN"
next
end
config system gre-tunnel
edit "toFG2"
set interface "port1"
set local-gw 100.0.0.2
set remote-gw 200.0.0.2
next
end
config router static
edit 0
set device "port1"
set gateway 100.0.0.1
set comment "default-route to Internet"
next
edit 0
set device "toFG2"
set dst 192.168.2.1 255.255.255.0
next
end
config firewall policy
edit 0
set srcintf "port2"
set dstintf "toFG2"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
edit 0
set srcintf "toFG2"
set dstintf "port2"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
end
# FG2
config system interface
edit "port1"
set mode static
set ip 200.0.0.2 255.255.255.0
set role wan
set alias "WAN"
next
edit "port2"
set ip 192.168.2.1 255.255.255.0
set role lan
set alias "LAN"
next
end
config system gre-tunnel
edit "toFG1"
set interface "port1"
set local-gw 200.0.0.2
set remote-gw 100.0.0.2
next
end
config router static
edit 0
set device "port1"
set gateway 200.0.0.1
set comment "default-route to Internet"
next
edit 0
set device "toFG1"
set dst 192.168.1.1 255.255.255.0
next
end
config firewall policy
edit 0
set srcintf "port2"
set dstintf "toFG1"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
edit 0
set srcintf "toFG1"
set dstintf "port2"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
end
=====GRE IPSec Tunnel=====
Siehe auch [[IPSec]].
{{gre_ipsec_tunnel.png}}
Zwischen R2 und R3 ist ein GRE Tunnel eingerichtet.
#R2
crypto isakmp policy 1
encryption aes 256
authentication pre-share
crypto isakmp key cisco address 200.0.0.2
crypto ipsec transform-set MYSET esp-aes esp-sha-hmac
ip access-list extended GRE-IN-IPSEC
permit gre any any
crypto map IPSECVPN 10 ipsec-isakmp
match address GRE-IN-IPSEC
set transform-set MYSET
set peer 200.0.0.2
interface fa0/0
crypto map IPSECVPN
#R3
crypto isakmp policy 1
encryption aes 256
authentication pre-share
crypto isakmp key cisco address 100.0.0.2
crypto ipsec transform-set MYSET esp-aes esp-sha-hmac
ip access-list extended GRE-IN-IPSEC
permit gre any any
crypto map IPSECVPN 10 ipsec-isakmp
match address GRE-IN-IPSEC
set transform-set MYSET
set peer 100.0.0.2
interface fa0/0
crypto map IPSECVPN
=====Links=====
* [[https://www.youtube.com/watch?v=ytAqv7qHGyU|How GRE Tunnels work Part 1 - Youtube]]
* [[https://www.youtube.com/watch?v=4IRefeZ3vyY|How GRE Tunnels work Part 2 - Youtube]]
* [[https://www.youtube.com/watch?v=ruhvoBt73yc|FREE CCNA Lab 065: GRE - Jeremys IT Lab - Youtube]]
* [[https://www.youtube.com/watch?v=anm84IVNBZU|Talk: GRE over IPSec]]