So let's save our script.
And what I'll do is use Python three to run this Python script before I run the script.
Let's run a debug on the router.
So debug telnet that will allow us to see if any connections are made to the router.
After the moment, I'm connected to the console of the writer.
So run the script.
We prompted for our username.
We prompted for our password.
And notice we can see that the script telnet to the router and we can see that a loopback interface
came up.
So show IP interface brief.
The loopback has been configured on the router.
Our script also shows us what it saw, so when it telnet it to the router it got to the output typed
enable was prompted for the enable password typed that logically into the router typed quantity created
the loopback typed end typed exit and the session has now ended.
So again, nano python 3.1 that simple script.
Talent added to the rotter and created a loopback on the router.
It's as simple as that to configure network devices such as Cisco routers using Python.
What I could do as an example is expand the script.
So let's create another loopback.
Loopback one.
And configure an IP address on that loopback.
And I'll save the script.
Clear the screen.
On the router show IP interface brief notice.
We only have a loopback zero under the router.
I'll run the script again into my username and to my password.
Script has telnet to the router and you can see that another loopback interface has come up.
You can also see here that David configured the router via V line is zero.
Show line shows us that the connection was disconnected.
Remember we typed exit here to exit the telnet session, but show IP interface brief shows us that that
loopback now exists on the router.
Show IP protocols shows us that no routing protocols are enabled on the router at this point, but we
could use our Python script to enable OSPF or other writing protocols on the router.
So as an example, we could simply edit our script.
Copy some lines, paste them into the script.
And enable a routing protocol such as OSPF.
And send network commands directly to the router.
So something like a network 0000245245245245.
Area zero.
Save the script.
So again, no routing protocols are currently enabled on the router.
But if I run my script.
And use the command again.
Show IP protocols.
Notice OSPF has now been enabled on the router.
Show IP OSPF interface brief shows us that OSPF is running on those three interfaces.
So there you go.
A basic script in Python can be used to automate Cisco network devices.
Now, please don't lose sight of the fact that this is the beginning.
This is a very basic script.
It's doing basic things.
We can use loops and other Python logic to make our scripts far more versatile and far more powerful.
This is a simple start, but hopefully shows you what's possible with Python.
Again.
If I remove OSPF from the router and remove the loopback interfaces on the router, I can simply rerun
the script to add the loopback interfaces back.
And to enable OSPF on the router.
So again, run the script.
It applies the configuration back to the router.
Show IP protocols.
Need to put my password in there.
I made a mistake.
So David, Cisco.
There you go.
That's been done.
So show IP protocols.
OSPF is now running.
Show IP interface.
Brief loopback.
So back again.
This is a paradigm or way of thinking.
Change to normal network configurations.
You can store your configurations on a network automation server or computer and then make sure that
your devices have a consistent and authorized configuration applied to them.
So if someone changes the configuration of a router or makes a mistake, you can simply use a configuration
stored on a network automation server to apply the configurations back to the devices in your network.
Now again, this is very simple, but is a way to get started.
We'll iterate and improve on this code as we go through the course.