[ Top page ]

« Software-based Ethernet switch | Main | Ethernet simulator for learning »

Network and communication

Two types of GRE tunneling configurations

A GRE tunnel can be created between two computers using an ip command. Either IP/GRE or (IP)/Ethernet/GRE tunnel can be created by slightly modifying the commands.

GRE (Generic Routing Encapsulation) is a layer 3 (L3) tunneling protocol, which was standardized by the IETF. The following command list is an example of a script that creates IP/GRE tunnel over IP.

ip tunnel add gre0 mode gre remote ${1} local ${2} key ${3}
ip addr add ${4} dev gre0
ip link set gre0 up
ip link set gre0 mtu 1460

As described in the first line, the command arguments are the destination IP address (i.e., the end of the GRE tunnel), the source (my) IP address (i.e., the beginning of the GRE tunnel), the GRE key, and the source (my) IP address on the tunnel (i.e., the IP address of the virtual network) and the subnet length. If the subnet length is not specified, an error occurs.

If no GRE key is specified by the ip tunnel command, the packet size becomes smaller; it must be specified for the above script. An example of the command usage follows.

./addgreip 1

The next script is for IP/Ethernet/GRE/IP.

ip link add gre1 type gretap remote ${1} local ${2} key ${3}
ip addr add ${4} dev gre1
ip link set gre1 up
ip link set gre1 mtu 1450

The command arguments are similar to those for the IP/GRE/IP commands. The MAC address specified in the inserted MAC header is filled by the computer if is is not specified by the user. An example of the command usage follows.

./addgreether 1

The ip command may refuse the above commnad (type gretap) when using older Linux. In such a case, a package called "iproute2" should be upgraded.

When IP/GRE/IP is used, an ip tunnel command is used for configuration. However, when IP/Ethernet/GRE/IP is used, an ip link command is used. As for command keywords, a "mode" parameter is used for GRE when IP/GRE is used. However, "type gretap" is used when IP/Ethernet/GRE is used. I am skeptical why these commands are so different.



TrackBack URL for this entry:

Post a comment


This page contains a single entry from the blog posted on February 18, 2013 9:13 PM.

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.36