Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

GNS3 configuration GRE

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

1. Brief introduction

GRE (Generic Routing Encapsulation) GRE is one of the most traditional tunneling protocols, and its basic function is to realize the tunneling function so that remote networks can access each other through internal private networks.

As an example in the figure above, suppose that XP1 with IP address 10.1.1.1 wants to access XP2 with IP address 192.168.1.1. The process is roughly as follows:

When a packet with a source IP of 10.1.1.1 and a destination of 192.168.1.1 arrives on router R2, because R2 is configured with GRE, another IP header is encapsulated on the original packet, with a source IP of 1.1.1.1 and a destination IP of 1.1.1.2.

Before the packet is sent to the public network, the new IP header is encapsulated on the original packet, with a source IP of 12.1.1.2 and a destination IP of 13.1.1.3, and then the router sends the packet according to the route.

After the packet arrives at router R3, it unencapsulates the received packet and finds the GRE header, which itself is the end of the GRE tunnel, and unencapsulates the packet again. It finds that the source IP address is 10.1.1.1, the destination IP address is 192.168.1.1, and then the packet is sent to XP2.

When XP2 receives the packet, it responds to a packet with a source IP of 192.168.1.1 and a destination IP of 10.1.1.1. The GRE header is also encapsulated when it arrives at router R3, with a source IP of 1.1.1.2 and a destination IP of 1.1.1.1. Then encapsulate the public network IP header with a source IP of 13.1.1.3 and a destination IP of 12.1.1.2. Finally, the packet is sent out.

When the packet arrives at router R2, it unencapsulates the received packet, discovers the GRE header, and is the end point of the GRE tunnel, unencapsulates the packet again, finds that the source IP address is 192.168.1.1, the destination IP address is 10.1.1.1, and then sends the packet to XP1. So far, a complete communication process of exchange of visits through the private network has been completed.

2. Basic network configuration.

R1 configuration:

Interface FastEthernet0/0

Ip address 12.1.1.1 255.255.255.0

Interface FastEthernet1/0

Ip address 13.1.1.1 255.255.255.0

R2 configuration:

Interface FastEthernet0/0

Ip address 12.1.1.2 255.255.255.0

Interface FastEthernet1/0

Ip address 10.1.1.254 255.255.255.0

Ip route 0.0.0.0 0.0.0.0 12.1.1.1

R3 configuration:

Interface FastEthernet0/0

Ip address 13.1.1.3 255.255.255.0

Interface FastEthernet1/0

Ip address 192.168.1.254 255.255.255.0.3

Ip route 0.0.0.0 0.0.0.0 13.1.1.1

At this time, XP1 and XP2 cannot communicate with each other through the private network.

3. GRE configuration

R2 configuration:

Interface Tunnel2

Ip address 1.1.1.1 255.255.255.252

Tunnel source 12.1.1.2

Tunnel destination 13.1.1.3

R3 configuration:

Interface Tunnel3

Ip address 1.1.1.2 255.255.255.252

Tunnel source 13.1.1.3

Tunnel destination 12.1.1.2

At this time, XP1 and XP2 still cannot communicate with each other through the private network, because the packet sends the data through the physical port, and when it arrives in the public network, the packet is discarded because there is no route to the private network.

4. GRE routing configuration.

R2 configuration:

Ip route 192.168.1.0 255.255.255.0 Tunnel2

R3 configuration:

Ip route 10.1.1.0 255.255.255.0 Tunnel3

After GRE routing is configured, all packets destined for the private network go through the GRE tunnel. At this point, you can communicate normally through the private network.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report