In GRE over IPsec networking, using the same the source IP address for the GRE tunnel and the IPsec tunnel helps save IP address resources.
Figure 1 shows the networking diagram.
Interfaces 1 and 2 in this example represent GE 0/1/1 and GE 0/1/2, respectively.
Network A belongs to subnet 10.1.1.0/24 and connects to GE 0/1/1 on DeviceA.
Network B belongs to subnet 10.1.2.0/24 and connects to GE 0/1/1 on DeviceB.
DeviceA and DeviceB are routable to each other.
A GRE tunnel uses a loopback interface as a source interface, and an IPsec tunnel borrows an IP address of a physical interface. Because the IP address of the source interface of the GRE tunnel must be the same as the source IP address of the IPsec tunnel, bind the loopback interface to a VPN instance, preventing a public IP address conflict.
The binding tunnel ipsec command is automatically generated on the interface whose IP address is borrowed by the IPsec tunnel.
The configuration roadmap is as follows:
Configure a GRE tunnel between DeviceA and DeviceB to encapsulate multicast and broadcast packets.
Configure an IPsec tunnel between DeviceA and DeviceB to encrypt multicast and broadcast packets.
A GRE tunnel uses a loopback interface as a source interface, and an IPsec tunnel borrows an IP address of a physical interface.
To complete the configuration, you need the following data:
DeviceA configuration file
# sysname DeviceA # acl number 3000 rule 5 permit gre vpn-instance vpna source 172.16.3.1 0 destination 172.16.9.1 0 # ip vpn-instance vpna ipv4-family route-distinguisher 100:1 apply-label per-instance vpn-target 111:1 export-extcommunity vpn-target 111:1 import-extcommunity # service-location 1 location slot 1 # service-instance-group group1 service-location 1 # ike proposal 10 encryption-algorithm aes-cbc 256 dh group14 authentication-algorithm sha2-256 integrity-algorithm hmac-sha2-256 # ike peer b pre-shared-key %$%$THBGMJK2659z"C(T{J"-,.2n%$%$ ike-proposal 10 remote-address 172.16.9.1 sa binding vpn-instance vpna # ipsec proposal tran1 esp authentication-algorithm sha2-256 esp encryption-algorithm aes 256 # ipsec policy map1 10 isakmp security acl 3000 ike-peer b proposal tran1 # interface GigabitEthernet0/1/1 undo shutdown ip address 10.1.1.1 255.255.255.0 # interface GigabitEthernet0/1/2 undo shutdown ip address 172.16.3.1 255.255.255.0 binding tunnel ipsec # interface loopback1 ip binding vpn-instance vpna ip address 172.16.3.1 255.255.255.255 binding tunnel gre # interface Tunnel1 ip address unnumbered interface GigabitEthernet0/1/2 tunnel-protocol ipsec ipsec policy map1 service-instance-group group1 # interface Tunnel2 ip address 172.21.1.1 255.255.255.0 tunnel-protocol gre source loopback1 destination vpn-instance vpna 172.16.9.1 # ip route-static 10.1.2.2 255.255.255.255 Tunnel 2 172.16.9.1 ip route-static vpn-instance vpna 172.16.9.1 255.255.255.255 Tunnel 1 172.16.9.1 ip route-static 172.16.9.1 255.255.255.255 172.16.3.2 # return
# sysname DeviceB # acl number 3000 rule 5 permit gre vpn-instance vpna source 172.16.9.1 0 destination 172.16.3.1 0 # ip vpn-instance vpna ipv4-family route-distinguisher 100:1 apply-label per-instance vpn-target 111:1 export-extcommunity vpn-target 111:1 import-extcommunity # service-location 1 location slot 1 # service-instance-group group1 service-location 1 # ike proposal 10 encryption-algorithm aes-cbc 256 dh group14 authentication-algorithm sha2-256 integrity-algorithm hmac-sha2-256 # ike peer a pre-shared-key %$%$THBGMJK2659z"C(T{J"-,.2n%$%$ ike-proposal 10 remote-address 172.16.3.1 sa binding vpn-instance vpna # ipsec proposal tran1 esp authentication-algorithm sha2-256 esp encryption-algorithm aes 256 # ipsec policy map1 10 isakmp security acl 3000 ike-peer a proposal tran1 # interface GigabitEthernet0/1/1 undo shutdown ip address 10.1.2.1 255.255.255.0 # interface GigabitEthernet0/1/2 undo shutdown ip address 172.16.9.1 255.255.255.0 binding tunnel ipsec # interface loopback1 ip binding vpn-instance vpna ip address 172.16.9.1 255.255.255.255 binding tunnel gre # interface Tunnel1 ip address unnumbered interface GigabitEthernet0/1/2 tunnel-protocol ipsec ipsec policy map1 service-instance-group group1 # interface Tunnel2 ip address 172.22.1.2 255.255.255.0 tunnel-protocol gre source loopback1 destination vpn-instance vpna 172.16.3.1 # ip route-static 10.1.1.2 255.255.255.255 Tunnel 2 172.16.3.1 ip route-static vpn-instance vpna 172.16.3.1 255.255.255.255 Tunnel 1 172.16.3.1 ip route-static 172.16.3.1 255.255.255.255 172.16.9.2 # return