Create GRE tunnels under Linux

Source: Internet
Author: User

The GRE tunnel is a IP-OVER-IP tunnel, which is a generic routing encapsulation protocol that encapsulates the datagram of some network layer protocols so that the encapsulated datagrams can be transmitted in the Ipv4/ipv6 network.

The tunnel is a virtual point-to-point connection that provides a path for the encapsulated data packet to be transmitted over the path and encapsulates and encapsulates the datagram at both ends of a tunnel. The message of an X protocol to pass through the IP network in the tunnel, must be packaged and unpacked two processes.

To create a GRE tunnel on Linux , you need to Ip_ The GRE kernel module, which is GRE through the IPV4 tunnel driver.


In general, it is more convenient to configure GRE on router switches.


Cisco configuration is as follows:

R1 (config) #int Tun 0
R1 (config-if) #tun source s2/0
R1 (config-if) #tunnel destination 10.10.23.3
R1 (config-if) #ip add 100.100.100.1 255.255.255.252
R1 (config-if) #no shut

Huawei configuration is as follows:

[S9312] Interface tunnel 1/0/1
[S9312-TUNNEL1/0/1] Tunnel-protocol GRE
[S9312-TUNNEL1/0/1] IP address 3.3.3.1 255.255.255.252
[S9312-TUNNEL1/0/1] Source 1.1.1.1

[S9312-TUNNEL1/0/1] Destination 2.2.2.2

When the configuration is complete, review the status of the tunnel interface and manually test if the direct-connect address is connected. After Setup is complete, you can configure the route to use the link.


The Linux section configuration is described in the attachment.


Here's how to view the GRE tunnels under Linux:

1.ifconfig

[Email protected] ~]# ifconfig gre1

Gre1 Link Encap:unspec HWaddr da-b9-f5-04-6e-6f-92-d2-00-00-00-00-00-00-00-00

inet addr:10.254.10.2 p-t-p:10.254.10.1 mask:255.255.255.255

Up Pointopoint RUNNING noarp mtu:1476 metric:1

RX packets:9857 errors:0 dropped:0 overruns:0 frame:0

TX packets:20133 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:540500 (527.8 KiB) TX bytes:16258447 (15.5 MiB)

2.ip Link Show

[[Email protected] ~]# IP link Show

1:lo: <LOOPBACK,UP,LOWER_UP> MTU 16436 qdisc noqueue State UNKNOWN

Link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00

2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast State up Qlen 1000

Link/ether 00:15:5d:f5:02:01 BRD FF:FF:FF:FF:FF:FF

3:GRE0: <NOARP> MTU 1476 Qdisc NoOp State down

Link/gre 0.0.0.0 BRD 0.0.0.0

4:gre1: <POINTOPOINT,NOARP,UP,LOWER_UP> MTU 1476 Qdisc noqueue State UNKNOWN

Link/gre 218.185.245.4 Peer 101.227.67.160

5:gre2: <POINTOPOINT,NOARP,UP,LOWER_UP> MTU 1476 Qdisc noqueue State UNKNOWN

Link/gre 218.185.245.4 Peer 43.240.245.254


It is worth noting that the change in the MTU value of the link causes the problem of data transfer after the GRE tunnel is established. This is evident when doing the SCP.

This article from the "Garbled Age" blog, declined to reprint!

Create GRE tunnels under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.