add gre / gretap docs

Signed-off-by: Marek Küthe <m.k@mk16.de>
This commit is contained in:
Marek Küthe 2023-01-02 17:13:44 +01:00
parent 15e993248a
commit 1f5dbc082a
No known key found for this signature in database
GPG Key ID: 7E869146699108C7
1 changed files with 55 additions and 0 deletions

55
docs/tunneling/gre.md Normal file
View File

@ -0,0 +1,55 @@
# Generic Routing Encapsulation (GRE)
*Note:* GRE tunnels are unencrypted.
GRE tunnels on layer 3 of the ISO/OSI model.
## Configuring with ip
To create a tunnel, you can use the following command:
```
ip link add <interface> type gre remote <remote> local <local> ttl 255
```
Replace `<interface>` with the desired interface name, `<remote>` with the IPv4 of the peer and `<local>` with your own IPv4.
If you want to establish the tunnel over IPv6 instead, you can replace the `mode gre` with `mode ip6gre`.
To delete a tunnel, you can use the following command:
```
ip link del <interface>
```
To assign an IP address to the interface, you can use the following command:
```
ip link del <interface>
```
To assign an IP address to the interface, you can use the following command:
```
ip addr add dev <interface> <ll>
```
Replace `<ll>` with your own link-local address.
### Automatic start with ifupdown
If you want to start the GRE tunnel automatically, you can use an ifupdown template which is placed under `/etc/network/interfaces.d`:
```
auto <interface>
iface <interface> inet6 manual
pre-up ip link add <interface> type gre remote <remote> local <local> ttl 255
up ip addr add dev <interface> <ll>
post-down ip link del <interface>
```
The interface can then be stopped and started accordingly:
```
ifup <interface>
```
```
ifdown <interface>
```
## GRETAP
GRETAP tunnels operate on layer 2 of the ISO/OSI model. To use a GRETAP tunnel, you only have to change the mode: For IPv4 `gretap` and for IPv6 `ip6gretap`.