2008年10月1日 星期三

Tunnel GRE Encapulate

Source : [O'relly] : Linux Server Hacks #51

一、需要安裝iproute2套件

二、載入gre核心模組

modprobe ip_gre

或將ip_gre加入/etc/modules使其開機自動載入

三、假設網路拓樸如下:

GRE

在RouterA

#ip tunnel add tunnel0 mode gre remote 26.13.15.239 local 203.14.26.9 ttl 255
#ip addr add 10.1.1.254 dev tunnel0
#ip link set tunnel0 up
#ip route add 10.1.1.0/24 dev tunnel0

RouterB

#ip tunnel add tunnel0 mode gre remote 203.14.26.9 local 26.13.15.239 ttl 255
#ip addr add 10.1.2.254 dev tunnel0
#ip link set tunnel0 up
#ip route add 10.1.2.0/24 dev tunnel0

最後一條指令ip route add 是linux對核心路由表加入靜態路由的指令
如果要linux主機成為router可以參考GNU Zebra 來跑routing protocol

四、撤銷通道

#ip link set tunnel0 down
#ip tunnel del tunnel0

沒有留言: