labunix's blog

labunixのラボUnix

IOU L3を使ったOSPFv3 (IPv6)検証環境を追加する。

■IOU L3を使ったOSPFv3 (IPv6)検証環境を追加する。


$ ps axo pid,pcpu,pmem,cmd | \
    awk 'BEGIN{l=0} /CPU|i86bi-linux-l/&&!/BEGIN/{cpu+=$2;mem+=$3;gsub("/.*/","",$0);print l,$0;l+=1} \
                END{print "Total "cpu,mem}'
0   PID %CPU %MEM CMD
1  2467  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 4
2  2468  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 5
3  2495  1.2  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 2
4  2516  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 6
5  2520  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 3
6  2539  1.2  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 1
7  2557  1.2  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 8
8  2560  2.2  0.5 i86bi-linux-l2-ipbasek9-15.1g.bin -e 8 -s 0 7
9 15435  1.5  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 16
10 15436  1.5  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 17
11 15437  1.5  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 18
12 15438  1.5  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 15
13 22033  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 10
14 22043  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 13
15 22063  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 9
16 22084  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 14
17 22086  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 12
18 22107  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 11
Total 24.8 24.3

$ free -m | awk '/^[A-Z]/{a[$1]=$3/$2*100}END{for (n in a){print n,a[n]"%"}}'
Swap: 0%
Mem: 40.3685%

f:id:labunix:20180805084305p:plain

$ echo "`seq 1 4`" | \
    awk '{print "[Ov3R"$1"]\nconf t\nint e1/0\n  ip address 192.168.0.5"$1" 255.255.255.0\n  no shut\n  end\nwrite mem"}'
[Ov3R1]
conf t
int e1/0
  ip address 192.168.0.51 255.255.255.0
  no shut
  end
write mem
[Ov3R2]
conf t
int e1/0
  ip address 192.168.0.52 255.255.255.0
  no shut
  end
write mem
[Ov3R3]
conf t
int e1/0
  ip address 192.168.0.53 255.255.255.0
  no shut
  end
write mem
[Ov3R4]
conf t
int e1/0
  ip address 192.168.0.54 255.255.255.0
  no shut
  end
write mem

■telnet接続の許可

conf t
enable password cisco
line vty 0 4
password cisco
transport input telnet
end
write mem

■他のサーバからの接続を待ち受け

$ for n in `seq 51 54`;do socat tcp-listen:${n}23,fork tcp-connect:192.168.0.${n}:23 & done

■socat経由でtelnet接続する

$ echo "`seq 51 54`" | \
    awk 'BEGIN{print "mate-terminal \\"} \
              {print "  --tab -e \042 ./mytel 172.31.31.92 "$0"23 \042 \\"} \
           END{print ""}' | sh

■IPv6をLoopback0に設定

$ echo "`seq 1 4`" | \
    awk '{print "[Ov3R"$1"]\nconf t\nipv6 unicast-routing"} \
         {print "int lo0\n ipv6 enable\n ipv6 address FEC0:"$1"::"$1"/128\n no shut\n ipv6 ospf network point-to-point"} \
         {print "end\nwrite mem"}'
[Ov3R1]
conf t
ipv6 unicast-routing
int lo0
 ipv6 enable
 ipv6 address FEC0:1::1/128
 no shut
 ipv6 ospf network point-to-point
end
write mem
[Ov3R2]
conf t
ipv6 unicast-routing
int lo0
 ipv6 enable
 ipv6 address FEC0:2::2/128
 no shut
 ipv6 ospf network point-to-point
end
write mem
[Ov3R3]
conf t
ipv6 unicast-routing
int lo0
 ipv6 enable
 ipv6 address FEC0:3::3/128
 no shut
 ipv6 ospf network point-to-point
end
write mem
[Ov3R4]
conf t
ipv6 unicast-routing
int lo0
 ipv6 enable
 ipv6 address FEC0:4::4/128
 no shut
 ipv6 ospf network point-to-point
end
write mem


■OSPFv3の設定

[Ov3R1]
conf t
ipv6 cef
ipv6 router ospf 1 area 0
 router-id 1.1.1.1
 log-adjacency-changes
int lo0
 ipv6 ospf 1 area 0
int e0/0
 no shut
 ipv6 enable
 ipv6 ospf 1 area 0
end
write mem

[Ov3R2]
conf t
ipv6 cef
ipv6 router ospf
 router-id 2.2.2.2
 log-adjacency-changes
 area 23 virtual-link 3.3.3.3
int e0/0
 no shut
 ipv6 enable
 ipv6 ospf 1 area 0
int s2/0
 no shut
 ipv6 enable
 ipv6 ospf 1 area 23
end
write mem

[Ov3R3]
conf t
ipv6 cef
ipv6 router ospf
 router-id 3.3.3.3
 log-adjacency-changes
 area 23 virtual-link 2.2.2.2
int s2/0
 no shut
 ipv6 enable
 ipv6 ospf 1 area 23
int e0/0
 no shut
 ipv6 enable
 ipv6 ospf 1 area 34
end
write mem

[Ov3R4]
conf t
ipv6 cef
ipv6 router ospf 1 area 34
 router-id 4.4.4.4
 log-adjacency-changes
int lo0
 ipv6 ospf 1 area 34
int e0/0
 no shut
 ipv6 enable
 ipv6 ospf 1 area 34
end
write mem

■インターフェイスの確認

Ov3R1#show ipv6 ospf interface brief 
Interface    PID   Area            Intf ID    Cost  State Nbrs F/C
Lo0          1     0               22         1     P2P   0/0
Et0/0        1     0               3          10    DR    1/1

