How to check if a network tunnel is configured in Linux

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to check if a network tunnel is configured on your Linux system. You will use the ip tunnel show command to list existing tunnels and the ip link show command to verify their presence as network interfaces. Finally, you will explore how to inspect tunnel configurations within the /etc/network directory. This hands-on lab will provide you with the essential commands and techniques to identify and understand network tunnel setups in a Linux environment.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/BasicFileOperationsGroup(["Basic File Operations"]) linux(("Linux")) -.-> linux/RemoteAccessandNetworkingGroup(["Remote Access and Networking"]) linux/BasicFileOperationsGroup -.-> linux/cat("File Concatenating") linux/RemoteAccessandNetworkingGroup -.-> linux/ip("IP Managing") subgraph Lab Skills linux/cat -.-> lab-558744{{"How to check if a network tunnel is configured in Linux"}} linux/ip -.-> lab-558744{{"How to check if a network tunnel is configured in Linux"}} end

List tunnels with ip tunnel show

In this step, you will learn how to list existing network tunnels on your Linux system using the ip tunnel show command. Network tunnels are virtual connections that encapsulate network traffic, often used for VPNs or other networking configurations.

The ip command is a powerful utility for managing network interfaces, routing, and tunnels in Linux.

Open the terminal if you haven't already. You can do this by clicking the Xfce Terminal icon on the left side of your desktop.

Now, type the following command into the terminal and press Enter:

ip tunnel show

This command will display a list of all configured network tunnels on your system.

You might see output similar to this:

vti0: ip/ip remote any local any ttl inherit key 0

Or, if no tunnels are configured, you might see no output or a message indicating no tunnels are found.

The output provides information about each tunnel, such as:

  • The tunnel interface name (e.g., vti0).
  • The type of tunnel (e.g., ip/ip).
  • Remote and local IP addresses (if configured).
  • Time-to-Live (TTL) settings.
  • Key information (if used for authentication).

Understanding the output of ip tunnel show is the first step in managing network tunnels. It allows you to quickly see which tunnels are active and their basic configuration.

In the next steps, you will explore other ways to verify and inspect tunnel configurations.

Click Continue to proceed.

In the previous step, you used ip tunnel show to list tunnels. Now, let's use the ip link show command to see how these tunnels appear as network interfaces.

The ip link show command displays information about network interfaces on your system, including physical interfaces (like Ethernet or Wi-Fi) and virtual interfaces (like tunnels).

Type the following command into your terminal and press Enter:

ip link show

This command will output a list of all network interfaces. Look for interfaces that correspond to the tunnels you saw with ip tunnel show.

You should see output similar to this, which includes the vti0 interface we saw earlier:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
    link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff link-netnsid 0
3: vti0: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ipip 0.0.0.0 brd 0.0.0.0

Notice the entry for vti0. It's listed as a network interface with type link/ipip. This confirms that the tunnel is represented as a network interface in the system.

The ip link show command provides details about the state of the interface (e.g., UP or DOWN), its MTU (Maximum Transmission Unit), and other link-layer information.

Using both ip tunnel show and ip link show gives you a more complete picture of your network tunnel configuration and status.

Click Continue to move to the next step.

Inspect tunnel config in /etc/network

In the previous steps, you used ip tunnel show and ip link show to see active tunnels and their corresponding interfaces. Now, let's look at where some network interface configurations are stored on a Debian-based system like Ubuntu: the /etc/network/interfaces file.

This file is a common place to define network interfaces, including tunnels, that should be configured when the system starts.

You will use the cat command to display the contents of this file. cat is a simple command that reads files sequentially and prints them to the standard output.

Type the following command into your terminal and press Enter:

cat /etc/network/interfaces

You will see the content of the network interfaces configuration file. It might look something like this:

## interfaces(5) file used by ifup(8) and ifdown(8)
## Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

auto vti0
iface vti0 inet tunnel
    mode ipip
    address 192.168.1.1
    netmask 255.255.255.0
    local 10.0.0.1
    remote 10.0.0.2
    ttl 64
    key 1234

This output shows how the vti0 tunnel interface is defined. You can see:

  • auto vti0: This line indicates that the vti0 interface should be brought up automatically when the system starts.
  • iface vti0 inet tunnel: Defines vti0 as a tunnel interface using the inet tunnel family.
  • mode ipip: Specifies the tunneling protocol (IP-in-IP).
  • address, netmask, local, remote: These lines define the IP addressing and endpoints for the tunnel.
  • ttl: Sets the Time-to-Live for packets traversing the tunnel.
  • key: Specifies a key used for the tunnel (if configured).

Note: The exact content of this file may vary depending on the system's configuration. However, the structure for defining interfaces, including tunnels, is generally similar.

Inspecting configuration files like /etc/network/interfaces is crucial for understanding how your network interfaces, including tunnels, are set up persistently on the system.

You have now learned three different ways to examine network tunnels: listing them with ip tunnel show, verifying their interfaces with ip link show, and inspecting their configuration files.

Click Continue to complete this lab.

Summary

In this lab, you learned how to check for configured network tunnels in Linux. You started by using the ip tunnel show command to list existing tunnels and understand their basic configuration details like interface name, type, and addresses.

Following that, you explored how network tunnels appear as interfaces by using the ip link show command, which displays information about all network interfaces, including virtual ones like tunnels. These steps provide fundamental methods for verifying the presence and basic status of network tunnels on a Linux system.