ネットワーク備忘録

アラフォーエンジニアのネットワーク系の備忘録。twitter:@deigo25374582

uRPF(Unicast Reverse Path Forwarding)での簡易フィルタ

uRPFは簡単に言えばルータが自身のルーティングテーブルにない「送信元アドレス」からのパケットをフィルタする機能。
 ちゃんとしたセキュリティではないものの、NWレイヤで比較的簡単にフィルタが可能。

下記の構成で確認
(IPv6でも確認したかったけど、手持ちのIOSでは不可だったので、意味なし)

f:id:klock_3rd:20170218135803p:plain

 

R1、R2、R3で、ipv4,ipv6ともにOSPFで経路をやりとりしている。
ただし、R3のloop0だけはOSPFは無効。

この状態のR2のshow ip route結果が↓

R2#show ip route ospf
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/2] via 10.1.1.1, 00:15:55, FastEthernet0/0
R2#

 R2#show ipv route ospf

O 2001::1/128 [110/1]
via FE80::C801:4CFF:FEAC:0, FastEthernet0/0

 

当然・・・この状態で、R3:Loop0からR1:Loop0にPingを打っても応答はなし。
ただし、R1:Loop0にはR3:Loop0からのパケットは届いてしまう。

R3:loop0からR1:Loop0へPing200発実行後でのR1:fa0/0のsho int 結果

 

R1#show int fa0/0
FastEthernet0/0 is up, line protocol is up
Hardware is DEC21140, address is ca01.4cac.0000 (bia ca01.4cac.0000)
Internet address is 10.1.1.1/24
MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Half-duplex, 100Mb/s, 100BaseTX/FX
ARP type: ARPA, ARP Timeout 04:00:00
Last input 00:00:01, output 00:00:03, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
1092 packets input, 125890 bytes
Received 768 broadcasts, 0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 watchdog
0 input packets with dribble condition detected
1118 packets output, 112548 bytes, 0 underruns
0 output errors, 0 collisions, 1 interface resets
0 babbles, 0 late collision, 0 deferred
0 lost carrier, 0 no carrier
0 output buffer failures, 0 output buffers swapped out
R1#

input Packetsが増大しているので、R1のルータにパケットは到達していると想定。

 

ここで、R2のe1/0にuRPFを実装

interface Ethernet1/0
ip address 10.1.2.2 255.255.255.0
ip verify unicast source reachable-via rx
ip ospf 1 area 0
ipv6 address 2001:DB8:2::2/64
ipv6 ospf 1 area 0
end

e1/0の状態確認

 R2#sho ip int et1/0
Ethernet1/0 is up, line protocol is up
Internet address is 10.1.2.2/24
Broadcast address is 255.255.255.255
<略>
IP verify source reachable-via RX
0 verification drops
0 suppressed verification drops
R2#

 

もっかい、R3:loop0からR1:Loop0へPing200発実行後に確認

R2#sho ip int et1/0
Ethernet1/0 is up, line protocol is up
Internet address is 10.1.2.2/24
Broadcast address is 255.255.255.255
<略>
IP verify source reachable-via RX
199 verification drops
0 suppressed verification drops
R2#

R1のfa0/0のinput Packetsは増大していない(省略)ので、R2にてuRPFが有効になったことで、フィルタされたとわかる。

 

今度は、デフォルトルート側からのパケットの場合

 

R1がR2に対しデフォルトルートを通知、R3:loop0はOSPF有効化の状態

R2#show ip route ospf
10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
O 10.1.3.1/32 [110/11] via 10.1.2.3, 00:03:48, Ethernet1/0
O*E2 0.0.0.0/0 [110/1] via 10.1.1.1, 00:03:48, FastEthernet0/0

この場合、R2はR3:loop0も知っているので、e1/0にかけたuRPFは有効にしても通信は可能。

R3#ping 1.1.1.1 source loop0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 10.1.3.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/35/56 ms
R3#

R2:fa0/0にuRPFをかけて再度Ping

interface FastEthernet0/0
ip address 10.1.1.2 255.255.255.0
ip verify unicast source reachable-via rx
ip ospf 1 area 0
duplex half
ipv6 address 2001:DB8::2/64
ipv6 ospf 1 area 0
end

Pingはエラー

R3#ping 1.1.1.1 source loop0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 10.1.3.1
.....
Success rate is 0 percent (0/5)

これは、R1:loop0がデフォルトルートの経路に収まってもuRPFのチェックで引っかかったため。 R2:fa0/0を修正

interface FastEthernet0/0
ip address 10.1.1.2 255.255.255.0
ip verify unicast source reachable-via rx allow-default
ip ospf 1 area 0
duplex half
ipv6 address 2001:DB8::2/64
ipv6 ospf 1 area 0
end

PingはOK

R3#ping 1.1.1.1 source loop0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 10.1.3.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/25/32 ms
R3#

 

uRPFは簡単だけど、デフォルトルートがある場合にはちょい注意が必要

検証おわり