Wireless Hacks Free Open Book

Wireless Hacks

Previous Section Next Section

Hack 55 Tunneling: GRE Encapsulation

figs/expert.giffigs/hack55.gif

IP tunnels with GRE for supporting multicast and Cisco devices.

GRE stands for Generic Routing Encapsulation. Like IPIP tunneling [Hack #54], GRE is an unencrypted encapsulation protocol. The main advantages of using GRE instead of IPIP are that it supports multicast packets, and that it also interoperates with Cisco routers.

Just as with the IPIP tunneling hack, I assume that you have two private networks (10.42.1.0/24 and 10.42.2.0/24), and that these networks both have direct Internet connectivity via a Linux router at each network. The "real" IP address of the first network router is 240.101.83.2, and the "real" IP of the second router is 251.4.92.217.

Again, as with IPIP tunneling, you also need a copy of the advanced routing tools package (there is no shortcut for GRE tunnels in Linux 2.2 that I've been able to find). Once you have the iproute2 package installed, begin by loading the GRE kernel module on both routers:

  # modprobe ip_gre

On the first network's router, set up a new tunnel device:

  # ip tunnel add gre0 mode gre remote 251.4.92.217 local 240.101.83.2 [RETURN]
    ttl 255
  # ip addr add 10.42.1.254 dev gre0
  # ip link set gre0 up

Note that you can call the device anything you like; gre0 is just an example. Also, that 10.42.1.254 address can be any available address on the first network, but shouldn't be 10.42.1.1 (the IP already bound to its internal interface.) Now, add your network routes via the new tunnel interface:

  # ip route add 10.42.2.0/24 dev gre0

The first network is finished. Now for the second:

  # ip tunnel add gre0 mode gre remote 240.101.83.2 local 251.4.92.217 [RETURN]
    ttl 255
  # ip addr add 10.42.2.254 dev gre0
  # ip link set gre0 up
  # ip route add 10.42.1.0/24 dev gre0

Again, the 10.42.2.254 address can be any available address on the second network. Feel free to add as many ip route add ... dev gre0 commands as you need.

That's it! You should now be able to pass packets between the two networks as if the Internet didn't exist. A traceroute from the first network should show just a couple of hops to any host in the second network (although you'll probably notice a fair bit of latency when crossing the 10.42.2.254 hop, unless you're really well connected). If you're having trouble, check the notes in the IPIP example and don't panic. Your best friend when debugging new network configurations is probably a packet sniffer like tcpdump [Hack #37] or Ethereal [Hack #38].

To bring the tunnel down, run this on both routers:

  # ip link set gre0 down
  # ip tunnel del gre0

See Also

    Previous Section Next Section
    Index: [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O][P][Q][R][S][T][U][V][W][X][Z]


         Main Menu
    Main Page
    Table of content
    Copyright
    Credits
    Foreword
    Preface
    Chapter 1. The Standards
    Chapter 2. Bluetooth and Mobile Data
    Chapter 3. Network Monitoring
    Chapter 4. Hardware Hacks
    4.1 Hacks #43-69
    Hack 43 Add-on Laptop Antennas
    Hack 44 Increasing the Range of a Titanium PowerBook
    Hack 45 WET11 Upgrades
    Hack 46 AirPort Linux
    Hack 47 Java Configurator for AirPort APs
    Hack 48 Apple Software Base Station
    Hack 49 Adding an Antenna to the AirPort
    Hack 50 The NoCat Night Light
    Hack 51 Do-It-Yourself Access Point Hardware
    Hack 52 Compact Flash Hard Drive
    Hack 53 Pebble
    Hack 54 Tunneling: IPIP Encapsulation
    Hack 55 Tunneling: GRE Encapsulation
    Hack 56 Running Your Own Top-Level Domain
    Hack 57 Getting Started with Host AP
    Hack 58 Make Host AP a Layer 2 Bridge
    Hack 59 Bridging with a Firewall
    Hack 60 MAC Filtering with Host AP
    Hack 61 Hermes AP
    Hack 62 Microwave Cabling Guide
    Hack 63 Microwave Connector Reference
    Hack 64 Antenna Guide
    Hack 65 Client Capability Reference Chart
    Hack 66 Pigtails
    Hack 67 802.11 Hardware Suppliers
    Hack 68 Home-Brew Power over Ethernet
    Hack 69 Cheap but Effective Roof Mounts
    Chapter 5. Do-It-Yourself Antennas
    Chapter 6. Long Distance Links
    Chapter 7. Wireless Security
    Appendix A. Deep Dish Parabolic Reflector Template
    Colophon
    Index


    More Books
    PHP Hacks
    Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
    The Koran (Holy Qur'an)
    Macromedia Flash 8 Bible
    Search Engine Optimization for Dummies
    YouTube Traffic
    PHP 5 for Dummies
    Harry Potter and The Chamber of Secrets
    Harry Potter and the Sorcerer's Stone
    The Pilgrim's Progress
    Wireless Hacks
    Flash Hacks. 100 Industrial-Strength Tips & Tools
    PayPal Hacks. 100 Industrial-Strength Tips and Tools
    Amazon Hacks
    Pdf Hacks
    The Da Vinci Code
    Google Hacks
    The Holy Bible
    Windows XP For Dummies
    Harry Potter and the Half-Blood Prince
    Seo Book
    Upgrading and Repairing Networks
    Macromedia Dreamweaver 8 UNLEASHED
    Windows XP Annoyances
    Windows XP Hacks
    Microsoft Windows XP Power Toolkit
    Teach Yourself MS Office In 24Hours
    iPod & iTunes Missing Manual
    PC Hacks 100 Industrial-Strength Tips and Tools
    PC Overclocking, Optimization, and Tuning - 2th Edition
    PC Hardware In A Nutshell 3rd Edition
    PC Hardware in a Nutshell, 2nd Edition
    Upgrading and Repairing PCs
    Google for Dummies
    MySQL Cookbook
    Teach Yourself Macromedia Flash 8 In 24 Hours
    PHP CookBook
    Sams Teach Yourself JavaScript in 24 Hours
    PHP5 Manual
    Free Games Paper Airplanes
    500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele