Free tech learning for everyone, from basics to pro

Network AutomationProgramming and Application SecurityIntermediate

NAPALM: vendor-neutral getters, config merge, replace and compare

In short: NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) offers the same Python methods across several platforms. Getters return structured data such as facts and interfaces. Configuration changes are loaded as a candidate, compared, then committed or discarded, with rollback available.

What NAPALM is for

Every vendor has its own commands for the same question, such as "what are this device’s interfaces?". NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) hides those differences behind one Python API. You pick a driver for the platform, and the same method names work everywhere. Under the hood each driver uses the best transport it can: SSH for IOS, eAPI for Arista EOS, NETCONF for Junos.

NAPALM driversNAPALM APIsame Python callsIOS / IOS-XEdriver: iosNX-OSdriver: nxosEOSdriver: eosJunosdriver: junosIOS-XRdriver: iosxrCommunityextra drivers
Figure 1. One set of NAPALM methods works across several vendor platforms through drivers.

Getters: structured data without parsing

Getters are read-only methods that return dictionaries in a documented, vendor-neutral format. Examples include get_facts(), get_interfaces(), get_interfaces_ip(), get_arp_table(), get_lldp_neighbors() and get_bgp_neighbors(). Not every driver supports every getter, so check the support matrix in the NAPALM documentation.

import os
from napalm import get_network_driver

driver = get_network_driver("ios")
with driver(hostname="192.168.10.1",
            username=os.environ["NET_USER"],
            password=os.environ["NET_PASS"]) as device:
    facts = device.get_facts()
    print(facts["hostname"], facts["os_version"], facts["serial_number"])

    for name, intf in device.get_interfaces().items():
        if intf["is_enabled"] and not intf["is_up"]:
            print("Enabled but down:", name)

Because the output shape is the same for every vendor, one report script can audit a mixed network.

Merge, replace and compare

Candidate config workflowLoadmerge orreplaceComparecompare_configReviewhuman or testCommitor discardRollbackif needed
Figure 2. NAPALM stages a candidate configuration, shows the difference, then commits or discards it.

NAPALM changes configuration through a candidate. You load changes, inspect the difference, then commit or throw them away.

  • Merge (load_merge_candidate): adds your lines to the running configuration, like typing them in. Good for small, additive changes.
  • Replace (load_replace_candidate): makes the device match your file exactly, removing anything not in it. Powerful for enforcing a full intended configuration, and dangerous if the file is incomplete.
import os
from napalm import get_network_driver

driver = get_network_driver("eos")
with driver("192.168.10.2", os.environ["NET_USER"], os.environ["NET_PASS"]) as device:
    device.load_merge_candidate(filename="ntp_snippet.cfg")
    diff = device.compare_config()
    if not diff:
        print("Nothing to change")
        device.discard_config()
    else:
        print(diff)
        if input("Commit? [y/N] ").lower() == "y":
            device.commit_config()
        else:
            device.discard_config()

Tip: compare_config() with no commit is a safe, read-only way to detect drift: load the intended configuration as a replace candidate, print the difference, then discard.

Platform notes and good practice

PlatformHow candidates work
Junos, IOS-XRNative candidate configuration and commit
Arista EOSConfiguration sessions
Cisco IOSEmulated with files and the archive feature; needs SCP and archive configured
NX-OSEmulated using checkpoint files
  • Test replace operations in a lab first; a missing management line in your file can cut off your own access.
  • Keep intended configurations in Git so every change has history and review.
  • Use rollback() after a commit if verification fails, and know how it behaves on your platform.
  • Combine NAPALM with Nornir (the nornir_napalm plugin) or Ansible to run across many devices.

Practice

What is the key difference between merge and replace?
Merge adds your lines to the existing configuration. Replace makes the whole configuration match your file, removing anything not in it.
How can NAPALM help detect configuration drift without changing anything?
Load the intended configuration as a replace candidate, run compare_config() to see the difference, then discard_config().
Why is get_interfaces() useful in a mixed-vendor network?
It returns the same dictionary structure for every supported platform, so one script can process all devices without vendor-specific parsing.

Key takeaways

  • NAPALM gives one Python API across several vendors via drivers.
  • Getters return structured, vendor-neutral data.
  • Changes use a candidate: load, compare, then commit or discard.
  • Merge adds lines; replace enforces a full configuration.
  • Test replace in a lab and keep intended configs in Git.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.