Netmiko Method for Entering and Exiting Configuration Mode
Short answer
A Send_config_set() is the Netmiko method that automatically enters configuration mode, sends the command list, and exits configuration mode, unlike send_command(), write_channel(), or send_command_timing().
Question
Key Takeaways
Netmiko's send_config_set() is the configuration helper that automatically enters global configuration mode, sends a list of CLI commands, and exits configuration mode. Among send_command(), write_channel(), and send_command_timing(), it is the only option whose default behavior wraps that mode lifecycle, so option A is correct.
Expert Analysis
Because the required call must own the whole configure-terminal/end envelope rather than merely push a CLI string, send_config_set (A) is the Netmiko method that enters and exits configuration mode around the supplied commands.
send_config_set Bundles the Configuration-Mode Lifecycle by Default
send_config_set (A) spends a little abstraction by wrapping the entire mode transition, but that is precisely the cost the requirement wants to pay: the caller supplies configuration statements and Netmiko handles configuration entry and exit. send_command (B) costs at least two extra round trips and, more importantly, two extra state decisions, because the engineer must issue configure terminal, verify the prompt changed, issue end, and verify the prompt returned before trusting the session. write_channel (C) sacrifices the most: it writes raw characters to the SSH channel without prompt detection, command verification, or mode accounting, so a missing newline, an echoed banner, or an early return can leave the device in configuration mode while the Python process believes it has finished. send_command_timing (D) avoids prompt matching by reading for a fixed interval, which helps with paginated or nonstandard output but does not infer that a configure terminal command has changed the CLI context; any mode exit would still have to be typed and tested by the script. The decisive contrast is between a helper that encodes the state transition and three calls that either ignore mode entirely or leave it to application code. The latter are not wrong in every Netmiko program, but they answer a different operational need: sending one command, writing raw bytes, or collecting output when the prompt is unreliable.
Automatic Mode Entry and Exit Makes send_config_set the Configuration Helper
The deciding condition is behavioral: the chosen call must change the device's CLI context before the supplied commands run and restore the prior context afterward. send_config_set is built around that transition. In Netmiko, it accepts a list or iterable of configuration commands and, with its defaults, calls the connection's configuration-mode routine before sending the list and the exit-configuration-mode routine after the list. Those routines are platform-aware: the library derives the correct configuration command for the device type, waits for the configuration prompt, then sends the platform's exit command and waits for the original prompt to return. That prompt verification is the part a bare write omits and a timing read approximates poorly. The helper also verifies commands as they are echoed unless command verification is disabled, so a rejected line does not silently pass for success. The requirement therefore does not hinge on the method's name alone; it hinges on the fact that entry, command delivery, and exit form one operation with one returned transcript. send_config_set is the only listed option that provides that packaged lifecycle. The others can send a configuration command, but they make the surrounding mode transition an application-level concern, and that is exactly the concern the requirement says must be handled.
Manual send_command Would Win Only If the Session Already Owned the Mode Change
send_command becomes the right tool when the requirement is a single prompt-terminated command and the surrounding CLI context is already correct. If a script had already entered configuration mode—perhaps through a prior send_command('configure terminal')—and now needed one interface GigabitEthernet0/1 statement without leaving configuration mode, then send_command would preserve that context and return the command output. It would also be the natural choice for an operational command such as show ip interface brief, where entering configuration mode would be harmful. Neither condition is present in the requested behavior. The requirement explicitly couples sending commands with entering and exiting configuration mode, so an alternative that only sends a string and waits for a prompt is incomplete. To make send_command satisfy the requirement, the caller would need to add explicit entry and exit calls, prompt checks, and error handling around them; at that point the script, not Netmiko, is implementing the mode envelope. The method can still be correct in programs that deliberately manage state themselves, but that is a different design contract from the automatic one. The presence of send_config_set makes the manual sequence unnecessary for a batch of configuration commands.
Treat Mode Ownership as the Discriminator Between Netmiko Send Methods
Carry this rule into any Netmiko task that mixes mode verbs with method names: if the desired behavior includes entering or exiting configuration mode, select the method that owns those transitions—send_config_set for an in-memory command list, or its file-based sibling for commands read from disk. If the task is only to issue one show command and read until the prompt, select send_command. If the prompt is unreliable and output must be collected by elapsed time, select send_command_timing. If the task is raw channel manipulation, select write_channel and accept that all prompt and mode handling is the script's responsibility. The evidence in the option set is the phrase pairing command delivery with configuration-mode entry and exit: only the configuration-set helper advertises both halves as one operation. A useful secondary check is to look for default parameters: enter_config_mode=True and exit_config_mode=True mean the lifecycle is automatic unless the caller deliberately overrides it. A method that merely sends text has no such defaults, so it cannot satisfy a mode-transition requirement without extra code. Test the requirement against the method's contract, not against whether it can eventually send the same characters.
Official Reference
- https://ktbyers.github.io/netmiko/docs/netmiko/base_connection.html
- https://github.com/ktbyers/netmiko/blob/develop/netmiko/base_connection.py
These links open the official vendor documentation in a new tab.
Exam Strategy
When a Netmiko stem mentions mode changes, map the requirement to the method that owns the mode envelope rather than the method that merely sends text. Remember the pairing: send_config_set() for configuration lists with automatic enter/exit, send_command() for one prompt-terminated command, and send_command_timing() for output that cannot be bounded by a prompt. If the options include both a mode-aware helper and generic send calls, eliminate the generic calls first, then confirm the helper's defaults include configuration-mode entry and exit.
Related Analysis
Practice All 300-435 Questions
Access 150 questions with complete answers and detailed explanations.
View Full 300-435 Practice Test →