Generic Enapsulation Tunnel is a kind of network tunneling technology, it is called General tunneling technology, it can be used to package the Ethernet, IP, MPLS and other packets in the IP packet to be forwarded in the network, there is a large-scale application.
The Linux system natively supports the GRE interface with the following configuration commands:
IP tunnel Add gret1 mode GRE remote 45.42.104.183 local 189.245.246.51 TTL 128 # Configure a 189.245.246.51 for the source address, 45.42.104.183 for the purpose The GRE tunnel of the address
IP link set gret1 up # set to Up
IP addr Add 1.1.1.2/32 dev Gret1 # Configure IP addresses for this GRE tunnel
IP route add 2.2.2.2/32 dev Gret1 # Configure routing 2.2.2.2/32 to Gre1
After the above configuration, access to 2.2.2.2/32 this address will be encapsulated into the GRE message through GRET1, the source destination address of the outer IP message is: 189.245.246.51/45.42.104.183, the source of the inner IP message address is: 1.1.1.2/ 2.2.2.2.
With this configuration, we can establish an end-to-end path between the two devices, and the ingress device can dnat access to its own traffic through the iptables to the 2.2.2.2 IP, thereby passing the GRE Tunnel arrives at the machine where the 2.2.2.2 is located, deploying a proxy server on the 2.2.2.2 enables tunneling across the Internet.
With this technology you can achieve more features, such as the use of this technology to achieve scientific access to the Internet (similar products can refer to http://www.youmen.in).
The construction principle of Linux GRE Tunnel