Hi i want to read the configuration stored in cisco router without using puTTY or hyper terminal (serial interface) purely using C# and retrieve the configuration files. is this possible?
What you need is to import the config file via tftp and then read it within your code.
Here is a link for simple TFTP client on C#
There are a lot of sample codes on the internet which you can use. There is no built-in TFTP support in C# and you have to create your own class to do it.
The following example shows how to download a remote file "config" from a tftp server located at 192.168.1.10:69, and name the local file "config.txt".
new IPEndPoint(IPAddress.Parse("192.168.1.10"), 69),
I assume your method is to use tftp cilent to grab the file from the tftp server using c#? what I'm doing is I want to grab the configuration file from the router itself using C# without going in the router (putty or hyperterminal) and use the command running-config tftp and put in the Cisco tftp server and grab it. I'm still a newbie in programming hope you can understand
With thies method you can grab the file directly from your router. You need to configure your router as TFTP server first as below:
Router(config)#tftp-server nvram:startup-config alias config
Then you can grab config file directly from your router.
As Joseph mentioned you can try SNMP as well but I think you need a system which is able to run snmpset command. Here is a link to cisco website for this:
Remember no matter what method you use to grab the config file you need to make it as secure as possible. Like for SNMP use snmp v3 if possible or apply an ACL to tftp server and allow only your server to get the file.
Hi Reza Thanks for your reply and your kind assistance!
I have already key in this command: tftp-server nvram:startup-config alias config in my Cisco router. and now I think my router is in TFTP server. However may i ask normally if i want to use command: copy running-config tftp i need to be in
privilege mode so i want to ask the C# program has the right to go in the router to grab the config file?
And also, I found this website http://www.c-sharpcorner.com/UploadFile/shanesnedecor/TFTPTest11282005005441AM/TFTPTest.aspx this program also uses C# to get the config file but I don't know what is the text to key in into the 2 textbox which is the TFTP Server and File Name.
You are very welcome.
In reply to your first question the answer is "No". As soon as you enable tftp server on your router, you are allowing anyone to run tftp get command. If you want to try it you can setup Tftpd64 and try under "tftp client" tab page. If you fill-up host,port,local file and remote file and then click on Get it will go to your router and will download the file. You can control access with ACL and block un-authorized IPs.
Unfortunately I can't see the c# code in your link. I have to be a member of that site and I'm not. But if it's asking about your tftp server and file name then you can use your router IP as server IP and "config" for File name if you punched in the following command on your router:
tftp-server nvram:startup-config alias config
Hi Reza i have downloaded the software but i keep getting the error timeout waiting block #1 i think i show you image will be easier the host 192.168.1.2 (is my router fastEthernet 0/0) the server interfaces: 192.168.1.39 (this is my computer ip address) the port i assume TFTP is 69, the local file is i create a text file name "boon.txt" and the remote file is config the block size 512.
I think i show you my config file better you take a look am i on the correct track
Thank you reza!
Please check layer 3 conectivity between your router and computer. Also make sure windows firewall is off. Here is what I have on my computer:
10.10.1.125 is my computer
10.10.1.12 is my router.
Yes i did not connect to my router now my router connectivity is up but i encounter another error pls help!
Thanks for your help!
Hi Reza I'm using Symantec Endpoint Protection i've disabled all the anti virus as shown below
but the same error still appear. please help thank you!
I suspect something is closing the connection on your computer. The best way to check this to run wireshark and see if you receive any reset packet from your router. Then you can say it's either your router or computer. Easiest way is to test it with a computer with no AV and disabled firewall.
There is no special setting for this simple tftp file transfer and it should work!
May i ask how do i see is there any reset packet from my router using wireshark?
I see. So can i troubleshoot by using the FastEthernet 0/0 (192.168.1.2) to plug in directly to my computer NIC and try instead? basically no internet to use also if i do it this way.. pls advice.
Thanks for your help reza!
You must see something like this in your pcap file. RST flag means reset.
192.168.3.10 192.168.1.23 TCP [TCP ACKed lost segment] 8004 > 60179 [RST, ACK] Seq=1 Ack=45320348 Win=0 Len=0
Don't look for exact same output as it will be different only RST part will be the same. If you haven't played with wireshark before I don't recommend it as it might be confusing.
You don't need to plug in directly all you have to do is following:
1) Use another computer with no AV installed.
2) Disable firewall.
3) Make sure you can reach the router IP.
4) Try tftpd64 again.
all the computers in my lab has AV installed and firewall enabled. I tried the solution you give but could not work
I also tried using cross cable to plug the router to my computer also encounter the same error.is there anyway i could check the port 69 is it block by the firewall? or is there any other solution you could advice?
The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.
In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.
You should be able to obtain the config directly from the device if you have SNMP enabled.