I am trying to automate router configuration with Python through Paramiko, however whenever I test a command through the exec_command function, it doesn't seem to do anything. If I enter the same commands through Putty it works though. I am fairly new to Python.
This is for configuration of a Ubiquiti Edge Router X. I've looked at answers here and some tutorials online and I think I am doing everything correctly
import paramiko
ip = '10.0.1.1'
user = 'ubnt'
passw = 'ubnt'
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname = ip, port=22, username = user, password = passw)
stdin, stdout, stderr = ssh.exec_command("configure")
stdin, stdout, stderr = ssh.exec_command("set service dhcp-server shared-network-name LAN subnet 10.0.1.0/24 dns-server 4.2.2.2")
stdin, stdout, stderr = ssh.exec_command("commit")
stdin, stdout, stderr = ssh.exec_command("save")
output = stdout.readlines()
print(output)
The expected output should be that the dns server settings on my router should be changed to 4.2.2.2 but it doesn't seem to do anything. Any help would be appreciated. Thanks.