Monday, August 30, 2021

strange error with netmiko (send_config_set)

i am trying to enable ZBF in gns 3, it 's worked many time but when i created new router wiht this setting :username ahmad password ammar

!

username ahmad priv 15

!

ip domain-name aspu.com

!

enable secr ammar

!

int f0/0

!

ip add 192.168.122.140 255.255.255.0

!

no sh

!

int serial 0/0

!

ip add 10.0.0.1 255.0.0.0

!

clock rate 64000

!

no sh

!

exit

!

ip route 192.168.150.0 255.255.255.0 10.0.0.2

ip route 192.168.130.0 255.255.255.0 10.0.0.2

ip route 11.0.0.0 255.0.0.0 10.0.0.2

!

line vty 0 4

!

login local

!

tran input ssh

!

exit

!

crypto key generate rsa

!

1024

!

the code is :

from netmiko import ConnectHandler

router_1= {

'device_type': 'cisco_ios',

'ip': '192.168.122.140',

'username': 'ahmad',

'password': 'ammar'

}

config_commands = ['zone security IN-ZONE', 'exit'

,'zone security OUT-ZONE', 'exit'

,'access-list 101 permit ip 192.168.122.0 0.0.0.255 any', 'class-map type inspect match-all IN-NET-CLASS-MAP','match access-group 101'

,'exit','policy-map type inspect IN-2-OUT-PMAP','class type inspect IN-NET-CLASS-MAP'

,'inspect ','exit','exit','zone-pair security IN-2-OUT-ZPAIR source IN-ZONE destination OUT-ZONE','service-policy type inspect IN-2-OUT-PMAP','exit'

,'interface fastEthernet 0/0','zone-member security IN-ZONE','exit'

,'inte serial 0/0','zone-member security OUT-ZONE','exit'

]

my_cmds = "important.txt"

net_connect = ConnectHandler(**router_1)

output = net_connect.send_command('show ip int brief')

print (output)

output2 = net_connect.send_config_set(config_commands)

the error :Traceback (most recent call last):

File "netmiko1.py", line 22, in <module>

output2 = net_connect.send_config_set(config_commands)

the error :

File "/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py", line 1921, in send_config_set

new_output = self.read_until_pattern(pattern=pattern)

File "/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py", line 655, in read_until_pattern

return self._read_channel_expect(*args, **kwargs)

File "/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py", line 575, in _read_channel_expect

raise EOFError("Channel stream closed by remote device.")

EOFError: Channel stream closed by remote device.



No comments:

Post a Comment