### Configure, Build, and Install RANCiD Source: https://context7.com/haussli/rancid/llms.txt Configure RANCiD with installation paths and SCM backend, then build and install it. Verify the installation using the version flag. ```sh ./configure \ --prefix=/opt/rancid \ --localstatedir=/opt/rancid/var \ --with-git make sudo make install # Verify installation /opt/rancid/bin/rancid -V # rancid 3.14.99 ``` -------------------------------- ### Initialize RANCiD Group Directories and SCM Repositories Source: https://context7.com/haussli/rancid/llms.txt Use `rancid-cvs` to create the directory structure and SCM repositories for each group defined in `rancid.conf`. This should be run after installation and when new groups are added. ```sh # Initialize all groups defined in rancid.conf /opt/rancid/bin/rancid-cvs # Initialize only specific groups /opt/rancid/bin/rancid-cvs backbone datacenter # Use an alternate config file /opt/rancid/bin/rancid-cvs -f /etc/rancid/rancid.conf # Expected directory structure created under BASEDIR: # /opt/rancid/var/ # backbone/ # configs/ <- collected device configs committed here # router.db <- device inventory file # datacenter/ # configs/ # router.db # logs/ <- per-group per-run log files # CVS/ (or .git/) <- SCM repository root ``` -------------------------------- ### Custom RANCiD device type configuration Source: https://context7.com/haussli/rancid/llms.txt Example of extending the 'cisco' type in rancid.types.conf to use 'show tech-support'. Includes custom Juniper type example. ```text # rancid.types.conf — user-defined custom type example # Extends 'cisco' type to use 'show tech-support' instead of running-config ciscoshtech;script;rancid -t ciscoshtech ciscoshtech;login;clogin ciscoshtech;module;ios ciscoshtech;module;iosshtech ciscoshtech;inloop;ios::inloop ciscoshtech;command;ios::ShowVersion;show version ciscoshtech;command;ios::ShowBoot;show boot ciscoshtech;command;iosshtech::WriteTerm;show tech-support # Custom Juniper type piping output to 'display set' format jlocal;script;rancid -t jlocal jlocal;login;jlogin jlocal;module;junos jlocal;inloop;junos::inloop jlocal;command;junos::ShowChassisHardware;show chassis hardware detail jlocal;command;junos::ShowVersion;show version detail jlocal;command;junos::ShowConfiguration;show configuration | display set # Add new device in router.db to use custom type: # custom-router.example.com;ciscoshtech;up ``` -------------------------------- ### SEC Configuration for Event-Driven Collection Source: https://context7.com/haussli/rancid/llms.txt Example SEC configuration stanza to trigger RANCiD collection when an IOS CONFIG_I syslog message is received, with suppression to avoid frequent triggers. ```sec type=SingleWithSuppress ptype=RegExp pattern=\s\S+:\S+\s(\S+)\.example\.com.*SYS-5-CONFIG_I action=shellcmd /opt/rancid/bin/rancid-run -r $1 backbone window=1800 ``` -------------------------------- ### Print Command List for Device Type Source: https://context7.com/haussli/rancid/llms.txt Display the configured command list for a given device type using the 'rancid -C' command. ```sh rancid -t myvendor -C ``` -------------------------------- ### RANCiD Global Configuration (`rancid.conf`) Source: https://context7.com/haussli/rancid/llms.txt Set environment variables for RANCiD, including paths, SCM backend, device groups, and filtering options. This file must be sourced before running RANCiD tools. ```sh # /opt/rancid/etc/rancid.conf (representative settings) TERM=network; export TERM LC_COLLATE="POSIX"; export LC_COLLATE umask 027 PERL5LIB=/opt/rancid/lib/rancid; export PERL5LIB BASEDIR=/opt/rancid/var; export BASEDIR PATH=/opt/rancid/bin:/usr/bin:/bin; export PATH # SCM backend: cvs | svn | git RCSSYS=git; export RCSSYS CVSROOT=$BASEDIR/CVS; export CVSROOT LOGDIR=$BASEDIR/logs; export LOGDIR # Device groups (each becomes a sub-directory and SCM repository) LIST_OF_GROUPS="backbone datacenter edge"; export LIST_OF_GROUPS # Parallel collection workers per group PAR_COUNT=10; export PAR_COUNT # Hours before alerting about unreachable devices OLDTIME=4; export OLDTIME # Retry failed device collections up to N times per run MAX_ROUNDS=3; export MAX_ROUNDS # Filter passwords (NO | YES | ALL) FILTER_PWDS=YES; export FILTER_PWDS # Strip SNMP community strings NOCOMMSTR=YES; export NOCOMMSTR # Filter oscillating/dynamic data (NO | YES | ALL) FILTER_OSC=YES; export FILTER_OSC # Filter ACL sequence numbers ACLFILTERSEQ=YES; export ACLFILTERSEQ # Sort access-lists by IP address ACLSORT=YES; export ACLSORT # Split large diff emails at N kbytes (0 = no split) MAILSPLIT=100; export MAILSPLIT SENDMAIL=/usr/sbin/sendmail; export SENDMAIL ``` -------------------------------- ### Define New Device Type 'myvendor' Source: https://context7.com/haussli/rancid/llms.txt Configure a new device type 'myvendor' by specifying the script, login method, and custom Perl modules for in-loop and command execution. ```rancid.types.conf myvendor;script;rancid -t myvendor myvendor;login;clogin myvendor;module;myvendor myvendor;inloop;myvendor::inloop myvendor;command;myvendor::ShowVersion;show version myvendor;command;myvendor::WriteTerm;show running-config ``` -------------------------------- ### RANCiD Device Inventory File (`router.db`) Source: https://context7.com/haussli/rancid/llms.txt Define devices to be collected by RANCiD within each group's `router.db` file. The format is `hostname;device-type;state`, where state can be `up` (collect) or `down` (skip). ```text # /opt/rancid/var/backbone/router.db # Format: hostname;device-type;state # state: up = collect, down = skip core-rtr1.example.com;cisco;up core-rtr2.example.com;cisco;up core-sw1.example.com;cisco;up edge-fw1.example.com;juniper;up edge-fw2.example.com;juniper;up mgmt-sw1.example.com;cat5;up old-rtr.example.com;cisco;down # Hybrid Catalyst with IOS routing module — two entries cat6k-rsm.example.com;cisco;up cat6k-sw.example.com;cat5;up # Other supported device types: # arista, nxos, iosxr, fortigate, panos, sros (Nokia SR-OS), # a10, arbor, arcos, ciena-ws, dell, dnos9, edgemax, exos, # f5, foundry, ios-xr, ios-exr, junos-evo, mrv, routeros, vrp ``` -------------------------------- ### Run all RANCiD groups with rancid-run Source: https://context7.com/haussli/rancid/llms.txt Top-level cron entry point that iterates over groups and calls control_rancid. Supports running specific groups or devices. ```sh # Run all groups defined in LIST_OF_GROUPS /opt/rancid/bin/rancid-run ``` ```sh # Run specific groups only /opt/rancid/bin/rancid-run backbone datacenter ``` ```sh # Trigger collection for a single device across all groups /opt/rancid/bin/rancid-run -r core-rtr1.example.com ``` ```sh # Send diffs to a specific address for this run /opt/rancid/bin/rancid-run -m noc@example.com backbone ``` ```sh # Use an alternate rancid.conf /opt/rancid/bin/rancid-run -f /etc/rancid/rancid.conf ``` ```sh # Typical crontab entries: # Run collection hourly 1 * * * * . /opt/rancid/etc/rancid.conf; /opt/rancid/bin/rancid-run # Clean logs older than 2 days 50 23 * * * /usr/bin/find /opt/rancid/var/logs -type f -mtime +2 -exec rm {} \; # Run with nice priority to avoid starving other processes 1 * * * * nice -19 /opt/rancid/bin/rancid-run ``` -------------------------------- ### Test Login Script Interactively Source: https://context7.com/haussli/rancid/llms.txt Use 'clogin' to test the login script interactively for a specific device. ```sh clogin myvendor-device.example.com ``` -------------------------------- ### rancid: Network Configuration Collector Source: https://context7.com/haussli/rancid/llms.txt Use rancid to collect and filter device configurations. It reads command definitions, invokes login scripts, and writes normalized .new files. Supports debug output and pre-captured file testing. ```sh # Collect config for a single Cisco IOS device rancid -t cisco core-rtr1.example.com # Output: core-rtr1.example.com.new (filtered, normalized config) ``` ```sh # Collect with debug output (keeps .raw and .new files on error) rancid -d -t cisco core-rtr1.example.com # core-rtr1.example.com.raw = unfiltered raw CLI output # core-rtr1.example.com.new = processed output ``` ```sh # Print the full command list that would be run for a device type rancid -t cisco -C # Output: # show version # show redundancy secondary # show interfaces # show ip interface # ... ``` ```sh # Collect a Juniper device rancid -t junos edge-fw1.example.com ``` ```sh # Collect from a pre-captured file (for offline testing/debugging) rancid -d -t cisco -f captured-output.raw fake-hostname ``` -------------------------------- ### Log output to a file with rancid Source: https://context7.com/haussli/rancid/llms.txt Use the -l flag to log output to a file. Specify the device type and hostname. ```sh rancid -l -t nxos nxos-sw1.example.com ``` -------------------------------- ### Verify Command Execution with clogin Source: https://context7.com/haussli/rancid/llms.txt Execute specific commands on a device using 'clogin' with the '-c' option. ```sh clogin -c 'show version; show running-config' myvendor-device.example.com ``` -------------------------------- ### clogin: Interactive and Scripted Device Login Source: https://context7.com/haussli/rancid/llms.txt Use clogin for interactive login, single-command execution, script execution, or batch commands from a file. Supports debugging .cloginrc matching and overriding timeouts. Source rancid.conf for correct PATH. ```sh # Interactive login (presents a live CLI prompt) clogin core-rtr1.example.com ``` ```sh # Run one or more commands and exit clogin -c 'show version' core-rtr1.example.com ``` ```sh # Run multiple semicolon-separated commands clogin -c 'show version; show interfaces; show ip route' core-rtr1.example.com ``` ```sh # Run commands that require secondary confirmation input # \n provides the extra carriage return to confirm the prompt clogin -c 'clear counters\n' core-rtr1.example.com ``` ```sh # Execute an expect script non-interactively clogin -s /opt/rancid/share/rancid/cisco-load.exp core-rtr1.example.com ``` ```sh # Run commands from a file (newline-separated) clogin -x /tmp/cmds.txt core-rtr1.example.com ``` ```sh # Debug .cloginrc matching for a host (-M shows matched directives) clogin -M core-rtr1.example.com ``` ```sh # Show all directives that would apply without connecting (-m) clogin -m core-rtr1.example.com ``` ```sh # Override timeout (seconds) clogin -t 120 -c 'show tech-support' core-rtr1.example.com ``` ```sh # Source rancid.conf to get the correct PATH first (recommended from shell) . /opt/rancid/etc/rancid.conf clogin -c 'show version' core-rtr1.example.com ``` -------------------------------- ### Configure parallel command execution with par Source: https://context7.com/haussli/rancid/llms.txt Enables RANCiD to collect from multiple devices simultaneously. Controlled by PAR_COUNT in rancid.conf. ```sh # PAR_COUNT controls how many rancid-fe processes run concurrently. # Set in rancid.conf: PAR_COUNT=10; export PAR_COUNT # par is typically invoked internally by control_rancid, but can be # used directly to parallelize arbitrary commands: # par -f device-list.txt -x "rancid-fe {}" # Tune PAR_COUNT by watching CPU during a collection run: vmstat 5 # Aim for near-zero idle% and minimal blocking (bi/bo). # Example throughput estimate: # 1 GHz CPU * 60 min/hr / 50 MHz·min per device = ~1200 devices/hour ``` -------------------------------- ### Reuse Existing Module for Cisco IOS-like Devices (awplus) Source: https://context7.com/haussli/rancid/llms.txt Configure the 'awplus' device type to reuse the 'ios' module for devices behaving like Cisco IOS, specifying script, login, and module details. ```rancid.types.conf awplus;script;rancid -t awplus awplus;login;clogin awplus;module;ios awplus;inloop;ios::inloop awplus;command;ios::ShowVersion;show version awplus;command;ios::WriteTerm;show running-config ``` -------------------------------- ### Test RANCiD Collection with Debug Output Source: https://context7.com/haussli/rancid/llms.txt Run RANCiD collection for a specific device type and host, using the '-d' flag to keep raw output for inspection. ```sh rancid -d -t myvendor myvendor-device.example.com ``` -------------------------------- ### Expected Output of Manual Trigger Source: https://context7.com/haussli/rancid/llms.txt Illustrates the expected output messages in the RANCiD log file after a successful manual on-demand trigger. ```text Trying core-rtr1.example.com collection successful changes found: committing ``` -------------------------------- ### jlogin: Juniper JunOS Device Login Source: https://context7.com/haussli/rancid/llms.txt Use jlogin for logging into Juniper devices running JunOS. It handles JunOS-specific prompts and supports SSH identity files. Use -d for debugging login sequences. ```sh # Interactive Juniper login jlogin edge-fw1.example.com ``` ```sh # Run JunOS operational commands jlogin -c 'show version; show chassis hardware' edge-fw1.example.com ``` ```sh # Run JunOS configuration commands (pipe to display set for portability) jlogin -c 'show configuration | display set' edge-fw1.example.com ``` ```sh # Use a specific SSH identity file jlogin -i /home/rancid/.ssh/juniper_rsa edge-fw1.example.com ``` ```sh # Debug login sequence jlogin -d edge-fw1.example.com ``` -------------------------------- ### Add Devices to router.db Source: https://context7.com/haussli/rancid/llms.txt Add new devices to the RANCiD router database, specifying the hostname, device type, and status. ```router.db myvendor-device.example.com;myvendor;up awplus-sw1.example.com;awplus;up ``` -------------------------------- ### plogin: Poly-Login for Device-Type Aware Login Source: https://context7.com/haussli/rancid/llms.txt Use plogin to automatically select the correct login script based on hostname in router.db. It delegates to appropriate scripts like clogin or jlogin. Can also run commands directly. ```sh # plogin looks up the device type in router.db and delegates to the # appropriate login script (clogin, jlogin, etc.) plogin core-rtr1.example.com ``` ```sh # Run a command using device-type-appropriate login script plogin -c 'show version' edge-fw1.example.com ``` ```sh # Works for any device type in router.db plogin mgmt-sw1.example.com ``` -------------------------------- ### RANCiD device type definition format Source: https://context7.com/haussli/rancid/llms.txt Defines the format for rancid.types.base and rancid.types.conf files. Specifies directives like script, login, module, and command. ```text # rancid.types.base format: type;directive;value # Directives: # script - rancid script/command to run (may include arguments) # login - login script name # module - Perl library module to load # inloop - module::function used as the main input processing loop # command - module::FilterFunction;CLI command to execute # alias - alias this type name to another type # timeout - override login timeout (seconds) # Example: Cisco IOS entry from rancid.types.base cisco;script;rancid -t cisco cisco;login;clogin cisco;module;ios cisco;inloop;ios::inloop cisco;command;ios::ShowVersion;show version cisco;command;ios::ShowRedundancy;show redundancy secondary cisco;command;ios::ShowInterfaces;show interfaces cisco;command;ios::ShowIPInterface;show ip interface cisco;command;ios::WriteTerm;show running-config ``` -------------------------------- ### Configure .cloginrc for Device Credentials Source: https://context7.com/haussli/rancid/llms.txt Use .cloginrc to store per-device or glob-matched credentials and connection options. Ensure the file has 0600 permissions. Supports various options like user, password, method, autoenable, noenable, and sshcmd for different device types and scenarios. ```tcl # ~/.cloginrc (must be chmod 600) # Backbone routers: username + password + enable password, SSH preferred add user backbone*.example.com netops add password backbone*.example.com {v7yP@ssw0rd} {3n@bl3P@ss} add method backbone*.example.com ssh telnet # Firewalls: auto-enabled after login (no separate enable step) add user fw*.example.com rancid-ro add password fw*.example.com {fwS3cr3t!} add autoenable fw*.example.com 1 add method fw*.example.com ssh # Juniper — SSH identity file add user *.juniper.example.com rancid add identity *.juniper.example.com /home/rancid/.ssh/juniper_rsa # Nokia SR-OS — no enable mode add noenable sros*.example.com 1 add user sros*.example.com rancid add password sros*.example.com {Sr0sP@ss} # Legacy devices requiring weak SSH crypto add sshcmd legacy*.example.com {ssh -o KexAlgorithms=+diffie-hellman-group1-sha1} # Route-servers: no enable add noenable route-server* 1 # Fallback catch-all add user * rancid add password * {d3f@ultP@ss} {d3f@ultEn@bl3} add method * ssh telnet ``` -------------------------------- ### Manual On-Demand RANCiD Trigger Source: https://context7.com/haussli/rancid/llms.txt Manually trigger RANCiD collection for a specific device using the 'rancid-run' script, sourcing the configuration first. ```sh . /opt/rancid/etc/rancid.conf rancid-run -r core-rtr1.example.com backbone ``` -------------------------------- ### Run RANCiD collection for a group with control_rancid Source: https://context7.com/haussli/rancid/llms.txt Orchestrates RANCiD collection for a single group. Handles parallel execution, SCM commits, and diff emails. ```sh # Run collection for the 'backbone' group control_rancid backbone ``` ```sh # Run for a single device within a group (skips others) control_rancid -r core-rtr1.example.com backbone ``` ```sh # Send diffs to a specific email address instead of the group alias control_rancid -m oncall@example.com backbone ``` ```sh # Use a group-specific config file overlay control_rancid -f /opt/rancid/var/backbone/rancid.conf backbone ``` ```sh # Use a custom SCM commit message control_rancid -c "Emergency change - ticket #12345" backbone ``` ```sh # Print version control_rancid -V ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.