<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>xpresslearn.com</title>
	<atom:link href="http://www.xpresslearn.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.xpresslearn.com</link>
	<description>Solutions to your Networking and Security questions</description>
	<lastBuildDate>Wed, 30 Jun 2010 18:20:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>CSharp Telnet client</title>
		<link>http://www.xpresslearn.com/networking/code/csharp-telnet-client</link>
		<comments>http://www.xpresslearn.com/networking/code/csharp-telnet-client#comments</comments>
		<pubDate>Fri, 11 Jun 2010 16:54:15 +0000</pubDate>
		<dc:creator>Scott Pilkinton</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[archive]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[ConfigSafe]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[telnet]]></category>

		<guid isPermaLink="false">http://www.xpresslearn.com/?p=181</guid>
		<description><![CDATA[This article will go through the process of compiling an entire program in C# that accomplishes logging into a Cisco IOS device via telnet and displays the running configuration.]]></description>
			<content:encoded><![CDATA[<p>In previous articles, I have explained how to setup automated Cisco backup processes &#8211; however all the previous examples used existing software. There are other scenarios where a custom programming solution could be required. Writing your own software gives you the most control over the program and the process. However, this usually requires more effort and understanding in order to obtain this level of control and/or functionality.  This article will go through the process of compiling an entire program that accomplishes logging into a Cisco IOS device via telnet and displays the running configuration.</p>
<p>First off, most of the credit for the following code goes to a contributor on <a href="http://www.codeproject.com">Codeproject</a>, which is where the source came from to build the telnet component of this program.  We will code the remainder of the program that utilizes the telnet code obtained from codeproject.</p>
<p>The code contained in this article can be compiled using the Microsoft 2.0 framework that is most likely already installed on your computer.  We will compile this with the command line compiler that comes with the .Net runtime.  By using this method, it not only provides a very simple process to compile the program, it also prevents having to download Microsoft Visual Studio Express.  I would suggest, however, that if you plan to extend this program &#8211; you can benefit greatly from having a full blown IDE to write the code in.</p>
<p>First, let&#8217;s look at the telnet component, which is the majority of the program.  This portion of the code is compiled as a library (.dll) under the name scottp.Net.Comm.dll and will be a dependency for the ConfigSafe project.  This code could have just as easily been put in the executable, which would have kept the program to a single file.  However, in bigger programs, this type of code would go into a library anyway &#8211; so there is no time like the present to begin following standard practices.</p>
<p><span id="more-181"></span></p>
<p>The telnet method accepts three arguments as input, which is the IP address, port number, and a timeout value in seconds:</p>
<pre>
        public Telnet(string Address, int Port, int CommandTimeout)
        {
            address = Address;
            port = Port;
            timeout = CommandTimeout;
        }
</pre>
<p>Once connected, the following method is used to search through the incoming data stream for the string defined as the argument in the WaitFor method:</p>
<pre>
        public int WaitFor(string DataToWaitFor)
        {
            // Get the starting time
            long lngStart = DateTime.Now.AddSeconds(this.timeout).Ticks;
            long lngCurTime = 0;

            while (strWorkingData.ToLower().IndexOf(DataToWaitFor.ToLower()) == -1)
            {
                // Timeout logic
                lngCurTime = DateTime.Now.Ticks;
                if (lngCurTime &gt; lngStart)
                {
                    throw new Exception("Timed Out waiting for : " + DataToWaitFor);
                }
                Thread.Sleep(1);
            }
            strWorkingData = "";
            return 0;
        }
</pre>
<p></p>
<p>One of the methods available (and the one we will use) to send data back to the Telnet service:</p>
<pre>
        public void SendMessage(string Message)
        {
            DoSend(Message + "\r");
        }
        private void DoSend(string strText)
        {
            try
            {
                Byte[] smk = new Byte[strText.Length];
                for (int i = 0; i < strText.Length; i++)
                {
                    Byte ss = Convert.ToByte(strText[i]);
                    smk[i] = ss;
                }

                s.Send(smk, 0, smk.Length, SocketFlags.None);
            }
            catch (Exception ers)
            {
                Console.Error.WriteLine(ers.ToString());
                //MessageBox.Show("ERROR IN RESPOND OPTIONS");
            }
        }
</pre>
<p>To compile the dll, we follow this simple process:  First, you will need to locate where the .net runtime is installed on your computer.  One of the easier ways to do this is to perform a search for csc.exe on your machine.  Most likely, the path will be the same as it is on my computer: \Windows\Microsoft.NET\Framework\v2.0.50727.  In order to compile, this needs to be added to your %PATH.  This can be done at the command line or by modifying the Advanced System Properties -> Environment Variables.  When using the latter method, all future cmd windows will use the updated path - if you have a cmd window already open and then modify the path in the system properties, it will not have the updated %PATH statement.  So, just be sure you are working in a cmd window that is opened after adding to the path in the system properties.</p>
<p>At the command window, change to the directory where the source files are located and compile:</p>
<pre>csc /t:library /out:scottp.Net.Comm.dll telnet.cs</pre>
<p>We have told the compiler (csc.exe) to compile a library and name it scottp.Net.Comm.dll using the source code contained in telnet.cs</p>
<p><a href="http://www.xpresslearn.com/wp-content/uploads/compile-dll1.png"><img src="http://www.xpresslearn.com/wp-content/uploads/compile-dll1.png" alt="" title="Compiling ConfigSafe Telnet library" width="600" height="266" class="alignnone size-full wp-image-445" /></a></p>
<p>Next, we will write the remainder of code that makes up the overall program.  The executable will be much smaller in terms of lines of code than the library we just looked at.  In this example, the program would be considered unusable in a production environment, because we have hard coded an IP address, username, and password for the router we want to download the configuration from.  To have a usable program, these three values could be taken in at the command line as arguments when running the program.  However, since this is just for demonstration purposes, the program will be kept simple.  In future articles, we will expand the functionality of the program.</p>
<p></p>
<p>Below is the entire source of the ConfigSafe.exe program:</p>
<pre>
using System;
using System.Collections.Generic;
using System.Text;
using scottp.Net.Comm;

namespace ConfigBackup
{
    class Program
    {
        static void Main(string[] args)
        {
            CiscoNoEnable cNE = new CiscoNoEnable();
            cNE.sHostName = "10.1.100.1";
            cNE.sUsername = "admin";
            cNE.sPassword = "cisco";
            cNE.getConfig();
        }
    }
        public class CiscoNoEnable
        {

        public string sHostName;
        public string sUsername;
        public string sPassword;

        private void Initialize_Components()
        {
            sHostName = "";
            sUsername = "";
            sPassword = "";
        }

        public CiscoNoEnable()
        {
            Initialize_Components();
        }
        public void getConfig()
        {

            this.sHostName = this.sHostName.Trim();
            this.sUsername = this.sUsername.Trim();
            this.sPassword = this.sPassword.Trim();

            Telnet mST = new Telnet(this.sHostName, 23, 8);

            if (mST.Connect() == false)
            {
                Console.WriteLine("");
                Console.WriteLine("Error: ");
                Console.WriteLine("Timeout connecting to: " + this.sHostName);
                Console.WriteLine("");
            }
            else
            {
                try
                {
                    mST.WaitFor("Username:");
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc.Message);
                }
                mST.SendMessage(this.sUsername);
                mST.WaitFor("Password:");
                mST.SendMessage(this.sPassword);
                mST.WaitFor("#");
                mST.SendMessage("term len 0");
                mST.WaitFor("#");
                mST.SendMessage("show run");
                mST.WaitFor("#");
                mST.SendMessage("exit");
                Console.Write(mST.FindStringBetween("bytes\r\n", "\r\n\r\n",
                "Error: Configuration not obtained"));
            }
        }
    }
}
</pre>
<p></p>
<p>Let's pick a couple of the important areas to understand and talk about a little further.  First the include statement we need for the library:</p>
<pre>
using scottp.Net.Comm;
</pre>
<p>This tells the compiler that we are accessing methods in the previously created library.</p>
<p>Next, here is the code that makes up the Main code block:</p>
<pre>

        static void Main(string[] args)
        {
            CiscoNoEnable cNE = new CiscoNoEnable();
            cNE.sHostName = "10.1.100.1";
            cNE.sUsername = "admin";
            cNE.sPassword = "cisco";
            cNE.getConfig();
        }
</pre>
<p>So, we created a new CiscoNoEnable object called cNE and then set three properties that is required before executing the getConfig method.  If we take a closer look at the getConfig method:</p>
<pre>
public void getConfig()
        {

            this.sHostName = this.sHostName.Trim();
            this.sUsername = this.sUsername.Trim();
            this.sPassword = this.sPassword.Trim();

            Telnet mST = new Telnet(this.sHostName, 23, 8);

            if (mST.Connect() == false)
            {
                Console.WriteLine("");
                Console.WriteLine("Error: ");
                Console.WriteLine("Timeout connecting to: " + this.sHostName);
                Console.WriteLine("");
            }
            else
            {
                try
                {
                    mST.WaitFor("Username:");
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc.Message);
                }
                mST.SendMessage(this.sUsername);
                mST.WaitFor("Password:");
                mST.SendMessage(this.sPassword);
                mST.WaitFor("#");
                mST.SendMessage("term len 0");
                mST.WaitFor("#");
                mST.SendMessage("show run");
                mST.WaitFor("#");
                mST.SendMessage("exit");
                Console.Write(mST.FindStringBetween("bytes\r\n", "\r\n\r\n",
                "Error: Configuration not obtained"));
            }
        }
</pre>
<p>We notice it uses the Telnet method in our library using the hostname set in the CiscoNoEnable property and has port 23 and a value of 8 seconds hard coded into the program.  If the Telnet object is able to connect, we use a try/catch block and wait for the telnet server to return the text 'Username'.  If/When we see this text, the value set in the UserName property is sent to the telnet server.  The telnet server is expected to return a 'Password:' prompt, in which the value of the password property is sent back to the telnet server.</p>
<p>After logging in, we expect a #, which tells us we are in enable mode and then issue the 'term len 0 command', followed by a show run command, and then terminate the connection.  We then find all the text between the word 'bytes' (which will be contained in the first line of the response) and the end of the file and writes that text to the console.  If we can't find that text, then the telnet server didn't send us the response expected, so an error message is written to the console instead.</p>
<p>To compile the executable, issue the command:</p>
<pre>
csc /t:exe /out:ConfigSafe.exe /r:scottp.Net.Comm.dll ConfigSafe.cs
</pre>
<p>This tells the compiler to compile into an executable file with the name ConfigSafe.exe and that the scottp.Net.Comm.dll library is a requirement in order to compile and last, the code to compile is contained in ConfigSafe.cs</p>
<p><a href="http://www.xpresslearn.com/wp-content/uploads/compile-exe.png"><img src="http://www.xpresslearn.com/wp-content/uploads/compile-exe.png" alt="" title="Compile the ConfigSafe executable" width="550" height="244" class="alignnone size-full wp-image-450" /></a></p>
<p>By default, a successful run will output the configuration to the console, which is not that useful - so we will pipe the output to a file.</p>
<p><a href="http://www.xpresslearn.com/wp-content/uploads/run.png"><img src="http://www.xpresslearn.com/wp-content/uploads/run.png" alt="" title="Running the ConfigSafe program" width="550" height="244" class="alignnone size-full wp-image-452" /></a></p>
<p>Now we will take a look at the output by opening config.txt in notepad:</p>
<p><a href="http://www.xpresslearn.com/wp-content/uploads/config-file.png"><img src="http://www.xpresslearn.com/wp-content/uploads/config-file.png" alt="" title="Configuration file of Cisco router obtained by ConfigSafe" width="600" height="865" class="alignnone size-full wp-image-453" /></a></p>
<p>The configuration in the text file also serves as the test configuration used for the IOS device in this example.  As you can see, the authorization command was used to give the admin user privileged access, which puts us directly into enable mode.  We could have just as easily looked for a greater than sign '>' and issued an 'enable' command, in order to enter into enable mode.</p>
<p>I hope you have found this useful and stay tuned for future articles building on this foundation to make a program that can be used in your daily work.</p>
<p><a href='http://www.xpresslearn.com/wp-content/uploads/ConfigSafe.zip.zip'>ConfigSafe Source files</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xpresslearn.com/networking/code/csharp-telnet-client/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configure a Basic MPLS Network II</title>
		<link>http://www.xpresslearn.com/cisco/mpls-cisco/configure-a-basic-mpls-network-ii</link>
		<comments>http://www.xpresslearn.com/cisco/mpls-cisco/configure-a-basic-mpls-network-ii#comments</comments>
		<pubDate>Thu, 10 Jun 2010 22:56:36 +0000</pubDate>
		<dc:creator>Scott Pilkinton</dc:creator>
				<category><![CDATA[MPLS]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Label Switching]]></category>
		<category><![CDATA[LDP]]></category>

		<guid isPermaLink="false">http://www.xpresslearn.com/?p=362</guid>
		<description><![CDATA[Part 2 of many articles explaining how to build out an internal MPLS network.  This article starts off with basic MPLS specific configuration added to the network that was established in the first article.]]></description>
			<content:encoded><![CDATA[<p>In the first article, we went over some very basic MPLS terms and explanations.  That article ended with a basic network using four 7206 routers &#8211; two in each datacenter.  At this point, we have no routing protocols or MPLS configuration.  All we can do presently is ping directly connected interfaces of neighboring devices.  The first thing that we want to establish, is the routing protocol used by the MPLS aware devices to determine how to reach the other core devices.</p>
<p>The routing protocol distributes topology information through the network so that the route of a Label Switched Path (LSP) can be calculated.  An interior gateway protocol, such as OSPF or IS-IS, is normally used, as MPLS networks typically cover a single administrative domain.  Let&#8217;s configure OSPF on the P/Core devices so that we can ping every interface on all four routers.</p>
<p>
<pre>
hostname r1
!
interface Loopback1
 ip address 10.254.1.1 255.255.255.255
!
interface FastEthernet1/0
 description r2 f1/0
 ip address 10.1.1.1 255.255.255.252
!
interface FastEthernet1/1
 description r3 f1/1
 ip address 10.1.1.5 255.255.255.252
!
router ospf 1
 log-adjacency-changes
 network 10.1.1.0 0.0.0.3 area 0
 network 10.1.1.4 0.0.0.3 area 0
 network 10.254.1.1 0.0.0.0 area 0
</pre>
</p>
<p>
<pre>
hostname r2
!
interface Loopback1
 ip address 10.254.1.2 255.255.255.255
!
interface FastEthernet1/0
 description r1 f1/0
 ip address 10.1.1.2 255.255.255.252
!
interface FastEthernet1/1
 description r4 f1/1
 ip address 10.1.1.13 255.255.255.252
!
router ospf 1
 log-adjacency-changes
 network 10.1.1.0 0.0.0.3 area 0
 network 10.1.1.12 0.0.0.3 area 0
 network 10.254.1.2 0.0.0.0 area 0
</pre>
</p>
<p><span id="more-362"></span></p>
<p>
<pre>
hostname r3
!
interface Loopback1
 ip address 10.254.1.3 255.255.255.255
!
interface FastEthernet1/0
 description r4 f1/0
 ip address 10.1.1.9 255.255.255.252
!
interface FastEthernet1/1
 description r1 f1/1
 ip address 10.1.1.6 255.255.255.252
!
router ospf 1
 log-adjacency-changes
 network 10.1.1.4 0.0.0.3 area 0
 network 10.1.1.8 0.0.0.3 area 0
 network 10.254.1.3 0.0.0.0 area 0
</pre>
</p>
<p></p>
<p>
<pre>
hostname r4
!
interface Loopback1
 ip address 10.254.1.4 255.255.255.255
!
interface FastEthernet1/0
 description r3 f1/0
 ip address 10.1.1.10 255.255.255.252
!
interface FastEthernet1/1
 description r2 f1/1
 ip address 10.1.1.14 255.255.255.252
!
router ospf 1
 log-adjacency-changes
 network 10.1.1.8 0.0.0.3 area 0
 network 10.1.1.12 0.0.0.3 area 0
 network 10.254.1.4 0.0.0.0 area 0
</pre>
</p>
<p>
A quick way to determine if all your interfaces are in OSPF and each assigned area is to issue the following command:</p>
<p>
<pre>
r1#show ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Lo1          1     0               10.254.1.1/32      1     LOOP  0/0
Fa1/1        1     0               10.1.1.5/30        1     BDR   1/1
Fa1/0        1     0               10.1.1.1/30        1     BDR   1/1
r1#
</pre>
</p>
<p>Here is the output of the same command ran on the other three routers, just so you can double check your work and make sure we are in sync:</p>
<p>
<pre>
r2#show ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Lo1          1     0               10.254.1.2/32      1     LOOP  0/0
Fa1/1        1     0               10.1.1.13/30       1     BDR   1/1
Fa1/0        1     0               10.1.1.2/30        1     DR    1/1
r2#
r3#show ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Lo1          1     0               10.254.1.3/32      1     LOOP  0/0
Fa1/0        1     0               10.1.1.9/30        1     BDR   1/1
Fa1/1        1     0               10.1.1.6/30        1     DR    1/1
r3#
r4#show ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Lo1          1     0               10.254.1.4/32      1     LOOP  0/0
Fa1/1        1     0               10.1.1.14/30       1     DR    1/1
Fa1/0        1     0               10.1.1.10/30       1     DR    1/1
r4#
</pre>
</p>
<p>
Once all the interfaces are configured correctly in OSPF, the routing tables will have the reach-ability to all interfaces on all routers.  At this stage, let&#8217;s verify what the routing tables should look like on all four routers.</p>
<p>
<pre>
r1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, + - replicated route

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 10 subnets, 2 masks
C        10.1.1.0/30 is directly connected, FastEthernet1/0
L        10.1.1.1/32 is directly connected, FastEthernet1/0
C        10.1.1.4/30 is directly connected, FastEthernet1/1
L        10.1.1.5/32 is directly connected, FastEthernet1/1
O        10.1.1.8/30 [110/2] via 10.1.1.6, 00:48:55, FastEthernet1/1
O        10.1.1.12/30 [110/2] via 10.1.1.2, 00:49:05, FastEthernet1/0
C        10.254.1.1/32 is directly connected, Loopback1
O        10.254.1.2/32 [110/2] via 10.1.1.2, 00:49:05, FastEthernet1/0
O        10.254.1.3/32 [110/2] via 10.1.1.6, 00:48:55, FastEthernet1/1
O        10.254.1.4/32 [110/3] via 10.1.1.6, 00:48:55, FastEthernet1/1
                       [110/3] via 10.1.1.2, 00:49:05, FastEthernet1/0
r1#

r2#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, + - replicated route

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 10 subnets, 2 masks
C        10.1.1.0/30 is directly connected, FastEthernet1/0
L        10.1.1.2/32 is directly connected, FastEthernet1/0
O        10.1.1.4/30 [110/2] via 10.1.1.1, 00:49:28, FastEthernet1/0
O        10.1.1.8/30 [110/2] via 10.1.1.14, 00:49:38, FastEthernet1/1
C        10.1.1.12/30 is directly connected, FastEthernet1/1
L        10.1.1.13/32 is directly connected, FastEthernet1/1
O        10.254.1.1/32 [110/2] via 10.1.1.1, 00:49:38, FastEthernet1/0
C        10.254.1.2/32 is directly connected, Loopback1
O        10.254.1.3/32 [110/3] via 10.1.1.14, 00:49:28, FastEthernet1/1
                       [110/3] via 10.1.1.1, 00:49:28, FastEthernet1/0
O        10.254.1.4/32 [110/2] via 10.1.1.14, 00:49:38, FastEthernet1/1
r2#

r3#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, + - replicated route

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 10 subnets, 2 masks
O        10.1.1.0/30 [110/2] via 10.1.1.5, 00:49:53, FastEthernet1/1
C        10.1.1.4/30 is directly connected, FastEthernet1/1
L        10.1.1.6/32 is directly connected, FastEthernet1/1
C        10.1.1.8/30 is directly connected, FastEthernet1/0
L        10.1.1.9/32 is directly connected, FastEthernet1/0
O        10.1.1.12/30 [110/2] via 10.1.1.10, 00:49:53, FastEthernet1/0
O        10.254.1.1/32 [110/2] via 10.1.1.5, 00:49:53, FastEthernet1/1
O        10.254.1.2/32 [110/3] via 10.1.1.10, 00:49:53, FastEthernet1/0
                       [110/3] via 10.1.1.5, 00:49:53, FastEthernet1/1
C        10.254.1.3/32 is directly connected, Loopback1
O        10.254.1.4/32 [110/2] via 10.1.1.10, 00:49:53, FastEthernet1/0
r3#

r4#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, + - replicated route

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 10 subnets, 2 masks
O        10.1.1.0/30 [110/2] via 10.1.1.13, 00:50:29, FastEthernet1/1
O        10.1.1.4/30 [110/2] via 10.1.1.9, 00:50:19, FastEthernet1/0
C        10.1.1.8/30 is directly connected, FastEthernet1/0
L        10.1.1.10/32 is directly connected, FastEthernet1/0
C        10.1.1.12/30 is directly connected, FastEthernet1/1
L        10.1.1.14/32 is directly connected, FastEthernet1/1
O        10.254.1.1/32 [110/3] via 10.1.1.13, 00:50:19, FastEthernet1/1
                       [110/3] via 10.1.1.9, 00:50:19, FastEthernet1/0
O        10.254.1.2/32 [110/2] via 10.1.1.13, 00:50:29, FastEthernet1/1
O        10.254.1.3/32 [110/2] via 10.1.1.9, 00:50:19, FastEthernet1/0
C        10.254.1.4/32 is directly connected, Loopback1
r4#
</pre>
</p>
<p></p>
<p>At this point, pinging any interface from any router should be successful.  The next step is to configure MPLS on the physical interfaces of each device.  There are a couple of things that are needed in order to do this.  First, <b>ip cef</b> needs to be running; which is a global configuration command.  Second, <b>mpls ip</b> needs to be configured on each physical interface.  Here is what the configuration will look like:</p>
<p>
<pre>
!
hostname r1
!
ip cef
!
interface FastEthernet1/0
 description r2 f1/0
 ip address 10.1.1.1 255.255.255.252
 mpls ip
!
interface FastEthernet1/1
 description r3 f1/1
 ip address 10.1.1.5 255.255.255.252
 mpls ip
</pre>
</p>
<p>
<pre>
!
hostname r2
!
ip cef
!
interface FastEthernet1/0
 description r1 f1/0
 ip address 10.1.1.2 255.255.255.252
 mpls ip
!
interface FastEthernet1/1
 description r4 f1/1
 ip address 10.1.1.13 255.255.255.252
 mpls ip
</pre>
</p>
<p>
<pre>
!
hostname r3
!
ip cef
!
interface FastEthernet1/0
 description r4 f1/0
 ip address 10.1.1.9 255.255.255.252
 mpls ip
!
interface FastEthernet1/1
 description r1 f1/1
 ip address 10.1.1.6 255.255.255.252
 mpls ip
</pre>
</p>
<p>
<pre>
!
hostname r4
!
ip cef
!
interface FastEthernet1/0
 description r3 f1/0
 ip address 10.1.1.10 255.255.255.252
 mpls ip
!
interface FastEthernet1/1
 description r2 f1/1
 ip address 10.1.1.14 255.255.255.252
 mpls ip
</pre>
</p>
<p>Once you start getting mpls configured on each device, console messages will appear alerting that LDP neighbors have been established.</p>
<p>
<pre>
r1#
*Jun  7 10:05:02.335: %LDP-5-NBRCHG: LDP Neighbor 10.254.1.2:0 (2) is UP
*Jun  7 10:03:17.791: %LDP-5-NBRCHG: LDP Neighbor 10.254.1.3:0 (1) is UP
</pre>
</p>
<p>Next thing you want to verify is that you have discovered your directly connect neighbors.  Each router will have two neighbors, since they have two direct connections to other routers.  On any of the routers, we will issue the command: <b>show mpls ldp discovery</b>.  This is to verify we are communicating via the LDP protocol to our connected neighbors.</p>
<p>
<pre>
r4(config-router)#do show mpls ldp discovery
 Local LDP Identifier:
    10.254.1.4:0
    Discovery Sources:
    Interfaces:
FastEthernet1/0 (ldp): xmit/recv
    LDP Id: 10.254.1.3:0
FastEthernet1/1 (ldp): xmit/recv
    LDP Id: 10.254.1.2:0
r4(config-router)#end
</pre>
</p>
<p>From the previous example, we examine the output of r4 to determine a few things:</p>
<p>
 &#8211; Our local LDP identifier is 10.254.1.4, this is because we have a loopback configured and LDP will use that first by default as it&#8217;s ID.<br />
 &#8211; We have ldp communications via our local interface FastEthernet1/0 from r3<br />
 &#8211; We have ldp communications via our local interface FastEthernet1/1 from r2</p>
<p>With everything looking good thus far, I would expect to have formed two neighbor relationships.  We can verify our neighbors by issuing the following command: <b>show mpls ldp neighbor</b></p>
<p>
<pre>
r4#show mpls ldp neighbor
    Peer LDP Ident: 10.254.1.2:0; Local LDP Ident 10.254.1.4:0
        TCP connection: 10.254.1.2.646 - 10.254.1.4.26889
        State: Oper; Msgs sent/rcvd: 11/11; Downstream
        Up time: 00:00:53
        LDP discovery sources:
          FastEthernet1/1, Src IP addr: 10.1.1.13
        Addresses bound to peer LDP Ident:
          10.1.1.2        10.254.1.2      10.1.1.13
    Peer LDP Ident: 10.254.1.3:0; Local LDP Ident 10.254.1.4:0
        TCP connection: 10.254.1.3.646 - 10.254.1.4.17695
        State: Oper; Msgs sent/rcvd: 11/12; Downstream
        Up time: 00:00:53
        LDP discovery sources:
          FastEthernet1/0, Src IP addr: 10.1.1.9
        Addresses bound to peer LDP Ident:
          10.1.1.9        10.254.1.3      10.1.1.6
r4#
</pre>
</p>
<p>Ok, let&#8217;s stop for a second &#8211; so that I can explain something you might run into when building an MPLS network.  Let&#8217;s say you expected to see a MPLS neighbor after everything was configured, but when you issued the <b>show mpls ldp neighbor</b> command, the expected neighbor wasn&#8217;t there.  So, you go back and issue the command: <b>show mpls ldp discovery all</b> to verify local LDP communications and the output looked something like this:</p>
<p>
<pre>
r3#show mpls ldp discovery all
 Local LDP Identifier:
    10.254.1.3:0
    Discovery Sources:
    Interfaces:
FastEthernet1/0 (ldp): xmit/recv
    LDP Id: 10.254.1.4:0; no route
FastEthernet1/1 (ldp): xmit/recv
    LDP Id: 10.254.1.1:0</pre>
</p>
<p>In this previous example, the neighbor that is not being established is the one directly connected to FastEthernet1/0.  As you can see from the output, we are sending and receiving LDP messages; but no neighbor relationship.  The LDP Id of the neighbor we want to establish is 10.254.1.4, we can&#8217;t establish it because of the following:</p>
<p>
<pre>
FastEthernet1/0 (ldp): xmit/recv
    LDP Id: 10.254.1.4:0; no route
</pre>
</p>
<p> The output shows we have no route to 10.254.1.4.  In this case, the reason we don&#8217;t have a route to it is because our underlying interior routing protocol was not configured properly.  An LDP neighbor can&#8217;t be established if it doesn&#8217;t have a route to the IP address used for the LDP ID.  So, if the LDP ID was the IP address of the locally connected interface &#8211; there wouldn&#8217;t be a problem, since we would have a route to it.  I mention this so that you can watch out for underlying routing issues when trying to establish LDP neighbor relationships.</p>
<p>The last thing we want to do here is a verbose traceroute to actually see the MPLS tags used in the path.  For this example, we will issue a traceroute from R4 in our configured network:</p>
<p>
<pre>
r4#traceroute
Protocol [ip]:
Target IP address: 10.254.1.1
Source address: 10.254.1.4
Numeric display [n]:
Timeout in seconds [3]:
Probe count [3]:
Minimum Time to Live [1]:
Maximum Time to Live [30]:
Port Number [33434]:
Loose, Strict, Record, Timestamp, Verbose[none]: V
Loose, Strict, Record, Timestamp, Verbose[V]:
Type escape sequence to abort.
Tracing the route to 10.254.1.1

  1 10.1.1.9 [MPLS: Label 18 Exp 0] 392 msec
    10.1.1.13 [MPLS: Label 18 Exp 0] 396 msec
    10.1.1.9 [MPLS: Label 18 Exp 0] 508 msec
  2 10.1.1.1 156 msec
    10.1.1.5 232 msec
    10.1.1.1 240 msec
r4#
</pre>
</p>
<p>OK, what did we discover?  First let&#8217;s look at the traceroute issued, which was to the opposite corner of the network.  Just by looking at the drawing, we can tell the traceroute has to go through one of two devices (r2 or r3) in order to get to it&#8217;s destination (r1).  We are going to issue an extended traceroute to R1&#8242;s loopback address using our loopback (of r4) as the source.  As you can see from the output of the traceroute, label id 18 was assigned to our traceroute packet before it was switched to the destination.</p>
<p>How are we doing so far?  Let&#8217;s take a break and pick it up in the third article in this series, where we will add the PE (Provider Edge) devices and begin talking about VRF&#8217;s.  If you have any questions or comments please leave them in the comment section below and I will answer asap.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xpresslearn.com/cisco/mpls-cisco/configure-a-basic-mpls-network-ii/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Configure a Basic MPLS Network</title>
		<link>http://www.xpresslearn.com/cisco/mpls-cisco/configure-a-basic-mpls-network</link>
		<comments>http://www.xpresslearn.com/cisco/mpls-cisco/configure-a-basic-mpls-network#comments</comments>
		<pubDate>Wed, 09 Jun 2010 20:26:38 +0000</pubDate>
		<dc:creator>Scott Pilkinton</dc:creator>
				<category><![CDATA[MPLS]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Label Switching]]></category>
		<category><![CDATA[LDP]]></category>

		<guid isPermaLink="false">http://www.xpresslearn.com/?p=339</guid>
		<description><![CDATA[In this article, which is part 1 of many, I would like to present how to build a basic MPLS network.  Whether you just wondered how your service providers network was built or if your considering an internal MPLS network inside your company, this information should help out.]]></description>
			<content:encoded><![CDATA[<p>In these articles, I would like to present how to build a basic MPLS network.  Whether you just wondered how your service providers network was built or if your considering an internal MPLS network inside your company, this information should help out.  As far as why you would want to build an MPLS network, I won&#8217;t go into much detail as this is more intended to show how to build and not why to build.  However, I will say the big reason to build an internal MPLS network is so that you can use MPLS based VPN&#8217;s using Virtual Route Forwarders or VRF.  That&#8217;s all I&#8217;ll mention on that, lets starting building a network.</p>
<p>I&#8217;ll be working with Cisco 7200 routers, since dynamips is being used as the platform.  We could just as easily use some of the other emulated hardware, but out of all the options available in dynamips &#8211; a 7200 is probably the closest to what you might see in the core of an MPLS network.  There are three terms that describe the type of MPLS device:</p>
<p><b>P</b> &#8211; <i>which is for Provider equipment</i><br />
<b>PE</b> &#8211; <i>which stands for Provider Edge</i><br />
<b>CE</b> &#8211; <i>which as you have probably already guessed, stands for customer edge.</i></p>
<p><span id="more-339"></span></p>
<p>As far as a provider network that you use for a company WAN solution, your equipment is obviously the CE device and the PE device is what directly connects you into the providers network.  The P devices is what you would consider the providers backbone and would never &#8216;see&#8217; or interface with that hardware.</p>
<p>In an internally built MPLS network, the premise (or remote office) routers would still be considered the CE equipment and the PE device would typically be in a company data-center serving in a traditional &#8216;distribution layer&#8217;.  The P devices in a corporate built MPLS network would be what connects multiple data-centers together.  For example, if you have two data-centers, then you would have at least one P device at each one that provides the connectivity between those two sites.  The type of hardware used for the P device would be something that supports MPLS label switching.  This could be 7200 routers, 7600 routers, a 6500 Multilayer Switch, or others.  There would be a PE device directly connected to the P devices at each of the two data-centers.  The PE device would be what represents your typical distribution layer, which could be a LAN distribution switch, or a WAN router, or both.  The CE equipment would be say a router at a remote branch office, which resides on the edge of a WAN.  The CE device could also be a firewall back in the data-center.  As you can see, there are many different configurations that one could encounter based on the needs of the company.  I have just tried to list a few of the more common scenarios, but by far is not an exhaustive list.</p>
<h3>A little about the lab</h3>
<p>As I mentioned earlier, we will be using Dynamips to provide the platform on which we will lab this exercise.  More specifically &#8211; GNS3, the all encompasing wrapper around dynamips (and now many other programs I might add) will be the tool of choice here.  At the end of this article, you will find an importable project that you can load directly into your own GNS3 installation.  However, to get the very most out of the exercise &#8211; I would recommend building the network out manually in GNS3, to get the complete feeling of the build.</p>
<h3>CompanyX network scenario</h3>
<p>CompanyX has two datacenters, that are connected by high speed point to point connections.  We have two 100Mbit connections between the datacenters, each one provided by a different commercial carrier.  Each datacenter has two &#8216;core&#8217; devices which will terminate a single 100Mbit connection.  The two core devices in each datacenter will have a local connection to each other, so that full connectivity can be maintained in the event one of the two metro connections are lost.  These &#8216;core&#8217; devices will serve as the &#8216;P&#8217; devices, which does nothing but what is called &#8216;label switching&#8217;.  By the time user traffic reaches these devices, they have labels appended to the packet headers and that is what is used to determine where to foward that traffic.  The concept here applies just like when Layer3 switching was introduced &#8211; it is much quicker to switch a packet than it is to route it.</p>
<h3>CompanyX network diagram containing P devices</h3>
<p><a href="http://www.xpresslearn.com/wp-content/uploads/MPLS.Core_.png"><img class="alignnone size-medium wp-image-347" title="CompanyX Dual Data Center Core" src="http://www.xpresslearn.com/wp-content/uploads/MPLS.Core_-300x141.png" alt="" width="300" height="141" /></a></p>
<p>The point to point connections are all /30 networks and using the 10.1.1.0 network.  All loopback addresses are assigned out of the 10.254.1.0 network as /32 or host addresses.</p>
<p>So, let&#8217;s dive in&#8230; Below you will find the basic GNS3 project information that is importable &#8211; otherwise use the diagram above to build out the network.</p>
<p>Here is the relevant configuration for each router:</p>
<p>
<pre>
hostname r1
!
interface Loopback1
 ip address 10.254.1.1 255.255.255.255
!
interface FastEthernet1/0
 description r2 f1/0
 ip address 10.1.1.1 255.255.255.252
!
interface FastEthernet1/1
 description r3 f1/1
 ip address 10.1.1.5 255.255.255.252
</pre>
</p>
<p>
<pre>
hostname r2
!
interface Loopback1
 ip address 10.254.1.2 255.255.255.255
!
interface FastEthernet1/0
 description r1 f1/0
 ip address 10.1.1.2 255.255.255.252
!
interface FastEthernet1/1
 description r4 f1/1
 ip address 10.1.1.13 255.255.255.252
</pre>
</p>
<p>
<pre>
hostname r3
!
interface Loopback1
 ip address 10.254.1.3 255.255.255.255
!
interface FastEthernet1/0
 description r4 f1/0
 ip address 10.1.1.9 255.255.255.252
!
interface FastEthernet1/1
 description r1 f1/1
 ip address 10.1.1.6 255.255.255.252
</pre>
</p>
<p>
<pre>
hostname r4
!
interface Loopback1
 ip address 10.254.1.4 255.255.255.255
!
interface FastEthernet1/0
 description r3 f1/0
 ip address 10.1.1.10 255.255.255.252
!
interface FastEthernet1/1
 description r2 f1/1
 ip address 10.1.1.14 255.255.255.252
</pre>
</p>
<p><a href='http://www.xpresslearn.com/wp-content/uploads/mpls-basic.zip.zip'>GNS3 project for basic MPLS build</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xpresslearn.com/cisco/mpls-cisco/configure-a-basic-mpls-network/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subnet Wall Chart</title>
		<link>http://www.xpresslearn.com/networking/subnet-wall-chart</link>
		<comments>http://www.xpresslearn.com/networking/subnet-wall-chart#comments</comments>
		<pubDate>Thu, 27 May 2010 17:30:53 +0000</pubDate>
		<dc:creator>Scott Pilkinton</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[CIDR]]></category>
		<category><![CDATA[netmask]]></category>
		<category><![CDATA[subnetting]]></category>

		<guid isPermaLink="false">http://www.xpresslearn.com/?p=318</guid>
		<description><![CDATA[Here is a wall chart for quick subnettting reference and an explanation of how the chart was created.]]></description>
			<content:encoded><![CDATA[<p>When working with IP addresses it is very handy to have a cheat sheet available in order to quickly calculate netmasks and for converting to/from CIDR notation.  So here is a quick chart that is printable for wall hanging.</p>
<p style="text-align: center;"></p>
<p style="text-align: center;"><a href="http://www.xpresslearn.com/wp-content/uploads/SubnetChart.png"><img class="size-medium wp-image-321 aligncenter" title="Subnet Chart from xpresslearn.com" src="http://www.xpresslearn.com/wp-content/uploads/SubnetChart-297x300.png" alt="Subnet Chart from xpresslearn.com" width="297" height="300" /></a></p>
<h2>Here is some explanation on how the chart is presented:</h2>
<p><span id="more-318"></span></p>
<p style="text-align: center;"></p>
<p> </p>
<p>The first row in the chart is the decimal representation of each placeholder in an 8 bit (binary) number.  This is pretty self explanatory, nothing so far that you would learn outside of math class.</p>
<p>The second row is the netmask equivalent for each decimal placeholder value. </p>
<p>Let&#8217;s start with a decimal representation of a subnet mask:</p>
<p>x.x.x.x &#8211; Where x equals a number between 0 and 255 &#8211; well, actually it can&#8217;t be any number between 0 and 255 when we are talking about netmasks.  To clarify, in a netmask, the x can only be one of the following numbers: 0, 128, 192, 224, 240, 248, 252, 254, or 255.  Each x represents one octect and we know (version 4) IP addresses and subnet masks each have a total of four octects.</p>
<p>The netmask value is the inverse value of the decimal number.  To come up with this value we take the number 256 (which is how many numbers we can get from a binary 8 bit number) and we subtract the decimal value from it and that gives us the netmask equivalent. </p>
<p>The same conversion in binary would look like the following:</p>
<p>The inverse value of 00001111 (which is a decimal 16)  would be 11110000 (a simple flip, ones become zeros and zeros become ones), which is a decimal 240.</p>
<p>The remainding lines represent the CIDR notation of a given netmask value.  The CIDR value represents how many binary ones are represented in a given netmask.  Let&#8217;s go back to the decimal representation of a netmask:</p>
<p>255.x.x.x &#8211; The class A boundary would be between the first and second octect.  There are inherantly 8 binary ones in this 32 bit binary number &#8211; before any additional subnetting is applied.<br />
255.255.x.x &#8211; The class B boundary would be between the second and third octect.  There are inherantly 16 binary ones in this 32 bit binary number &#8211; before any additional subnetting is applied.<br />
255.255.255.x &#8211; The class C boundary would be betwen the third and fourth octect.  There are inherantly 24 binary ones in this 32 bit binary number &#8211; before any additional subnetting is applied.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xpresslearn.com/networking/subnet-wall-chart/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>General Cisco Security Best Practices</title>
		<link>http://www.xpresslearn.com/cisco/general/general-cisco-security-best-practices</link>
		<comments>http://www.xpresslearn.com/cisco/general/general-cisco-security-best-practices#comments</comments>
		<pubDate>Mon, 25 Jan 2010 00:57:18 +0000</pubDate>
		<dc:creator>Scott Pilkinton</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.xpresslearn.com/?p=271</guid>
		<description><![CDATA[A list of commands for adding to your configuration template the next time you configure a Cisco device.]]></description>
			<content:encoded><![CDATA[<p>There are several general configuration items that should be configured on all Cisco devices running standard IOS.  Some layer2 only switches will ignore a few of the commands in this article that are layer3 specific.</p>
<p>The first place to start is with the service commands</p>
<pre>service password-encryption</pre>
<h3>Explanation:</h3>
<p>The router administrator will ensure passwords are not viewable when displaying the router configuration. Type 5 encryption must be used for the enable mode password.</p>
<pre>no service udp-small-servers
no service tcp-small-servers</pre>
<h3>Explanation:</h3>
<p>All IOS versions above 12.0 has small-servers disabled by default.  However, it is good to make sure these services didn&#8217;t get enabled somewhere along the way.  The commands above won&#8217;t show up in the configuration, since they are off by default.  Cisco IOS provides these &#8220;small services&#8221; which include echo, chargen, and discard.  These services are completely unnecessary to run on Cisco devices.</p>
<p><span id="more-271"></span></p>
<p style="text-align: center;"></p>
<pre>no service pad</pre>
<h3>Explanation:</h3>
<p>Packet Assembler Disassembler (PAD) is an X.25 component that is seldom used.  PAD acts like a multiplexer for the terminals. If enabled, it can render the device open to attacks.</p>
<pre>service tcp-keepalives-in</pre>
<h3>Explanation:</h3>
<p>Idle logged-in telnet sessions can be susceptible to unauthorized access and hijacking attacks. By default, routers do not continually test whether a previously connected TCP endpoint is still reachable. If one end of a TCP connection idles out or terminates abnormally, the opposite end of the connection may still believe the session is available. These “orphaned” sessions use up valuable router resources and can also be hijacked by an attacker. To mitigate this risk, routers must be configured to send periodic keep-alive messages to check that the remote end of a session is still connected. If the remote device fails to respond to the keep-alive message, the sending router will clear the connection and free resources allocated to the session.</p>
<pre>no service finger</pre>
<h3>Explanation:</h3>
<p>The IOS finger service supports the UNIX finger protocol, which is used for querying a host about the users that are logged on.  This would give potential attackers a head start by providing valid usernames for the device.</p>
<pre>no boot network
no service config</pre>
<h3>Explanation:</h3>
<p>The routers can find their startup configuration either in their own NVRAM or load it over the network via TFTP or Remote Copy (rcp).  Obviously, loading in from the network is taking a security risk. If the startup configuration was intercepted by an attacker, it could be used to either gain access to the router.</p>
<p>Next, let&#8217;s take a look at the various server services available in IOS.</p>
<pre>no ip http-server
no ip ftp-server
no ip tftp-server</pre>
<h3>Explanation:</h3>
<p>The services listed above are extremely insecure and serve very little useful purpose.  An ftp-server or tftp-server might be used in environments where you have one device that has a software image on it that you want to distribute to other reachable devices.  These other devices might not have connectivity to a centralized distribution server that would host images for software upgrades, therefore making it convenient to use a router in order to get the job done.  If these services are used, it should only be in a temporary capacity and need to be disabled before logging out of the device.</p>
<pre>no ip bootp server</pre>
<h3>Explanation:</h3>
<p>Bootp is a user datagram protocol (UDP) that can be used by Cisco routers to access copies of Cisco IOS Software on another Cisco router running the Bootp service. In this scenario, one Cisco router acts as a Cisco IOS Software server that can download the software to other Cisco routers acting as Bootp clients. In reality, this service is rarely used and can allow an attacker to download a copy of a routers Cisco IOS Software.</p>
<pre>no ip source-route</pre>
<h3>Explanation:</h3>
<p>Source routing is a feature of IP, whereby, individual packets can specify routes. This feature is used in several different network attacks.  The router should always control how traffic is routed as apposed to be told to trust a path that is provided from another source.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xpresslearn.com/cisco/general/general-cisco-security-best-practices/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Security Guides available from the DoD</title>
		<link>http://www.xpresslearn.com/security/security-guides-available-from-the-dod</link>
		<comments>http://www.xpresslearn.com/security/security-guides-available-from-the-dod#comments</comments>
		<pubDate>Wed, 12 Aug 2009 03:37:25 +0000</pubDate>
		<dc:creator>Scott Pilkinton</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Security Technical Implementation Guides]]></category>
		<category><![CDATA[STIG]]></category>

		<guid isPermaLink="false">http://www.xpresslearn.com/?p=246</guid>
		<description><![CDATA[Using Department of Defense security material that is freely available to anyone in order to secure your networks and host platforms]]></description>
			<content:encoded><![CDATA[<p>In corporate environments, I.T. professionals are constantly trying to adhere to the latest guidelines that apply to the line of business they are a part of.  Most organizations are guided by one or more of the following:  HIPPA (Healthcare), PCI (Credit Card Industry), and SOX among others.  These guidelines definitely overlap with each other in areas.  If your privileged enough to have to satisfy more than one of these governing bodies, many times an issue addressed in one will also address the same issue in another.  The overlap exists largely because all of these guidelines are based on &#8216;best practices&#8217;.  When you have a list of these best practices available to audit against, it allows you to score yourself before the formal audits happen that are required by the various governing bodies.  It is also wise to be aware of the best practices before implementing a new system, in order to prevent having to go back and revisit after the implementation.</p>
<p>The good news is there are resources available to anyone and are provided by Defense Information Systems Agency (DISA) which is a government agency that is part of the Department of Defense (DoD). These guides are separated into two different types: One set is called Security Technical Informational Guides (STIG) and the other is called Security Checklists.  These guides are developed to provide guidance for people who build and manage DoD networks.  They are also used in audits performed within Department of Defense networks.</p>
<p>None of the DoD offered materials has anything to do with HIPPA, PCI, SOX, etc. on the surface, but the thing they do have in common is they are focused on security best practices.  In my experience dealing with HIPPA, PCI, SOX, and DoD networks, using these guides as a reference to secure a network or platform will cover 90+% of anything that would come up in a HIPPA, PCI, or SOX audit.</p>
<p><span id="more-246"></span></p>
<p></p>
<p>These guides are available publicly to anyone and are considered unclassified material in their currently offered form.</p>
<p>Use the following link to browse the security checklists, find one that addresses your area of interest and download.  All unpacked files are in .pdf format.</p>
<p><a href="http://iase.disa.mil/stigs/checklist/index.html">http://iase.disa.mil/stigs/checklist/index.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xpresslearn.com/security/security-guides-available-from-the-dod/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cisco TACACS server for Windows v2</title>
		<link>http://www.xpresslearn.com/tools/software-tools/cisco-tacacs-server-for-windows-v2</link>
		<comments>http://www.xpresslearn.com/tools/software-tools/cisco-tacacs-server-for-windows-v2#comments</comments>
		<pubDate>Sun, 12 Apr 2009 02:52:44 +0000</pubDate>
		<dc:creator>Scott Pilkinton</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Cisco ACS]]></category>
		<category><![CDATA[tacacs windows]]></category>
		<category><![CDATA[tacacs+]]></category>
		<category><![CDATA[tac_plus]]></category>

		<guid isPermaLink="false">http://www.xpresslearn.com/?p=223</guid>
		<description><![CDATA[Have you wanted to run a tacacs+ server on Windows, but didn't have the budget for Cisco ACS or another commercial TACACS+ server?  Cisco offers the source code to a freeware version of tacacs+.  However, the code has typically been compiled for Unix platforms and other related variants.  This is version 2 of a previous version posted on this site.]]></description>
			<content:encoded><![CDATA[<p>Finally, an update (well, sort of) to the Cisco TACACS server for Windows that was provided <a href="http://www.xpresslearn.com/tools/software-tools/cisco-tacacs-server-for-windows">here</a>.  The first version provided on this site was compiled from the original 4.0.4 Cisco version of tac_plus.</p>
<p>This version is actually based on 4.03, but has many added features that doesn&#8217;t exist in the 4.0.4 Cisco release.  The version given to this particular code distribution is F4.0.3.alpha-9a.</p>
<p>It runs just like the other version, (yes, with all the same qwerks as well) with additional options available to you.</p>
<p style="text-align: center;"></p>
<p style="text-align: left;"><span id="more-223"></span></p>
<p><a href="http://www.xpresslearn.com/wp-content/uploads/2009/04/tacacs.zip">Cisco tacacs+ server for Windows</a></p>
<p>Have fun, and if you successfully use any of the additional features &#8211; be sure to post a comment to let me and others know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xpresslearn.com/tools/software-tools/cisco-tacacs-server-for-windows-v2/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Network link redundancy using BVI</title>
		<link>http://www.xpresslearn.com/cisco/general/network-link-redundancy-using-bvi</link>
		<comments>http://www.xpresslearn.com/cisco/general/network-link-redundancy-using-bvi#comments</comments>
		<pubDate>Mon, 10 Nov 2008 03:53:01 +0000</pubDate>
		<dc:creator>Scott Pilkinton</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[bvi]]></category>
		<category><![CDATA[redundant link]]></category>

		<guid isPermaLink="false">http://www.xpresslearn.com/?p=222</guid>
		<description><![CDATA[Cisco devices functioning as a gateway can have link redundancy without running routing protocols.  Configuring Integrated Routing and Bridging allows two interfaces to be bridged together along with an associated virtual interface that serves as the routed interface.]]></description>
			<content:encoded><![CDATA[<p>When designing a robust network, the requirement that should make the top of the list is redundancy.  Most of the time, this is pretty easy.  When linking switches together, connect multiple links.  When connecting servers to the network, using multiple network adapters with teaming is the norm.  Connecting more than one interface on a router for redundancy is usually a little different.  Most of the time, you would take two interfaces on a router and assign an IP network to each and use a routing protocol for interacting with other connected routers for link selection.  However, there are some devices that are router types that don&#8217;t perform routing functions. </p>
<p>IOS devices functioning as some type of gateway comes to mind as a type of device that won&#8217;t route traffic &#8211; however network redundancy to the device is still desired.  In this example, a Cisco VG224 is used in a network to provide dial tone to analog devices over an IP network.  The VG224 gateway has multiple interfaces and does have the ability to run a routing protocol for reachability, but would be considered a bloated solution just to provide redundant network connections to the device.</p>
<p>In this example, we will accomplish network link redundancy by using a feature called Integrated routing and bridging or IRB for short.  In an IRB configuration, multiple physical interfaces are assigned to a common bridge group.  The two interfaces then form a bridge what communicates with a bridge virtual interface.  The device IP address then gets assigned to the virtual interface.</p>
<p><span id="more-222"></span></p>
<p style="text-align: center;"></p>
<p>As with any bridge, loop detection is necessary to prevent problems in the network.  Spanning tree is configured on the specific bridge which will communicate with the connected access switches.  In this particular scenario, we would never want this bridge to become the root for the connected network.  Therefore it is important to specify a priority, even though it is optional, to influence the root bridge selection process.</p>
<p>To get started, specify a bridge number and spanning tree protocol used. The ieee option is the only real valid choice here, which is the 802.1D standard spanning tree.</p>
<pre>GW-VG224-01(config)#bridge 1 protocol ?
  dec          DEC protocol
  ibm          IBM protocol
  ieee         IEEE 802.1 protocol
  vlan-bridge  vlan-bridge protocol

GW-VG224-01(config)#bridge 1 protocol ieee</pre>
<p>Every bridge that participates in a spanning-tree domain goes through the root bridge election process. Specify the highest bridge priority for influencing the election process to not select this device as a root bridge:</p>
<pre>GW-VG224-01(config)#bridge 1 priority ?
  &lt;0-65535&gt;  Priority (low priority more likely to be root)

GW-VG224-01(config)#bridge 1 priority 65535</pre>
<p>This device in this example has two Fast Ethernet interfaces. Assign both of these physical interfaces to the bridge group number previously assigned:</p>
<pre>GW-VG224-01(config)#int fa0/0
GW-VG224-01(config-if)#bridge-group 1
GW-VG224-01(config-if)#int fa0/1
GW-VG224-01(config-if)#bridge-group 1</pre>
<p style="text-align: center;"></p>
<p>Specify the use of irb:</p>
<pre>GW-VG224-01(config)#bridge ?
  &lt;1-255&gt;            Bridge Group number for Bridging.
  crb                Concurrent routing and bridging
  irb                Integrated routing and bridging
  mac-address-table  MAC-address table configuration commands

GW-VG224-01(config)#bridge irb</pre>
<p>Enter interface configuration mode for the virtual interface that is created. This interface is where the layer3 configuration goes:</p>
<pre>GW-VG224-01(config)#int bvI ?
  &lt;1-255&gt;  BVI interface number

GW-VG224-01(config)#int bvI 1
GW-VG224-01(config-if)#ip address 10.32.16.20 255.255.255.0</pre>
<p>Traffic will not be forwarded until the bridge is configured to route the IP traffic through this virtual bridge.</p>
<pre>GW-VG224-01(config)#bridge 1 route ?
  ip  IP
GW-VG224-01(config)#bridge 1 route ip</pre>
<p>Lastly, take the physical interfaces out of shutdown mode:</p>
<pre>GW-VG224-01(config-if)#int fa0/0
GW-VG224-01(config-if)#no shut
GW-VG224-01(config-if)#int fa0/1
GW-VG224-01(config-if)#no shut</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.xpresslearn.com/cisco/general/network-link-redundancy-using-bvi/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Upgrade to a modular IOS image</title>
		<link>http://www.xpresslearn.com/cisco/switching/upgrade-to-a-modular-ios-image</link>
		<comments>http://www.xpresslearn.com/cisco/switching/upgrade-to-a-modular-ios-image#comments</comments>
		<pubDate>Thu, 16 Oct 2008 02:52:55 +0000</pubDate>
		<dc:creator>Scott Pilkinton</dc:creator>
				<category><![CDATA[Switching]]></category>
		<category><![CDATA[6500]]></category>
		<category><![CDATA[IOS]]></category>
		<category><![CDATA[Modular]]></category>

		<guid isPermaLink="false">http://www.xpresslearn.com/?p=200</guid>
		<description><![CDATA[Cisco IOS Software Modularity is available for the two newest Supervisor modules, the Sup720 and Sup32,  which go into the Cisco 6500 series platform.  Basically, by using the modular IOS, the switch runs more efficiently.  This is accomplished by splitting up major components inside the IOS into separate subsystems, which will run in different processes. [...]]]></description>
			<content:encoded><![CDATA[<p>Cisco IOS Software Modularity is available for the two newest Supervisor modules, the Sup720 and Sup32,  which go into the Cisco 6500 series platform.  Basically, by using the modular IOS, the switch runs more efficiently.  This is accomplished by splitting up major components inside the IOS into separate subsystems, which will run in different processes.  The modularity also allows the patching of portions of the IOS, without having to install an entirely new IOS.  Think about this: How many times have you installed a new IOS image to fix a specific bug, but the new software caused a problem in another area that was previously not broken?  Now, fixing issues by only patching the part of the software with a problem helps insure the rest of the device&#8217;s operation will continue to operate as it did in the past.</p>
<p>A new feature that comes along with the modular image is the inclusion of Cisco Embedded Event Manager (EEM).  This feature allows the EEM process to &#8216;catch&#8217; a defined event and then spawn an action from that raised event.  For example, the device can generate and send an email when the CPU goes over a certain percentage for a period that is longer than a defined threshold.  The engine behind this functionality is controlled using the Python scripting language.  Using Python to write these embedded event handlers provides some powerful capabilities at your fingertips.<br />
<span id="more-200"></span></p>
<p style="text-align: center;"></p>
<p>This article wasn&#8217;t really intended to help you decide on using the IOS modularity option, but to explain the upgrade/conversion process.  The first thing to do is obtain the proper image from CCO.  The modular version has the same feature sets and versions available just like the native IOS versions do.  Just pick the right modular image based on your hardware and services needed just like you would any other time.</p>
<p>Once you have downloaded the image, upload it to storage that is available on the (primary) supervisor.  Before the &#8216;installation&#8217; of the modular IOS, the supervisor has to boot from it first, like it would any other image.  In fact, the switch can load the modular IOS .bin file and run just like it was the non-modular version.  However, this would defeat the purpose, since patching is not available until the installation has been performed and the system rebooted.</p>
<p>Put a boot statement in the configuration pointing it to the .bin file that was just uploaded to storage and reload the switch.  Once the switch is back up running on the new image here is where it starts to get fun&#8230;</p>
<p>Let&#8217;s look at the output of the <strong>show version</strong> command after the switch has booted the new IOS image:</p>
<pre>6500switch#sh version
Cisco IOS Software, s72033_rp Software (s72033_rp-ADVIPSERVICESK9_WAN-VM),
Version 12.2(33)SXH3a, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2008 by Cisco Systems, Inc.
Compiled Wed 24-Sep-08 14:37 by prod_rel_team

ROM: System Bootstrap, Version 12.2(17r)SX5, RELEASE SOFTWARE (fc1)

6500switch uptime is 14 hours, 53 minutes
Uptime for this control processor is 14 hours, 52 minutes
Time since 6500switch switched to active is 14 hours, 52 minutes
System returned to ROM by reload at 23:22:24 CDT Tue Oct 14 2008
 (SP by reload)
System image file is "disk0:s72033-advipservicesk9_wan-vz.122-33.SXH3a.bin"

cisco WS-C6506-E (R7000) processor (revision 1.1) with
516096K/8192K bytes of memory.
SR71000 CPU at 600Mhz, Implementation 1284, Rev 1.2, 512KB L2 Cache
Last reset from s/w reset
1 Virtual Ethernet interface
52 Gigabit Ethernet interfaces
1917K bytes of non-volatile configuration memory.

65536K bytes of Flash internal SIMM (Sector size 512K).
Configuration register is 0x2102

Patching is not available since the system is not running from an
installed image. To install please use the "install file" command</pre>
<p>Take a look at the last couple of lines of the output. This output is telling you to run the &#8216;install file&#8217; command in order to install the image. The installation procedure creates a directory structure on the file system specified in the install command. In this example, the image is running from flash installed in slot0:, which is known to the switch as disk0:. We are going to install onto the sup-bootdisk0: flash, which is an compact flash module installed internally with a <a href="http://www.cisco.com/en/US/docs/switches/lan/catalyst6500/hardware/Config_Notes/78_17277.html">compact flash adapter</a> that replaces the SP bootflash on the supervisor. Cisco recommends the modular installation use internal storage, because it is too easy to eject the flash from the slots on the front of the supervisor &#8211; which would cause the switch to crash.<br />
<!--more--></p>
<p style="text-align: center;"></p>
<p>The command to start the process will be: <strong>install file disk0:s72033-advipservicesk9_wan-vz.122-33.SXH3a.bin sup-bootdisk0:/sys</strong> . The syntax is basically the source image to use then the destination. Notice the /sys at the end of the destination, which is a required argument and is called the search root. The search root is basically just a top level directory and valid entries are: sys|newsys|oldsys .  Below is a normal output during the installation:</p>
<pre>6500switch#install file disk0:s72033-advipservicesk
9_wan-vz.122-33.SXH3a.bin sup-bootdisk:/sys
Source filename [s72033-advipservicesk9_wan-vz.122-33.SXH3a.bin]?
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Verifying checksums of extracted files

Verifying installation compatibility

Finalizing installation ...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Computing and verifying file checksums
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Writing installation meta-data.  Please wait ...

NOTE: The newly added base image is not yet active.
      To activate the new base image, perform an 'install bind' in
      config mode followed by a 'reload'.

[DONE]

6500switch#</pre>
<p>The last thing you see is a note on how to activate the new base image.  The correct command in this example is: 6509switch(config)#<strong>install bind sup-bootdisk:/sys</strong> .  Notice this command is done from configuration mode.  This command basically just adds a boot statement in the switch configuration pointing to the new modular image.  Here is the output from the install bind command:</p>
<pre>6500switch(config)#install bind sup-bootdisk:/sys
WARNING: This system is running in a redundant mode.  However, the specified
search root on the Standby does not contain installed software, or is unavailable.
Unless the proper software is installed on the Standby,
it will not boot from this binding</pre>
<p>The message we received above was due to the fact the example system was running dual supervisor modules.  If you have a single supervisor, this message will not display.  In order to get the installation onto the redundant supervisor, the process is a little simpler.  There is a copy command that will copy the existing installation on sup-bootflash0:/sys to the redundant supervisor&#8217;s file system.  The following is all that is required to insure the secondary supervisor can boot successfully:</p>
<pre>6500switch#install copy sup-bootdisk:/sys slavesup-bootdisk:/sys
Copying installed software at sup-bootdisk:/sys to slavesup-bootdisk:/sys
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[DONE]</pre>
<p>A look at the running configuration shows the following:</p>
<pre>6500switch#show run</pre>
<pre>boot-start-marker
boot system flash disk0:s72033-advipservicesk9_wan-vz.122-33.SXH3a.bin
boot system flash sup-bootdisk:
boot system sup-bootdisk:/sys/s72033/base/s72033-advipservicesk9_wan-vm
boot-end-marker</pre>
<p>As you can see, the install bind command will not remove any of the previous boot statements.  In all the upgrades I have performed so far, I have went ahead and removed all the old boot statements, just to make sure the supervisor boots correctly.</p>
<pre>6500switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
6500switch(config)#no boot system flash disk0:s72033-advipservicesk9_wan-vz.122-33.SXH3a.bin
6500switch(config)#no boot system flash sup-bootdisk:
6500switch(config)#end
6500switch#wr
Building configuration...
[OK]
6500switch#sh boot
BOOT variable = sup-bootdisk:/sys/s72033/base/s72033-advipservicesk9_wan-vm,12;
CONFIG_FILE variable =
BOOTLDR variable =
Configuration register is 0x2102

Standby is up
Standby has 524288K/8192K bytes of memory.

Standby BOOT variable = sup-bootdisk:/sys/s72033/base/s72033-advipservicesk9_wan-vm,12;
Standby CONFIG_FILE variable =
Standby BOOTLDR variable =
Standby Configuration register is 0x2102</pre>
<p>The last thing to do is reload the switch:</p>
<pre>6500switch#reload
Proceed with reload? [confirm]</pre>
<p>Once the switch is back up, the output of show version now looks like:</p>
<p><!--more--></p>
<p style="text-align: center;"></p>
<pre>6500switch# sh ver
Cisco IOS Software, s72033_rp Software (s72033_rp-ADVIPSERVICESK9_WAN-VM),
 Version 12.2(33)SXH3a, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2008 by Cisco Systems, Inc.
Compiled Wed 24-Sep-08 14:37 by prod_rel_team

ROM: System Bootstrap, Version 12.2(17r)SX5, RELEASE SOFTWARE (fc1)

 6500switch uptime is 8 minutes
Uptime for this control processor is 7 minutes
Time since 6500switch switched to active is 7 minutes
System returned to ROM by reload at 15:07:48 CDT Wed Oct 15 2008 (SP by reload)
System image file is "sup-bootdisk:/sys/s72033/base/s72033-advipservicesk9_wan-vm"

cisco WS-C6506-E (R7000) processor (revision 1.1) with 516096K/8192K bytes of memory.
SR71000 CPU at 600Mhz, Implementation 1284, Rev 1.2, 512KB L2 Cache
Last reset from s/w reset
1 Virtual Ethernet interface
52 Gigabit Ethernet interfaces
1917K bytes of non-volatile configuration memory.

65536K bytes of Flash internal SIMM (Sector size 512K).
Configuration register is 0x2102

System is currently running from installed software
For further information use "show install running"</pre>
<p>To look at the actual software versions along with any patch information, issue the <strong>show install running</strong> command:</p>
<pre>6500switch#show install running

B/P C State     Filename
--- - --------  --------

Software running on card installed at location s72033_rp - Slot 6 :
 B    Active    slavesup-bootdisk:/sys/s72033_rp/base/DRACO2_MP

Software running on card installed at location s72033 - Slot 5 :
 B    Active    sup-bootdisk:/sys/s72033/base/s72033-advipservicesk9_wan-vm -
Version 12.2(33)SXH3a

Software running on card installed at location s72033_rp - Slot 5 :
 B    Active    sup-bootdisk:/sys/s72033_rp/base/DRACO2_MP

Software running on card installed at location c2_lc - Slot 1 :
 B    Active    sup-bootdisk:/sys/c2_lc/base/C2LC

Software running on card installed at location s72033 - Slot 6 :
 B    Active    slavesup-bootdisk:/sys/s72033/base/s72033-advipservicesk9_wan-vm -
Version 12.2(33)SXH3a

LEGEND:
-------:
B/P/MP - (B)ase image, (P)atch, or (M)aintenance (P)ack
'C' - (C)ommitted
Pruned - This file has been pruned from the system
Active - This file is active in the system
PendInst - This file is set to be made available to run on the
   system after next activation.
PendRoll - This file is set to be rolled back after next activation.
InstPRel - This file will run on the system after next reload
RollPRel - This file will be removed from the system after next reload
RPRPndIn - This file is both rolled back pending a reload, and pending
   installation.  On reload, this file will not run and will move to
   PendInst state.  If 'install activate' is done before reload, pending
   removal and install cancel each other and file simply remains active
IPRPndRo - This file is both installed pending a reload, and pending rollback.
   If the card reloads, it will be active on the system pending a rollback
   If 'install activate' is done before a reload, the pending install and
   removal with cancel each other and the file will simply be removed
Occluded - This file has been occluded from the system,
   a newer version of itself has superceded it.

6500switch#</pre>
<p>All things considered, this is a pretty easy upgrade &#8211; just take your time and make sure each step is followed carefully. I would recommend allocating 1.5 hours for the first upgrade performed. Once you&#8217;re familiar with the process, it can be done in half that time and even quicker if the image is transferred to a filesystem on the switch prior to performing the upgrade.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xpresslearn.com/cisco/switching/upgrade-to-a-modular-ios-image/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Automate Cisco commands from Windows</title>
		<link>http://www.xpresslearn.com/cisco/general/automate-cisco-commands-from-windows</link>
		<comments>http://www.xpresslearn.com/cisco/general/automate-cisco-commands-from-windows#comments</comments>
		<pubDate>Tue, 07 Oct 2008 01:40:54 +0000</pubDate>
		<dc:creator>Scott Pilkinton</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[automate]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[plink]]></category>
		<category><![CDATA[putty]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.xpresslearn.com/?p=150</guid>
		<description><![CDATA[Use plink to automate sending commands and receiving information from your telnet and ssh sessions.  This article will show you how to use plink to gather the configuration from an IOS device.]]></description>
			<content:encoded><![CDATA[<p>In the previous article, <a title="Permanent Link to Running commands on a Cisco device from the Windows command line" rel="bookmark" href="http://www.xpresslearn.com/cisco/running-commands-on-a-cisco-device-from-the-windows-command-line">Running commands on a Cisco device from the Windows command line</a> , I wrote on how to run commands from the Windows command line against a Cisco device.  The article was based on using the Unix utility rsh aka Remote Shell.  The biggest downfall of using rsh is the security issues around the protocol.  How about another method of doing the same thing, but with using a more secure process?</p>
<p>Putty has a sister program that is called plink.  Like putty, plink is a standalone executable that is capable of accessing remote devices using telnet or ssh.  Plink is basically used in place of putty when you want the input/output of the program to use STDIN/STDOUT.  So, for example you can open a command prompt, invoke plink and connect to a device.  The interaction with the session will look just as if it would when using the telnet.exe from the XP/Vista command line.  One of the features of plink is that it can share the saved sessions created in Putty.  By default, putty will use the Windows registry to store saved connection information.  However, the configuration can be changed to store the sessions in the local file system.</p>
<p>In this initial example, lets configure a router to accept an incoming ssh connection with a locally defined username/password combination.  The basic IOS configuration to accomplish this task will look like the following:<br />
<span id="more-150"></span></p>
<p></p>
<pre>
R1(config)#int fa0/0
R1(config-if)#ip address 10.1.100.1 255.255.255.0

<strong>! Define the hostname on the router - required for enabling ssh</strong>
Router(config)#hostname R1

<strong>! Define the domain name on the router - required for enabling ssh</strong>
R1(config)#ip domain-name xpresslearn.com

<strong>! Generate encryption keys for use with ssh</strong>
R1(config)#crypto key generate rsa general-keys
The name for the keys will be: R1.xpresslearn.com
Choose the size of the key modulus in the range of 360 to 2048 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minutes.
How many bits in the modulus [512]:
% Generating 512 bit RSA keys, keys will be non-exportable...[OK]

<strong>! Use the latest version of ssh</strong>
R1(config)#ip ssh version 2

<strong>! Locally defined username on the router</strong>
R1(config)#username xpresslearn privilege 15 secret pa55w0rd

<strong>! Enable aaa</strong>
R1(config)#aaa new-model

<strong>! Set all logins by default to use the local username entries</strong>
R1(config)#aaa authentication login default local

<strong>! Use the priviledge level defined in the local username statement</strong>
R1(config)#aaa authorization exec default local</pre>
<p>Now, from the command line, let&#8217;s use the plink.exe program to show the interfaces of the Cisco device. But first, lets take a look at the options available from the plink executable:</p>
<div id="attachment_161" class="wp-caption aligncenter" style="width: 457px"><a href="http://www.xpresslearn.com/wp-content/uploads/2008/09/plink-options.gif"><img class="size-full wp-image-161" title="Plink command options" src="http://www.xpresslearn.com/wp-content/uploads/2008/09/plink-options.gif" alt="Command line options for plink.exe" width="447" height="481" /></a><p class="wp-caption-text">Command line options for plink.exe</p></div>
<p>As you can see, one of the options is a -m to run remote commands from a file.  In order to automatically run commands without interaction, the commands you want to run need to be inserted into a text file.</p>
<div id="attachment_163" class="wp-caption aligncenter" style="width: 355px"><a href="http://www.xpresslearn.com/wp-content/uploads/2008/09/plink-commands.gif"><img class="size-full wp-image-163" title="Automating commands in Cisco IOS for use with Plink" src="http://www.xpresslearn.com/wp-content/uploads/2008/09/plink-commands.gif" alt="Text file to use with plink.exe" width="345" height="326" /></a><p class="wp-caption-text">Text file to use with plink.exe</p></div>
<p>Now, run the program with the proper command line options.  Which in the following example is:</p>
<p>- Use ssh to connect<br />
- Connect with the username xpresslearn<br />
- The IP address of the device we are connecting is 10.1.100.1<br />
- use the password pa55w0rd<br />
- run the commands contained in the file called plink-commands.txt that resides in the current directory.</p>
<div id="attachment_166" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.xpresslearn.com/wp-content/uploads/2008/09/plink-batch.gif"><img class="size-full wp-image-166" title="Running plink.exe in batch mode" src="http://www.xpresslearn.com/wp-content/uploads/2008/09/plink-batch.gif" alt="Running plink.exe in batch mode" width="500" height="195" /></a><p class="wp-caption-text">Running plink.exe in batch mode</p></div>
<p>As you can see, the output from the command is displayed as standard program output.  This output can just as easily be piped to a text file.  Next, let&#8217;s use this method to back up the configuration of the router.  First, we will put the proper commands in the text file for batch processing.</p>
<div id="attachment_168" class="wp-caption aligncenter" style="width: 358px"><a href="http://www.xpresslearn.com/wp-content/uploads/2008/09/plink-commands2.gif"><img class="size-full wp-image-168" title="Plink commands for configuration backup" src="http://www.xpresslearn.com/wp-content/uploads/2008/09/plink-commands2.gif" alt="Backup cisco configuration via plink.exe" width="348" height="330" /></a><p class="wp-caption-text">Backup cisco configuration via plink.exe</p></div>
<p>Now, run plink.exe with the same command line options and add the pipe to end:</p>
<div id="attachment_169" class="wp-caption aligncenter" style="width: 509px"><a href="http://www.xpresslearn.com/wp-content/uploads/2008/09/plink-batch2.gif"><img class="size-full wp-image-169" title="Router backup via Plink" src="http://www.xpresslearn.com/wp-content/uploads/2008/09/plink-batch2.gif" alt="Router backup using plink.exe" width="499" height="553" /></a><p class="wp-caption-text">Router backup using plink.exe</p></div>
<p>So we ran plink with the commands in the text file and piped them to a file called R1.txt.  In the above screen shot, you can see where we view the text file after the program has executed.  The text file contains the complete configuration of the device, which was displayed using the show run command.  FYI: the term length 0 command is used to prevent paging when showing the running configuration.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xpresslearn.com/cisco/general/automate-cisco-commands-from-windows/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