Ov3R2#show ipv6 ospf interface brief
Interface    PID   Area            Intf ID    Cost  State Nbrs F/C
Et0/0        1     0               3          10    BDR   1/1
VL0          1     0               23         64    P2P   1/1
Se2/0        1     23              11         64    P2P   1/1

Ov3R3#show ipv6 ospf interface brief
Interface    PID   Area            Intf ID    Cost  State Nbrs F/C
VL2          1     0               25         64    P2P   1/1
Se2/0        1     23              11         64    P2P   1/1
Et0/0        1     34              3          10    DR    1/1

Ov3R4#show ipv6 ospf interface brief
Interface    PID   Area            Intf ID    Cost  State Nbrs F/C
Lo0          1     34              22         1     P2P   0/0
Et0/0        1     34              3          10    BDR   1/1

■neighborの確認

Ov3R1#show ipv6 ospf neighbor 

            OSPFv3 Router with ID (1.1.1.1) (Process ID 1)

Neighbor ID     Pri   State           Dead Time   Interface ID    Interface
2.2.2.2           1   FULL/BDR        00:00:30    3               Ethernet0/0

Ov3R2#show ipv6 ospf neighbor

            OSPFv3 Router with ID (2.2.2.2) (Process ID 1)

Neighbor ID     Pri   State           Dead Time   Interface ID    Interface
1.1.1.1           1   FULL/DR         00:00:38    3               Ethernet0/0
3.3.3.3           0   FULL/  -           -        25              OSPFv3_VL0
3.3.3.3           0   FULL/  -        00:00:33    11              Serial2/0

Ov3R3#show ipv6 ospf neighbor

            OSPFv3 Router with ID (3.3.3.3) (Process ID 1)

Neighbor ID     Pri   State           Dead Time   Interface ID    Interface
2.2.2.2           0   FULL/  -           -        23              OSPFv3_VL2
2.2.2.2           0   FULL/  -        00:00:37    11              Serial2/0
4.4.4.4           1   FULL/BDR        00:00:31    3               Ethernet0/0

Ov3R4#show ipv6 ospf neighbor

            OSPFv3 Router with ID (4.4.4.4) (Process ID 1)

Neighbor ID     Pri   State           Dead Time   Interface ID    Interface
3.3.3.3           1   FULL/DR         00:00:37    3               Ethernet0/0

■ルーティングの確認

Ov3R1#show ipv6 route ospf 
IPv6 Routing Table - default - 5 entries
Codes: C - Connected, L - Local, S - Static, U - Per-user Static route
       B - BGP, HA - Home Agent, MR - Mobile Router, R - RIP
       H - NHRP, I1 - ISIS L1, I2 - ISIS L2, IA - ISIS interarea
       IS - ISIS summary, D - EIGRP, EX - EIGRP external, NM - NEMO
       ND - ND Default, NDp - ND Prefix, DCE - Destination, NDr - Redirect
       O - OSPF Intra, OI - OSPF Inter, OE1 - OSPF ext 1, OE2 - OSPF ext 2
       ON1 - OSPF NSSA ext 1, ON2 - OSPF NSSA ext 2, la - LISP alt
       lr - LISP site-registrations, ld - LISP dyn-eid, a - Application
OI  FEC0:2::2/128 [110/10]
     via FE80::A8BB:CCFF:FE00:1000, Ethernet0/0
OI  FEC0:3::3/128 [110/74]
     via FE80::A8BB:CCFF:FE00:1000, Ethernet0/0
OI  FEC0:4::4/128 [110/84]
     via FE80::A8BB:CCFF:FE00:1000, Ethernet0/0

Ov3R2#show ipv6 route ospf | section FE|FF
O   FEC0:1::1/128 [110/10]
     via FE80::A8BB:CCFF:FE00:F00, Ethernet0/0
O   FEC0:3::3/128 [110/64]
     via FE80::A8BB:CCFF:FE00:1100, Serial2/0
OI  FEC0:4::4/128 [110/74]
     via FE80::A8BB:CCFF:FE00:1100, Serial2/0

Ov3R3#show ipv6 route ospf | section FE|FF
O   FEC0:1::1/128 [110/74]
     via FE80::A8BB:CCFF:FE00:1000, Serial2/0
O   FEC0:2::2/128 [110/64]
     via FE80::A8BB:CCFF:FE00:1000, Serial2/0
O   FEC0:4::4/128 [110/10]
     via FE80::A8BB:CCFF:FE00:1200, Ethernet0/0

Ov3R4#show ipv6 route ospf | section FE|FF
OI  FEC0:1::1/128 [110/84]
     via FE80::A8BB:CCFF:FE00:1100, Ethernet0/0
OI  FEC0:2::2/128 [110/74]
     via FE80::A8BB:CCFF:FE00:1100, Ethernet0/0
OI  FEC0:3::3/128 [110/10]
     via FE80::A8BB:CCFF:FE00:1100, Ethernet0/0

■疎通確認

Ov3R1#traceroute ipv6 FEC0:4::4
Type escape sequence to abort.
Tracing the route to FEC0:4::4

  1 FEC0:2::2 1 msec 1 msec 0 msec
  2 FEC0:3::3 8 msec 9 msec 9 msec
  3 FEC0:4::4 9 msec 10 msec 10 msec

Ov3R4#traceroute ipv6 FEC0:1::1
Type escape sequence to abort.
Tracing the route to FEC0:1::1

  1 FEC0:3::3 1 msec 0 msec 1 msec
  2 FEC0:2::2 9 msec 9 msec 8 msec
  3 FEC0:1::1 10 msec 10 msec 9 msec