Search This Blog

Wednesday, July 11, 2012

How to configure GRE tunnel between Cisco IOS and Linux


Let’s have the following scenario:



Both nodes are connected through the internet, here in my example, using private IP.
On the Cisco device, Fa0/0 is the WAN interface with the following configuration:

interface Tunnel1
 description TO-LINUX-SERVER
 ip address 192.168.10.2 255.255.255.252
 ip mtu 1436
 tunnel source Fastethernet 0/0
 tunnel destination 172.16.0.2

Where tunnel source is the IP of the Cisco router, tunnel destination is the IP of the Linux server and 192.168.10.2 is the IP of the tunnel.
On the Linux server ETH0 is the WAN interface which connected to the internet

modprobe ip_gre
ip tunnel add gre_tun0 mode gre remote 10.0.0.2 local 172.16.0.2 ttl 255
ip tunnel ls
ip link ls dev gre_tun0
ip link set gre_tun0 up
ip link ls dev gre_tun0
ip addr add 192.168.10.1/30 dev gre_tun0
ip addr ls dev gre_tun0
ifconfig gre_tun0 mtu 1380

Modeprobe runs the module for GRE; ip tunnel creates the tunnel with gre_tun0 as the name for the tunnel. Remote and local are the same as source and destination.
In order to configure the GRE tunnel permanently and to make sure it will be configured after reload of the server use the following:

Vi /etc/rc.local

And add the configuration to the file:

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
modprobe ip_gre
#GRE Tunnel CONFIG
modprobe ip_gre
ip tunnel add gre_tun0 mode gre remote 10.0.0.2 local 172.16.0.2 ttl 255
ip tunnel ls
ip link ls dev gre_tun0
ip link set gre_tun0 up
ip link ls dev gre_tun0
ip addr add 192.168.10.1/30 dev gre_tun0
ip addr ls dev gre_tun0
ifconfig gre_tun0 mtu 1380
~                                                                                                       
~                                                                                                       
~                                                                                                        
~                                                                                                       
~                                                                                                        
"/etc/rc.local" 32L, 1051C

Don’t forget to type wq! to save the file.

Remember that GRE stands for General Routing Encapsulation and It’s not encrypting or protecting the data from eavesdrop eyes.  The encapsulation itself adds 24 bytes to the IP packet and (4 bytes for the GRE protocol and 20 bytes for one more IP header)


15 comments:

  1. Replies
    1. Nice article. All the sections of your site covered with great functions. I really like the content and discussions on your site. Thanks a lot for allowing me to join. I love to see more about GB WhatsApp 2022. Keep sharing and updating. Also share more posts with us. Thank you.

      Delete
  2. thanks for sharing information really it is very useful

    Data Interpretation for GRE Test

    ReplyDelete
  3. This blog is having the general information. Got a creative work and this is very different one.We have to develop our creativity mind.This blog helps for this. Thank you for this blog. This is very interesting and useful.
    GRE training institutes in chennai

    ReplyDelete
  4. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon. wordpress

    ReplyDelete
  5. The two iOS and Android make apps appear on the home screen. The portable stages permit clients to get to the as often as possible utilized apps legitimately from the home screen. Itools 4.4.5.8 crack

    ReplyDelete
  6. The other OS's have not been remembered for the count as they structure an exceptionally little aspect of the condition. In this way, with the colossal development in the versatile gaming industry, up and coming designers are ready with the unavoidable issue of picking among iOS and Android game turn of events.mx player

    ReplyDelete
  7. Get instant and affordable antivirus support service at Webroot Technical Support. Our expertise team are always there to help you. basicknowledgehub

    ReplyDelete
  8. Hey, thank you a lot for sharing this article with us. I can’t say, how grateful we are to read this. Also, I would love to share it with my friends and family, who are interested. I hope you will publish such articles in the future as well. It’s so helpful. Goodbye! Take a look at this wonderful article and download clash of clans MOD APK 2021 for free And visit netflix premium apk.

    ReplyDelete
  9. In general, we can see that most of the people are struggling to find the stuffs when you want to know. If you are looking for the same, then without going for a second thought, go ahead with this- Check new posts- fmwhatsapp and gbwhatsapp

    ReplyDelete
  10. Thanks for the post.. Here are the some interesting posts regarding your niche. Check now- COC MOD APK GBWhatsapp

    ReplyDelete
  11. Such an excellent post, thanks for sharing. Keep sharing stuff like this in the future.

    ReplyDelete
  12. Thanks for the detailed article on this topic. I would like to see more such awesome articles from you.

    ReplyDelete
  13. Wish to see this much more like this. Thanks for sharing your information!

    ReplyDelete
  14. Yes you heard it right I almost used every WhatsApp mod and checked all mods themes features and I found Amazing themes those are better than other WhatsApp Mods in FMWhatsApp.

    ReplyDelete