由於IP-×××專線之間的BGP要經過服務商,使用起來不方便,遂想經過GRE隧道封裝。安全
我這邊使用的是juniper srx240,對端用思科路由器。app
GRE協議原本是思科搞出來的,juniper的junos也不知道行不行,搜索了一下,有簡短的例子,可是沒有虛擬路由器的用法,研究了一下。ide
首先創建一個gre的虛擬接口,這個接口默認是不出現,GUI也搞不出來,用命令行,或者編輯配置。oop
interfaces {測試
gr-0/0/0 {
unit 0 {
tunnel {
source 192.168.8.1;
destination 192.168.8.2;
routing-instance {
destination VRRIP;
}
}
family inet;
}
unit 1 {
tunnel {
source 192.168.2.2;
destination 192.168.2.1;
routing-instance {
destination VRBGP;
}
}
family inet;
}
}加密
}命令行
說明一下 , router
routing-instance {
destination VRRIP;
}server
這個最開始是沒法加的,由於虛擬路由VRRIP和VRBGP尚未創建,而後創建虛擬路由器,接口
routing-instances {
VRBGP {
instance-type virtual-router;
interface gr-0/0/0.1; //把作好的接口加入
interface ge-0/0/11.0; //這個物理接口接思科路由器
interface lo0.0; //爲測試,創建環回接口
routing-options {
static {
route 2.2.2.2/32 next-hop gr-0/0/0.1;//作路由,這個路由和主的互不影響
}
}
}
}
虛擬路由器作好以後,把interface gr-0/0/0.1歸屬到routing-instance VRBGP
routing-instance {
destination VRRIP;
}
配置物理接口
ge-0/0/11 {
unit 0 {
family inet {
address 192.168.2.2/24;
}
}
}
爲了分離和主路由的流量,作VRBGP的安全ZONE BGP
security {
zones {
security-zone BGP {
host-inbound-traffic {
system-services {
all;
}
protocols {
all;
}
}
interfaces {
lo0.0;
gr-0/0/0.1; //把接口都劃入該zone,
ge-0/0/11.0;//注意的是接口劃入zone和劃入虛擬路由器同步進行,否則報錯
}
}
}
許可安全策略
security {
policies {
from-zone BGP to-zone BGP {
policy bgp {
match {
source-address any-ipv4;
destination-address any-ipv4;
application any;
}
then {
permit;
}
}
}
}
}
下面是思科路由器的配置,
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface Tunnel0
ip address 3.3.3.3 255.255.255.0
tunnel source FastEthernet0/0
tunnel destination 192.168.2.2
!
interface FastEthernet0/0
ip address 192.168.2.1 255.255.255.0
duplex auto
speed auto
!
no ip http server
!
ip route 1.1.1.1 255.255.255.255 Tunnel0
有一點要說明一下,就是Tunnel0配置了IP地址,由於srx設備的gre隧道是沒有IP的,原來就打算不配IP地址,沒成想,不配IP地址就不通,不管配什麼都IP能夠,只要有IP地址就行,固然在實用的時候,這個IP地址不能衝突。
另外就是要注意MTU的問題,調整好大小。
通常以太網ping的載荷在1472
gre以後的ping載荷爲1448,這是在中繼路程上都是最小以MTU1500爲轉送值,由於gre不加密,有效載荷就是這麼多。
IP頭20,GRE頭4,內嵌IP頭20,1500-20-4-20=1456,icmp頭8,1456-8=1448