GRE(Generic Routing Encapsulation)
[GREとは]
GREはトラフィックを別のプロトコルでカプセル化して伝送する
トンネルプロトコルの1つ。
ちなみに主なトンネルプロトコルは下記。
Layer2トンネリング
・L2F
・PPTP
・L2TP
Layer3トンネリング
・GRE★
・IPsec
GREトンネリングでは任意のプロトコルのパケットをIPトンネル内で
カプセル化する。
GREトンネリングを行なう両端のルータでトラフィックに対する
カプセル化とその解除を行う。
GRE自体は暗号化機能を備えていなく、データ暗号化が必要な場合は
IPSecと併用する必要がある。(GREoverIPSec)
※GREのみでカプセル化されたデータはWireshark等でモニター可能。
※IPSecの場合はマルチキャストを透過できない
(ダイナミックルーティングのHelloを透過できない)が、
GREトンネリング上においてはマルチキャストを透過可能。
トンネルインターフェースは以下のトンネリングのコンポーネントの
Transport Protocolを使用して、任意のPassenger Protocolを
カプセル化する方法を提供するCiscoルータ上の論理インターフェース。
[コンポーネント]
Transport Protocol
→カプセル化プロトコルを伝送するために使用されるプロトコル(IP)
Passenger Protocol
→カプセル化されるプロトコル(IP、IPX、AppleTalk、CLNS、DECnetなど)
Carrier Protocol
→カプセル化するプロトコル(GRE, aurp, cayman, dvmrp, eon, ipip, ipv6ip, nos)
GREトンネルを経由し通信が行われる場合、GREヘッダーとともに
新しいIPヘッダーが付加される。
※この時付加される新IPヘッダのSrc/Dstアドレスはトンネルインターフェースへ
定義したTunnel Source/Destinationアドレス。
新IPヘッダとGREヘッダは対向のGREルータで解除される。
[GRE設定]
(config)# interface tunnel number
(config-if)# ip address address mask
(config-if)# tunnel source address | interface
(config-if)# tunnel destination address
(config-if)# tunnel mode gre ip
※tunnel src/dstはトンネルインターフェースのアドレスではなく、
物理インターフェースの実アドレスを指定する。
GREは普段あまり使わないこともありGNS3で実際に試してみた。
構成図は以下のとおり。
コンフィグは以下のように設定。
※全部乗せると長いので必要箇所だけ抜粋。
★R1
R1#sh run | sec interface
interface Tunnel1
ip address 1.1.1.1 255.255.255.0
tunnel source 10.1.1.1
tunnel destination 10.1.1.2
interface FastEthernet0/0
ip address 192.168.10.254 255.255.255.0
interface FastEthernet0/1
ip address 10.1.1.1 255.255.255.0
R1#sh run | in ip route
ip route 192.168.20.0 255.255.255.0 Tunnel1
★R2
R2#sh run | sec interface
interface Tunnel1
ip address 1.1.1.2 255.255.255.0
tunnel source 10.1.1.2
tunnel destination 10.1.1.1
interface FastEthernet0/0
ip address 192.168.20.254 255.255.255.0
interface FastEthernet0/1
ip address 10.1.1.2 255.255.255.0
R2#sh run | in ip route
ip route 192.168.10.0 255.255.255.0 Tunnel1
ルーティングテーブル
※Tunnel 1をネクストホップとしたルーティングが
インストールされていることを確認
PC間のPingも問題なく通ることを確認。
PC-1> ping 192.168.20.1
84 bytes from 192.168.20.1 icmp_seq=1 ttl=62 time=34.593 ms
84 bytes from 192.168.20.1 icmp_seq=2 ttl=62 time=32.085 ms
84 bytes from 192.168.20.1 icmp_seq=3 ttl=62 time=33.062 ms
84 bytes from 192.168.20.1 icmp_seq=4 ttl=62 time=35.093 ms
84 bytes from 192.168.20.1 icmp_seq=5 ttl=62 time=35.595 ms
PC-2> ping 192.168.10.1
84 bytes from 192.168.10.1 icmp_seq=1 ttl=62 time=21.055 ms
84 bytes from 192.168.10.1 icmp_seq=2 ttl=62 time=23.061 ms
84 bytes from 192.168.10.1 icmp_seq=3 ttl=62 time=24.064 ms
84 bytes from 192.168.10.1 icmp_seq=4 ttl=62 time=22.560 ms
84 bytes from 192.168.10.1 icmp_seq=5 ttl=62 time=24.064 ms