Creating a GRE tunnel for traversing a public network

This example creates a GRE tunnel between two switches, enabling traffic from two networks to traverse a public network.

Procedure
  1. 在开关1:
    1. Enable interface1/1/1and assign the IP address10.1.1.1/24to it.
      switch#configswitch(config)#interface 1/1/1switch(config-if)#ip address 10.1.1.1/24switch(config-if)#no shutdown
    2. Enable interface1/1/2and assign the IP address180.1.10.2/24to it.
      switch#configswitch(config)#interface 1/1/2switch(config-if)#ip地址180.1.10.2/24switch(config-if)#no shutdownswitch(config-if)#exit
    3. Create GRE tunnel10and assign the IP address192.168.10.1/24, source address10.1.1.1, and destination address20.1.1.1to it.
      switch(config)#interface tunnel 10 mode gre ipv4switch(config-gre-if)#ip address 192.168.10.1/24switch(config-gre-if)#source ip 10.1.1.1switch(config-gre-if)#destination ip 20.1.1.1switch(config-gre-if)#no shutdownswitch(config-gre-if)#exit
    4. Defines routes so that traffic from network 1 can reach network 2 through the tunnel.
      switch(config)#ip route 20.1.1.0/24 10.1.1.2switch(config)#ip route 190.1.10.0/24 tunnel10
  2. On switch 2:
    1. Enable interface1/1/1and assign the IP address20.1.1.1/24to it.
      switch#configswitch(config)#interface 1/1/1switch(config-if)#ip address 20.1.1.1/24switch(config-if)#no shutdown
    2. Enable interface1/1/2and assign the IP address190.1.10.2/24to it.
      switch(config)#interface 1/1/2switch(config-if)#ip address 190.1.10.2/24switch(config-if)#no shutdownswitch(config-if)#exit
    3. Create GRE tunnel10and assign the IP address192.168.10.2/24, source address20.1.1.1, and destination address10.1.1.1to it.
      switch(config)#interface tunnel 10 mode gre ipv4switch(config-gre-if)#ip address 192.168.10.2/24switch(config-gre-if)#source ip 20.1.1.1switch(config-gre-if)#destination ip 10.1.1.1switch(config-gre-if)#no shutdownswitch(config-gre-if)#exit
    4. Defines routes so that traffic from network 2 can reach network 1 through the tunnel.
      switch(config)#ip route 10.1.1.0/24 20.1.1.2switch(config)#ip route 180.1.10.0/24 tunnel10