IOSでのIPアドレスの設定
- カテゴリ:
- Cisco
3つのインターフェイスにIPアドレスを設定します。ここではあえてマスク値を/24以外で設定しました。
interface Serial1/0 ip address 192.168.3.1 255.255.255.128 ! interface Serial1/1 ip address 192.168.33.1 255.255.255.192 ! interface Serial1/2 ip address 192.168.133.1 255.255.255.224 |
IPアドレスを設定した後に設定を確認しますが、show ip interface briefではマスク値は表示されません。
R3#show ip interface brief Interface IP-Address OK? Method Status Protocol Serial1/0 192.168.3.1 YES manual up down Serial1/1 192.168.33.1 YES manual up down Serial1/2 192.168.133.1 YES manual up down |
IPアドレスを設定したにもかかわらず通信が出来ない場合、マスク値が意図したものになっていない場合がままあります。マスク値の確認はshow ip interfaceを利用します。
R3#show ip interface Serial1/0 is up, line protocol is down Internet address is 192.168.3.1/25 Broadcast address is 255.255.255.255 〜略〜 |
ただこのまま実行すると上記の様に、不要な情報まで大量に表示されます。ここでincludeと|を利用することで、必要な行のみを抜き出すことが可能です。
R3#show ip interface | include is up|Internet address Serial1/0 is up, line protocol is down Internet address is 192.168.3.1/25 Serial1/1 is up, line protocol is down Internet address is 192.168.33.1/26 Serial1/2 is up, line protocol is down Internet address is 192.168.133.1/27 |
またBGPの学習時など、たくさんのIPアドレスを設定する必要がある場合はsecondary addressが便利です。一つのインターフェイスに複数のIPアドレスを設定することが可能です。
R2(config)#interface loopback 200 R2(config-if)#ip address 192.168.0.2 255.255.255.0 R2(config-if)#ip address 192.168.1.2 255.255.255.0 ? secondary Make this IP address a secondary address R2(config-if)#ip address 192.168.1.2 255.255.255.0 secondary R2(config-if)#ip address 192.168.2.2 255.255.255.0 secondary R2(config-if)#ip address 192.168.3.2 255.255.255.0 secondary R2#show running-config interface loopback 200 Building configuration... Current configuration : 211 bytes ! interface Loopback200 ip address 192.168.1.2 255.255.255.0 secondary ip address 192.168.2.2 255.255.255.0 secondary ip address 192.168.3.2 255.255.255.0 secondary ip address 192.168.0.2 255.255.255.0 |
設定の確認にはshow ip interfaceを利用しますが、includeを使うことで見やすい形式にしています。
R2#show ip interface loopback 200 | include Internet|Secondary Internet address is 192.168.0.2/24 Secondary address 192.168.1.2/24 Secondary address 192.168.2.2/24 Secondary address 192.168.3.2/24 |
そのままBGPで利用出来ることが分かります。
R2(config)#router bgp 200 R2(config-router)#network 192.168.0.0 mask 255.255.255.0 R2(config-router)#network 192.168.1.0 mask 255.255.255.0 R2(config-router)#network 192.168.2.0 mask 255.255.255.0 R2(config-router)#network 192.168.3.0 mask 255.255.255.0 R2#show ip bgp BGP table version is 5, local router ID is 17.17.2.2 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 192.168.0.0 0.0.0.0 0 32768 i *> 192.168.1.0 0.0.0.0 0 32768 i *> 192.168.2.0 0.0.0.0 0 32768 i *> 192.168.3.0 0.0.0.0 0 32768 i |
コメント