LoginSignup
3
8

More than 5 years have passed since last update.

CatalystスイッチのインターフェースへのSecondary IP設定

Last updated at Posted at 2017-05-24

はじめに

Secondary IPの設定をこれまで使ったことが無かったため、勉強します。なお今回は、臨場感溢れるLive形式でお送りします。

コマンドリファレンス

ip address ip-address mask [secondary]
インターフェースにIPアドレスを設定する。
secondaryオプションを付けることで1つ以上の追加のIPを設定することができる。
http://www.cisco.com/c/en/us/td/docs/ios-xml/ios/ipaddr/command/ipaddr-cr-book/ipaddr-c1.html#wp1930336422

いろいろやってみる

L3スイッチなのでまずはSVIで。PCのIPは常にxxx.xxx.xxx.100にして、Port1に接続してある。

Vlan1に192.168.1.1を設定する。

Cisco
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#int vlan 1
Switch(config-if)#ip add 192.168.1.1 255.255.255.0
Switch(config-if)#no shut
Switch(config-if)#end
Switch#
Switch#ping 192.168.1.100

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.100, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Switch#

Vlan1のSecondaryに192.168.2.1を設定する。

Cisco
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#int vlan 1
Switch(config-if)#ip add 192.168.2.1 255.255.255.0 sec
Switch(config-if)#end
Switch#
Switch#sh run int vlan 1
Building configuration...

Current configuration : 109 bytes
!
interface Vlan1
 ip address 192.168.2.1 255.255.255.0 secondary
 ip address 192.168.1.1 255.255.255.0
end

Switch#

設定した。PCのIPを192.168.2.100に変えてみる。

Cisco
Switch#ping 192.168.2.100

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.100, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
Switch#

Ping飛ばない\(^o^)/。arpが原因か?

Cisco
Switch#sh ip arp
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  192.168.1.100           2   3c97.0e13.85a6  ARPA   Vlan1
Internet  192.168.2.100           0   3c97.0e13.85a6  ARPA   Vlan1
Internet  192.168.1.1             -   0015.6256.6340  ARPA   Vlan1
Internet  192.168.2.1             -   0015.6256.6340  ARPA   Vlan1
Switch#

arp見えているんですけど……ということはルーティングか。

Cisco
Switch#sh ip route
Default gateway is not set

Host               Gateway           Last Use    Total Uses  Interface
ICMP redirect cache is empty
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#ip routing
Switch(config)#end
Switch#
00:16:05: %SYS-5-CONFIG_I: Configured from console by console
Switch#
Switch#ping 192.168.2.100

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.100, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
Switch#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

C    192.168.1.0/24 is directly connected, Vlan1
C    192.168.2.0/24 is directly connected, Vlan1
Switch#

\(^o^)/ルーティング見えていても飛ばない! 念のため端末から打ってみる?

Cisco
C:\Users\jinnai73>ping 192.168.2.1

192.168.2.1 に ping を送信しています 32 バイトのデータ:
192.168.2.1 からの応答: バイト数 =32 時間 =1ms TTL=255
192.168.2.1 からの応答: バイト数 =32 時間 =1ms TTL=255
192.168.2.1 からの応答: バイト数 =32 時間 <1ms TTL=255
192.168.2.1 からの応答: バイト数 =32 時間 <1ms TTL=255

192.168.2.1 の ping 統計:
    パケット数: 送信 = 4、受信 = 4、損失 = 0 (0% の損失)、
ラウンド トリップの概算時間 (ミリ秒):
    最小 = 0ms、最大 = 1ms、平均 = 0ms

C:\Users\jinnai73>

飛ぶんかい……ということはパケットの送信元IPがおかしいな。端末でキャプチャしながら、スイッチから再度192.168.2.100へpingしよう。
image.png
なるほど。Pingと打つときはPrimaryのIPアドレスから投げるようだ。明示すれば飛ぶかな。

Cisco
Switch#ping 192.168.2.100 source 192.168.2.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.100, timeout is 2 seconds:
Packet sent with a source address of 192.168.2.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/8 ms
Switch#

とんだ。ルーティングは関係なかったね。

Cisco
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#no ip routing
Switch(config)#end
Switch#
Switch#ping 192.168.2.100 source 192.168.2.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.100, timeout is 2 seconds:
Packet sent with a source address of 192.168.2.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/202/1007 ms
Switch#

Packets generated by the Cisco IOS software always use the primary IP address.

ちゃんと書いてあった……。

続いて、PrimaryのIPを消してみる。

Cisco
Switch#sh run int vlan 1
Building configuration...

Current configuration : 128 bytes
!
interface Vlan1
 ip address 192.168.2.1 255.255.255.0 secondary
 ip address 192.168.1.1 255.255.255.0
 no ip route-cache
end

Switch#
Switch#
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#int vlan 1
Switch(config-if)#no ip add 192.168.1.1 255.255.255.0
Must delete secondary before deleting primary
Switch(config-if)#

怒られた。secondaryが設定されているとprimaryは消せない。じゃあ、何も設定されていないインターフェースにいきなりsecondaryは書けるのか?

Cisco
Switch(config-if)#no ip add
Switch(config-if)#do sh run int vlan 1
Building configuration...

Current configuration : 57 bytes
!
interface Vlan1
 no ip address
 no ip route-cache
end

Switch(config-if)#ip add 192.168.2.1 255.255.255.0 sec
Switch(config-if)#do sh run int vlan 1
Building configuration...

Current configuration : 57 bytes
!
interface Vlan1
 no ip address
 no ip route-cache
end

Switch(config-if)#

コマンドが何故か入るが、設定上は見えない。実に不安である。この状態でprimary IPを設定してみると。。。

Cisco
Switch(config-if)#ip add 192.168.1.1 255.255.255.0
Switch(config-if)#do sh run int vlan 1
Building configuration...

Current configuration : 128 bytes
!
interface Vlan1
 ip address 192.168.2.1 255.255.255.0 secondary
 ip address 192.168.1.1 255.255.255.0
 no ip route-cache
end

Switch(config-if)#

Secondary、いるんかい!

まとめ

・Primary、Secondaryのアドレスを設定することで、ノードからはどちらのアドレスへも通信可能。

・スイッチから通信をする時はPrimaryのIPでパケットが送信される。

・SecondaryのIPを設定した状態でPrimaryのIPを消すことはできない。

・IPの設定されていないインターフェースにSecondaryのIPを設定しようとするとコマンドは成功する。ただし、Primary IPを設定するまで反映されない

・Live形式は読みづらいのでもうやらない。

3
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
8