Pregunta

I'm a network administrator and want to automate process of creation of ipsec tunnels on Cisco routers. Through Exscript module I establish ssh connection to router and want to execute some commands there.

from Exscript.util.interact import read_login
from Exscript.protocols import SSH2
from Exscript import Host, Account

def create_ipsec_tunnel(event):
account = Account('login','password')
conn = SSH2()                       
conn.connect('192.168.1.1')     
conn.login(account)  
conn.execute('conf t')
conn.execute('crypto isakmp policy 1')
..............
conn.send('quit\r')
conn.close()

For creating ipsec tunnel it's neccessary to create crypto policy, access-list, transform-set and so on. I'd like to add check if such parameters already exist. For example we want to create an access-list with name of newipsectunnel. Before creation my application should check if access-list with such name is already exist.

Could you give me advice how to resolve this issue. Thanks in advance.

¿Fue útil?

Solución

You can enter a command like "show ip access-lists ACLNAME" and parse the output (empty line if none found).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top