ip-tunnel(8)
Create, modify, and delete IP tunnel interfaces for encapsulating network traffic.
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
| Flag | What it does |
|---|---|
mode MODE | Tunnel encapsulation mode: sit, gre, ipip, vti, etc. |
remote ADDR | Remote tunnel endpoint IP address |
local ADDR | Local tunnel endpoint IP address |
ttl TTL | Time-to-live value for tunnel packets (default 64) |
tos TOS | Type-of-service field for tunnel encapsulation |
key KEY | Key for GRE tunnel (32-bit value or IP address format) |
ikey IKEY | Input key for GRE tunnel |
okey OKEY | Output key for GRE tunnel |
seq | Enable sequence numbers in GRE header |
nopmtudisc | Disable 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.5Display all configured tunnel interfaces and their parameters
ip tunnel showCreate 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 12345Modify the TTL value of an existing tunnel
ip tunnel change tun0 ttl 128Delete the tunnel interface named gre1
ip tunnel del gre1Create 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 100Bring up the tunnel and set MTU to account for IPv6 header overhead
ip link set tun0 up mtu 1480