Cisco Router Logging DHCP Bindings to FTP Server [COULD NOT WRITE DATABASE HEADER]

ciscodhcprouter

Today I was working on my home lab for practice. I wanted to set my 2800 Series Cisco router to send a log of DHCP bindings to a FTP server on the local network (raspberry pi operating as sftp server, it is also serving as a wireless access point).

I downloaded FileZilla on my PC and confirmed my sftp server was working on the raspberry pi. DHCP is working properly on all of my vlans, including for hosts connected via the pi AP.

I set the commands…

ip dhcp database ftp://pi:raspberry@10.0.99.50/home/pi/Desktop/router-dhcp write-delay 60 timeout 15

(I tried using sftp:// and ftp:// and neither worked)

ip ftp source-interface Gi0/0.99

(pointing to the location of the ftp server, subinterface 99 (vlan 99))

Here are the logs I get with debug dhcp…

*May  5 21:48:46.678: DHCPD: writing bindings to ftp://pi:raspberry@10.0.99.50/home/pi/Desktop/router-dhcp.
*May  5 21:48:46.678: DHCPD: could not write database header.
*May  5 21:48:46.678: DHCPD: ifs_write failed (error 1545).

Here is the Info from [show ip dhcp database]…

 Router#show ip database ftp://pi:raspberry@10.0.99.50/home/pi/Desktop/router-dhcp
 URL      : ftp://pi:raspberry@10.0.99.50/home/pi/Desktop/router-dhcp
 Read     : Never
 Written  : Never
 Status   : Last write failed because of a protocol error.
 Delay    : 60  seconds
 Timeout  : 15  seconds
 Failures : 24
 Successes: 0

Any suggestions to my problem is greatly appreciated!


I have also seen this error message…
When the router attempts to write to the url of the ftp server, this is the first message shown after the attempt, and then it fails.

 DHCPD: ifs_open failed (error 19)

Best Answer

SFTP is - as far as I understand it - a bit complex to handle for a low-footprint client, requiring kinda two operation modes simultaneously - one interactive (shell-like, for commands and directory browsing etc), one for transfers (binary), much like classic FTP did. I have yet to come across an SFTP client on a "classical" IOS Router (recent "linux somewhere in there"-OSs like IOS-XE or NX-OS excluded).

However, SFTP has a simple sibling: SCP. Most SSH server implementations on "computers" support SCP quite nicely, and halfway recent cisco routers have an SCP client (and server, too; see below).

router6rd#copy vlan.dat scp://user@172.19.41.50/vlan.dat  
Address or name of remote host [172.19.41.50]?  
Destination username [user]? 
Destination filename [vlan.dat]?  
Writing vlan.dat  
Password: ..... 
 Sink: C0644 900 vlan.dat 
! 
900 bytes copied in 3.696 secs (244 bytes/sec)

Give it a try and see if the dhcp database command also accepts an scp://user:pw@host/path/file URI. There's a good chance that it will, if the given IOS version has an scp client.

side note / tech babble:

We regularely use scp from our management stations to upload IOS images to and crashdumps/showtechs etc from our remote Cisco boxes (ip scp server enable), where TFTP and FTP just won't cut it.

TFTP suffers immensely across WAN links (with 512bytes per packet, every single packet ACKd; a 500MB IOS Image takes a day to transfer...), and FTP always has the hassle of the reverse connections, availability or lack of passive/active mode support, and then there's the NAT/ALG problem for both of them and don't even get me started on the stubborn firewall admins that won't allow (T)FTP. (I am a firewall admin myself, so I do feel entitled to throw that stone ;-) )

With the SCP server on the Cisco, all you need is an SSH connection to the remote device. It offers TCP's reliability and window scaling capabilities, uses only a single port in one direction, fully NATtable, plays nicely with the firewall admins...

And with the SCP client on a Cisco, you can do some clever things as well.