問題 ccnp-300-435-topic-1-question-106・第3版

問題

Cisco IOS XEルーターのインターフェースのIPアドレスを含む出力を取得するコードはどれか。

  1. A 
    from netmiko import ConnectHandler
    
    router = {
        'device_type': 'cisco_ios',
        'host': '10.0.10.1',
        'username': '<USERNAME>',
        'password': '<PASSWORD>'
    }
    
    net_connect = ConnectHandler(**router)
    output = net_connect.send_command('show ip int brief')
    print(output)
    
  2. B 
    from netmiko import ConnectHandler
    
    router = {
        'device_type': 'cisco_ios',
        'host': '10.0.10.1',
        'username': '<USERNAME>',
        'password': '<PASSWORD>'
    }
    
    net_connect = ConnectHandler(**router)
    output = net_connect.command('show ip int brief')
    print(output)
    
  3. C 
    from netmiko import ConnectHandler
    
    router = {
        'device_type': 'ios_xe',
        'host': '10.0.10.1',
        'username': '<USERNAME>',
        'password': '<PASSWORD>'
    }
    
    net_connect = ConnectHandler(**router)
    output = net_connect.show_command('show ip int brief')
    print(output)
    
  4. D 
    from netmiko import ConnectHandler
    
    router = {
        'device_type': 'cisco_ios_xe',
        'host': '10.0.10.1',
        'username': '<USERNAME>',
        'password': '<PASSWORD>'
    }
    
    net_connect = ConnectHandler(**router)
    output = net_connect.command('show ip int brief')
    print(output)
    

正解:A

理由

NetmikoのConnectHandlerへ機器情報を渡し、send_commandで表示コマンドを実行する。show ip int briefはインターフェースとIPアドレスを含むCLI出力を返す。

選択肢ごとの説明

A.
from netmiko import ConnectHandler

router = {
    'device_type': 'cisco_ios',
    'host': '10.0.10.1',
    'username': '<USERNAME>',
    'password': '<PASSWORD>'
}

net_connect = ConnectHandler(**router)
output = net_connect.send_command('show ip int brief')
print(output)

cisco_iosでIOS XEへ接続し、send_commandでshow ip int briefの表示を取得する。表示にはインターフェースのIPアドレスが含まれる。

B.
from netmiko import ConnectHandler

router = {
    'device_type': 'cisco_ios',
    'host': '10.0.10.1',
    'username': '<USERNAME>',
    'password': '<PASSWORD>'
}

net_connect = ConnectHandler(**router)
output = net_connect.command('show ip int brief')
print(output)

Netmikoで表示用CLIを送るメソッドはsend_commandであり、commandではない。

C.
from netmiko import ConnectHandler

router = {
    'device_type': 'ios_xe',
    'host': '10.0.10.1',
    'username': '<USERNAME>',
    'password': '<PASSWORD>'
}

net_connect = ConnectHandler(**router)
output = net_connect.show_command('show ip int brief')
print(output)

ios_xeはこのNetmikoドライバーの指定ではなく、show_commandもsend_commandとは異なる。

D.
from netmiko import ConnectHandler

router = {
    'device_type': 'cisco_ios_xe',
    'host': '10.0.10.1',
    'username': '<USERNAME>',
    'password': '<PASSWORD>'
}

net_connect = ConnectHandler(**router)
output = net_connect.command('show ip int brief')
print(output)

cisco_ios_xeは対応するドライバー指定ではなく、commandもこのCLI取得のメソッドではない。

お問い合わせ

演習する →