Creating a Tunnel
Problem
You want to tunnel IP traffic through your network.
Solution
The basic GRE tunnel configuration is simply a matter of defining the source and destination addresses or interfaces on both devices. On the first router, you need to create the tunnel interface and define its source and destination:
Router1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#interface Tunnel
Router1(config-if)#
1
ip address
Router1(config-if)#
192.168.35.6 255.255.255.252
tunnel source
Router1(config-if)#
172.25.1.5
tunnel destination
Router1(config-if)#
172.25.1.7
exit
Router1(config)#end
Router1#
Then, on the other router you must create a tunnel interface with a matching source and destination:
Router5#configure terminal
Enter configuration commands, one per line. End with CNTL/Z. Router5(config)#interface Tunnel
Router5(config-if)#
3
ip address
Router5(config-if)#
192.168.35.5 255.255.255.252
tunnel source
Router5(config-if)#
172.25.1.7
tunnel destination
Router5(config-if)#
172.25.1.5
exit
Router5(config)#end
Router5#
Discussion
Creating a basic tunnel is very simple—you just need to define a source and destination on each of two routers. When you do this, as with any other virtual interface such as subinterfaces and loopback interfaces, there is an additional memory requirement on the router. However, the CPU overhead is not as bad as you might initially think. This is because GRE tunnels do work well with Cisco Express Forwarding (CEF). So the ...
Get Cisco IOS Cookbook, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.