Primaryが現在105でVIP:192.168.10.1が設定されていることがわかる
hsrp-nat-1#show standby all
GigabitEthernet0/0 - Group 5
State is Active
7 state changes, last state change 01:53:51
Virtual IP address is 192.168.10.1
Active virtual MAC address is 0000.0c07.ac05
Local virtual MAC address is 0000.0c07.ac05 (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 1.088 secs
Preemption enabled
Active router is local
Standby router is 192.168.10.3, priority 100 (expires in 10.032 sec)
Priority 105 (configured 105)
Track object 10 state Up decrement 100
Group name is "HSRP1" (cfgd)
hsrp-nat-1#
アクティブルータ(HSRP-NAT-1) を経由し、NAT変換(送信元:192.168.10.8-> 10.0.0.201)されて疎通できていることがわかる
root@ubuntu-0:~# ping 10.0.0.8
PING 10.0.0.8 (10.0.0.8) 56(84) bytes of data.
64 bytes from 10.0.0.8: icmp_seq=1 ttl=63 time=3.11 ms
64 bytes from 10.0.0.8: icmp_seq=2 ttl=63 time=4.13 ms
64 bytes from 10.0.0.8: icmp_seq=3 ttl=63 time=2.85 ms
root@ubuntu-2:~# tcpdump -i enp0s2
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp0s2, link-type EN10MB (Ethernet), capture size 262144 bytes
13:44:25.346572 IP 10.0.0.201 > ubuntu-2: ICMP echo request, id 13543, seq 14, length 64
13:44:25.346607 IP ubuntu-2 > 10.0.0.201: ICMP echo reply, id 13543, seq 14, length 64
13:44:25.663103 ARP, Request who-has 10.0.0.254 tell ubuntu-2, length 28
13:44:25.666529 ARP, Reply 10.0.0.254 is-at 52:54:00:0e:88:30 (oui Unknown), length 46
13:44:26.349612 IP 10.0.0.201 > ubuntu-2: ICMP echo request, id 13543, seq 15, length 64
13:44:26.349648 IP ubuntu-2 > 10.0.0.201: ICMP echo reply, id 13543, seq 15, length 64
13:44:27.350994 IP 10.0.0.201 > ubuntu-2: ICMP echo request, id 13543, seq 16, length 64
13:44:27.351031 IP ubuntu-2 > 10.0.0.201: ICMP echo reply, id 13543, seq 16, length 64
8 packets captured
8 packets received by filter
0 packets dropped by kernel
root@ubuntu-2:~#
ubuntu-2のインターフェースをdownさせてVIPを移動させる
root@ubuntu-2:~# iip link set dev enp0s2 down
root@ubuntu-2:~# ip addr show dev enp0s2
2: enp0s2: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether 52:54:00:13:83:f2 brd ff:ff:ff:ff:ff:ff
root@ubuntu-2:~#
下記の通り、trackで設定しているstateがdownしたのがわかる
hsrp-nat-1#
*Oct 2 13:45:58.250: %TRACK-6-STATE: 10 ip sla 1 reachability Up -> Down
*Oct 2 14:58:29.369: %HSRP-5-STATECHANGE: GigabitEthernet0/0 Grp 5 state Active -> Speak
*Oct 2 14:58:40.153: %HSRP-5-STATECHANGE: GigabitEthernet0/0 Grp 5 state Speak -> Standby
下記の通り、Stateは Standby になりPriorityは 5 (=105-100)、Trackのstateがdownになっているのがわかる
hsrp-nat-1# show stand all
GigabitEthernet0/0 - Group 5
State is Standby
12 state changes, last state change 00:00:27
Virtual IP address is 192.168.10.1
Active virtual MAC address is 0000.0c07.ac05
Local virtual MAC address is 0000.0c07.ac05 (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 2.304 secs
Preemption enabled
Active router is 192.168.10.3, priority 100 (expires in 8.176 sec)
Standby router is local
Priority 5 (configured 105)
Track object 10 state Down decrement 100
Group name is "HSRP1" (cfgd)
hsrp-nat-1(config-if)#
下記の通り、StateがActiveになっている(=VIPが移っている)ことがわかる
hsrp-nat-2#show stand all
GigabitEthernet0/0 - Group 5
State is Active
5 state changes, last state change 00:01:00
Virtual IP address is 192.168.10.1
Active virtual MAC address is 0000.0c07.ac05
Local virtual MAC address is 0000.0c07.ac05 (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 2.176 secs
Preemption disabled
Active router is local
Standby router is unknown
Priority 100 (default 100)
Group name is "HSRP1" (cfgd)
hsrp-nat-2#
pingが引き続き疎通が通る
root@ubuntu-0:~# ping 10.0.0.8
PING 10.0.0.8 (10.0.0.8) 56(84) bytes of data.
64 bytes from 10.0.0.8: icmp_seq=1 ttl=63 time=2.94 ms
64 bytes from 10.0.0.8: icmp_seq=2 ttl=63 time=3.63 ms
64 bytes from 10.0.0.8: icmp_seq=3 ttl=63 time=3.89 ms
64 bytes from 10.0.0.8: icmp_seq=4 ttl=63 time=3.65 ms
--- 10.0.0.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms^C
rtt min/avg/max/mdev = 2.943/3.529/3.893/0.361 ms
root@ubuntu-0:~#
ubuntu-3のtcpdumpを確認するとNAT変換され、届いていることがわかる
root@ubuntu-3:~# tcpdump -i enp0s2
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp0s2, link-type EN10MB (Ethernet), capture size 262144 bytes
17:43:27.194055 Loopback, skipCount 0, Reply, receipt number 0, data (40 octets)
17:43:27.295920 IP 10.0.0.201 > ubuntu-3: ICMP echo request, id 13566, seq 1, length 64
17:43:27.295976 IP ubuntu-3 > 10.0.0.201: ICMP echo reply, id 13566, seq 1, length 64
17:43:28.296268 IP 10.0.0.201 > ubuntu-3: ICMP echo request, id 13566, seq 2, length 64
17:43:28.296304 IP ubuntu-3 > 10.0.0.201: ICMP echo reply, id 13566, seq 2, length 64
17:43:29.298791 IP 10.0.0.201 > ubuntu-3: ICMP echo request, id 13566, seq 3, length 64
17:43:29.298828 IP ubuntu-3 > 10.0.0.201: ICMP echo reply, id 13566, seq 3, length 64
^C
7 packets captured
7 packets received by filter
0 packets dropped by kernel
root@ubuntu-3:~#
ubuntu-2のインターフェースをupさせ、復旧させる
インターフェースをupさせる
root@ubuntu-2:~# ip link set dev enp0s2 up
hsrp-nat-1#
*Oct 2 14:49:33.473: %TRACK-6-STATE: 10 ip sla 1 reachability Down -> Up
*Oct 2 14:49:35.441: %HSRP-5-STATECHANGE: GigabitEthernet0/0 Grp 5 state Standby -> Active
hsrp-nat-1#show standby all
GigabitEthernet0/0 - Group 5
State is Active
13 state changes, last state change 00:06:47
Virtual IP address is 192.168.10.1
Active virtual MAC address is 0000.0c07.ac05
Local virtual MAC address is 0000.0c07.ac05 (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 1.392 secs
Preemption enabled
Active router is local
Standby router is 192.168.10.3, priority 100 (expires in 9.840 sec)
Priority 105 (configured 105)
Track object 10 state Up decrement 100
Group name is "HSRP1" (cfgd)
hsrp-nat-1#
root@ubuntu-0:~# ping 10.0.0.8
PING 10.0.0.8 (10.0.0.8) 56(84) bytes of data.
64 bytes from 10.0.0.8: icmp_seq=1 ttl=63 time=4.55 ms
64 bytes from 10.0.0.8: icmp_seq=2 ttl=63 time=2.59 ms
64 bytes from 10.0.0.8: icmp_seq=3 ttl=63 time=4.53 ms
--- 10.0.0.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 2.591/3.896/4.559/0.924 ms
root@ubuntu-0:~#