OpenWrt Forum Archive

Topic: Basic tftp failure

The content of this topic has been archived on 30 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Dear All,

I've not got very far trying to install OpenWRT, because I can't get tftp to work.  Here's what I've done; if anyone can spot my mistake I'd be very grateful.

I'm using a PC running Debian.  It is connected to the WRT54g's #1 LAN port, and I can ping it:

$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: icmp_seq=0 ttl=64 time=160.3 ms
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=2.2 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.2 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=1.3 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=1.2 ms

I then remove the power, and try tftp.  I've tried both the Debian tftp package, which I think is netkit, and the atftp package, following the instructions from the Wiki installation instructions.  They both fail in exactly the same way:

$ atftp --trace --option "timeout 1" --option "mode octet" --put --local-file openwrt-wrt54g-squashfs.bin 192.168.1.1
Trace mode on.
Option timeout = 1
Option mode = octet
sent WRQ <file: openwrt-wrt54g-squashfs.bin, mode: octet <timeout: 1>>
tftp: aborting

It fails immediately.  strace reveals this:

socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
bind(3, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0
getsockname(3, {sa_family=AF_INET, sin_port=htons(1781), sin_addr=inet_addr("0.0.0.0")}, [16]) = 0
connect(3, {sa_family=AF_UNSPEC, sa_data="\347\267T7\5\10hQ\5\10\0\0\0\0"}, 16) = 0
open("/tmp/openwrt-wrt54g-squashfs.bin", O_RDONLY) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=1573888, ...}) = 0
write(2, "sent WRQ <file: /tmp/openwrt-wrt"..., 76sent WRQ <file: /tmp/openwrt-wrt54g-squashfs.bin, mode: octet <timeout: 1>>
) = 76
sendto(3, "\0\2/tmp/openwrt-wrt54g-squashfs.b"..., 51, 0, {sa_family=AF_INET, sin_port=htons(69), sin_addr=inet_addr("192.168.1.1")}, 16) = -1 EPERM (Operation not permitted)

I get the same when I run atftp as root.  man sendto does not mention EPERM as a possible error return value.

I wondered if this was a firewall-like problem, but iptables -L shows that no filters are loaded.

I suspect that I've got something basic wrong, but can't work out what it is.  Does anyone have any suggestions for further debugging?  Has anyone else suceeded in using tftp from a Debain machine recently?

Cheers,

--Phil.

endecotp wrote:

$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: icmp_seq=0 ttl=64 time=160.3 ms
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=2.2 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.2 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=1.3 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=1.2 ms

I then remove the power, and try tftp.  I've tried both the Debian tftp package, which I think is netkit, and the atftp package, following the instructions from the Wiki installation instructions.  They both fail in exactly the same way:

You say you remove power but you don't say you reconnected power. I assume you just forgot to mention this? Is boot_wait set to on?

Void Main wrote:
endecotp wrote:

I then remove the power, and try tftp.  I've tried both the Debian tftp package, which I think is netkit, and the atftp package, following the instructions from the Wiki installation instructions.  They both fail in exactly the same way:

You say you remove power but you don't say you reconnected power. I assume you just forgot to mention this? Is boot_wait set to on?

I don't get as far as the point where I would reconnect the power.  Having started tftp I expect to see it retrying every second, waiting to find a live WRT; if it did that, I would then reconnect the power.  But it fails instantly and doesn't ever retry.

Yes, boot_wait is on - but again, I'm not getting as far as the point where that is relevent.

--Phil.

You don't want to start the tftp until after you are able to ping the router (right after power up). You won't even have a link on your ethernet interface with the power off (unless you have a switch between your machine and the router). You want to have the command ready, plug the power in, then execute the command.

Void Main wrote:

You don't want to start the tftp until after you are able to ping the router (right after power up). You won't even have a link on your ethernet interface with the power off (unless you have a switch between your machine and the router). You want to have the command ready, plug the power in, then execute the command.

Really?  That's not how I understand the instructions:
(http://openwrt.org/OpenWrtDocs/Installing)

    *  unplug the power to your router
    *  start your tftp client
          o  give it the router's address (usually 192.168.1.1)
          o  set mode to octet
          o  tell the client to resend the file, until it succeeds.
          o  put the file
    * plug your router, while having the tftp client running and constantly probing for a connection
    * the tftp client will receive an ack from the bootloader and starts sending the firmware

OK, finally fixed.  It was a firewall problem on the machine from which I was running the tftp.  In case anyone else suffers from this, here is what I believe will thoroughly disable any firewall blocking:

iptables -F
iptables -X
iptables -P INPUT ALLOW
iptables -P OUTPUT ALLOW

Note, though, that your firewall may get re-enabled each time you ifup an interface.  I suggest checking with iptables -L before you try the tftp.  I now have a functional OpenWRT'd WRT54g.

A couple of other random hints:
* when editing files in /etc, check the permissions.
* dnsmasq doesn't seem to like comments at end of line, e.g. appending hostnames as comments in /etc/ethers.

Many thanks to everyone who has helped to make this work.

--Phil.

The discussion might have continued from here.