[rancid] Re: Download configs from one router through another

Graham Fleming Graham.Fleming at bdwalk.biz
Fri Sep 12 18:04:46 UTC 2008


Thanks for the reply, Ed. Here's a small snippet of the kind of thing we
would be using your patch for. This would be one site where we log into
the GATEWAY router and then from there we would log into the internal
routers on the 172.16.0.0/24 network.

This is a small example for three such routers and how I have it
configured using your patch. The trouble is we have a few clients with
dozens of routers so, as you can see, this could get quite tedious:


add user 172.16.0.23            username1
add autoenable 172.16.0.23      1
add password 172.16.0.23        {password1}
add method 172.16.0.23          {usercmd}
add usercmd 172.16.0.23         {ssh} {username1 at public-ip.address}
add usercmd_chat 172.16.0.23    {Password: } {password2\r}
{GATEWAY-PROMPT#} {ssh 172.16.0.23\r} {Password: } {password1\r}
{INTERNAL-PROMPT#} {\r}

add user 172.16.0.34            username1
add autoenable 172.16.0.34      1
add password 172.16.0.34        {password1}
add method 172.16.0.34          {usercmd}
add usercmd 172.16.0.34         {ssh} {username1 at public-ip.address}
add usercmd_chat 172.16.0.34    {Password: } {password2\r}
{GATEWAY-PROMPT#} {ssh 172.16.0.34\r} {Password: } {password1\r}
{INTERNAL-PROMPT#} {\r}

add user 172.16.0.56            username1
add autoenable 172.16.0.56      1
add password 172.16.0.56        {password1}
add method 172.16.0.56          {usercmd}
add usercmd 172.16.0.56         {ssh} {username1 at public-ip.address}
add usercmd_chat 172.16.0.56    {Password: } {password2\r}
{GATEWAY-PROMPT#} {ssh 172.16.0.56\r} {Password: } {password1\r}
{INTERNAL-PROMPT#} {\r}

... and so on....

So, what I'd love to be able to do is use wildcards with your patch,
specifcally the 'usercmd_chat' portion. So instead of one statement for
each router, we use one for all internal routers like so:

add user 172.16.0.*            username1
add autoenable 172.16.0.*      1
add password 172.16.0.*        {password1}
add method 172.16.0.*          {usercmd}
add usercmd 172.16.0.*        {ssh} {username1 at public-ip.address}
add usercmd_chat 172.16.0.*    {Password: } {password2\r}
{GATEWAY-PROMPT#} {ssh $INTERNAL_IP\r} {Password: } {password1\r}
{$INTERNAL_PROMPT#} {\r}

Where  {ssh $INTERNAL_IP\r} would be the value for the wildcarded
internal IP address and {ssh $INTERNAL_IP\r} could somehow be a wilcard
value to match any prompt.

I'm assuming this probably won't work though, as I have no idea how
you'd pass the internal IP address to the ssh command on the gateway
router using variables or whatnot. Similarly, is there a way to accept
any value for the internal router's prompt so we don't need to use
specific values for each router?

Thanks a lot for all your help!

Graham 

-----Original Message-----
From: Ed Ravin [mailto:eravin at panix.com] 
Sent: Thursday, September 11, 2008 1:18 PM
To: Graham Fleming
Cc: rancid-discuss at shrubbery.net
Subject: Re: [rancid] Re: Download configs from one router through
another

I'm not sure I fully understand what you're trying to do - it would help
if you posted a sanitized .cloginrc of what you're doing now, and then
a wishful thinking .cloginrc of what you'd like to have.

The "usercmd" definitions are matched the same way everything else is
in the *login scripts, which would let you have a common usercmd for
groups of routers.  However, my patch doesn't add any fucntionality for
unique content in the usercmd variable or expansion of variables other
than what is already supported by clogin.  There may be a way to use
"$router" in the usercmd definition or some other extra coding in
cloginrc
to do what you want; it might require an extra "eval" in clogin when
assigning the value of $usercmd.  Perhaps someone more familiar with
TCL and/or RANCID scripting could speak up with the details.

	-- Ed


More information about the Rancid-discuss mailing list