In this lesson, we will cover:

  • The different Netmiko methods used for configuring a device.
  • How to send a list of configuration commands to a device.
  • How to read and send configuration commands from a file.
  • How to save/commit the configuration on a device with Netmiko.

The scripts and code for this lesson can be found within the Netmiko repo under the directory: examples/002_device_interaction.

Config Set

Netmiko provides the method send_config_set(). This method takes a list() of commands, and then applies them to the device. Like so:

commands = [
    "interface Ethernet8",
    "switchport mode trunk",
    "switchport trunk allowed vlan 100,200-400",
]
ios_connection.send_config_set(commands)

We can then log in to the device and confirm the changes have been made.

Ready to Master Network Automation? Start Your Journey Today!
Our membership provides:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Live monthly tech sessions
  • Access to tech session library

Join Now ➜
Close You've successfully subscribed to Packet Coders.
Close Success! Your account is fully activated, you now have access to all content.
Close Welcome back! You've successfully signed in.
Close Nearly there! To activate your account, please click the link in the email we just sent you.