$linuxjunkies
>

ip-tunnel(8)

Create, modify, and delete IP tunnel interfaces for encapsulating network traffic.

UbuntuDebianFedoraArch

Synopsis

ip tunnel { add | del | change | show | prl | 6rd } TUNNEL_NAME [ mode MODE ] [ remote ADDR ] [ local ADDR ] [ other_options ]

Description

The ip tunnel command manages virtual tunnel interfaces that encapsulate packets within other packets. Common tunnel types include sit (IPv6 over IPv4), gre (Generic Routing Encapsulation), and ipip. Tunnels are essential for connecting networks across incompatible infrastructure or creating VPNs.

Before using a tunnel, you must create it with the add subcommand, configure its mode and endpoints, then bring it up with ip link set. You can inspect tunnel parameters with show and modify them with change.

Common options

FlagWhat it does
mode MODETunnel encapsulation mode: sit, gre, ipip, vti, etc.
remote ADDRRemote tunnel endpoint IP address
local ADDRLocal tunnel endpoint IP address
ttl TTLTime-to-live value for tunnel packets (default 64)
tos TOSType-of-service field for tunnel encapsulation
key KEYKey for GRE tunnel (32-bit value or IP address format)
ikey IKEYInput key for GRE tunnel
okey OKEYOutput key for GRE tunnel
seqEnable sequence numbers in GRE header
nopmtudiscDisable path MTU discovery clamping

Examples

Create a sit (IPv6-in-IPv4) tunnel named tun0 with remote and local endpoints

ip tunnel add tun0 mode sit remote 192.0.2.1 local 203.0.113.5

Display all configured tunnel interfaces and their parameters

ip tunnel show

Create a GRE tunnel with a 32-bit key for traffic identification

ip tunnel add gre1 mode gre remote 10.0.0.2 local 10.0.0.1 key 12345

Modify the TTL value of an existing tunnel

ip tunnel change tun0 ttl 128

Delete the tunnel interface named gre1

ip tunnel del gre1

Create a VTI (Virtual Tunnel Interface) for IPsec encapsulation

ip tunnel add vti0 mode vti remote 192.168.1.2 local 192.168.1.1 key 100

Bring up the tunnel and set MTU to account for IPv6 header overhead

ip link set tun0 up mtu 1480

Related commands