Comment 5 for bug 1448500

Revision history for this message
Frans Oilinki (moilinki) wrote : Re: tftp-hpa doesn't accept IPv4 connections

It seems tftpd-hpa interprets option --address ::69 to mean that only listen on IPv6:
1. By default (with TFTP_ADDRESS="[::]:69") it is started as

    /usr/sbin/in.tftpd --listen --user tftp --address [::]:69 --secure --create /srv/tftp

2. netstat (command "sudo netstat -anutp | grep '[:]69'") shows:

        udp6 0 0 :::69 :::* 10681/in.tftpd

I do not know and I am not interested to check the source code if there is way to explicitly tell tftpd-hpa to listen on all interfaces, both IPv4 and IPv6, but if you just omit the --address option, tftpd-hpa - per netstat output - listens on all interfaces both IPv4 and IPv6; when I start tftp-hpa as "/usr/sbin/in.tftpd --listen --user tftp --secure --create /srv/tftp" then netstat shows

       udp 0 0 0.0.0.0:69 0.0.0.0:* 24607/in.tftpd
       udp6 0 0 :::69 :::* 24607/in.tftpd

I accomplished this by hacking /etc/init.d/tftpd-hpa as follows:

diff --git a/init.d/tftpd-hpa b/init.d/tftpd-hpa
index 115ca4e..a4a5b60 100755
--- a/init.d/tftpd-hpa
+++ b/init.d/tftpd-hpa
@@ -52,9 +52,15 @@ do_start()
                fi
        done

+ if [ "$TFTP_ADDRESS" = "[::]:69" ]; then # all interfaces
+ start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- \
+ --listen --user $TFTP_USERNAME \
+ $TFTP_OPTIONS $TFTP_DIRECTORY
+ else
                start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- \
                        --listen --user $TFTP_USERNAME --address $TFTP_ADDRESS \
                        $TFTP_OPTIONS $TFTP_DIRECTORY
+ fi
 }

 do_stop ()