You are here

How to Easily Set Up an IPIP Tunnel on Ubuntu 16.04 and CentOS 7


How to Easily Set Up an IPIP Tunnel on Ubuntu 16.04 and CentOS 7

Creating a stable connection between various Linux systems is paramount for modern network specialists. Enter the world of IPIP tunneling, one of the most straightforward solutions available. In this guide, you'll uncover the nuances of setting up an IPIP tunnel on two popular Linux distributions: Ubuntu 16.04 and CentOS 7.

Requirements for a Successful IPIP Tunnel Setup:

To ensure a seamless connection, there are a few prerequisites:

  • Servers must have public IP addresses, enabling direct communication.
  • Alternatively, for testing purposes, they can have private addresses but should reside within the same network.

Setting Up the Tunnel on Ubuntu 16.04:

Ubuntu, with its IP address 192.168.1.126, requires specific configurations. Follow the steps below:

  1. Navigate to /etc/network/interfaces using the command nano /etc/network/interfaces.
  2. Insert the following configuration:

auto tun0
    iface tun0 inet static
    address 10.0.0.1
    netmask 255.255.255.0
    pointopoint 10.0.0.2
    pre-up ip tunnel add tun0 mode ipip local 192.168.1.126 remote 192.168.1.119
    post-down iptunnel del tun0

  1. Restart the network using /etc/init.d/networking restart.
  2. Verify the setup with ifconfig. A new tun0 interface should now be visible.

tun0      Link encap:IPIP Tunnel  HWaddr   
          inet addr:10.0.0.1  P-t-P:10.0.0.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP  MTU:1480  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:168 (168.0 B)  TX bytes:672 (672.0 B)

Tunnel Configuration on CentOS 7:

For CentOS 7, with its designated IP address of 192.168.1.119, the procedure is slightly varied:

  1. Create the configuration file at /etc/sysconfig/network-scripts/ifcfg-tun0.
/etc/sysconfig/network-scripts/ifcfg-tun0
  1. Populate it with the given details:

DEVICE=tun0
MY_OUTER_IPADDR=192.168.1.119
PEER_OUTER_IPADDR=192.168.1.126
MY_INNER_IPADDR=10.0.0.2
PEER_INNER_IPADDR=10.0.0.1
TYPE=IPIP

  1. Initiate a network restart: /etc/init.d/network restart.
  2. Validate the setup through ifconfig to ensure the appearance of the tun0 interface.

tun0: flags=209<UP,POINTOPOINT,RUNNING,NOARP>  mtu 1480
        inet 10.0.0.2  netmask 255.255.255.255  destination 10.0.0.1
        tunnel   txqueuelen 1  (IPIP Tunnel)
        RX packets 2  bytes 168 (168.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2  bytes 168 (168.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Conclusion & Key Takeaways:

Successfully establishing an IPIP tunnel between Ubuntu and CentOS facilitates efficient server-to-server communication. Whether for professional use or testing purposes, mastering this skill can significantly streamline Linux networking tasks.

FAQs:

  1. What is an IPIP tunnel?
    • It's a tunneling protocol that encapsulates one IP packet in another IP packet to transport it over an IP network.
  2. Can I use a different Linux distribution?
    • While this guide focuses on Ubuntu 16.04 and CentOS 7, the general principles can be applied to other distributions with minor adjustments.

Engage with Us:

Found this guide helpful? Explore more about system administration on our blog. Questions or feedback? Leave a comment below!

0 0

Share the article with your friends in social networks, maybe it will be useful to them.


If the article helped you, you can >>thank the author<<