You are not logged in.

#1 2012-12-12 18:00:09

android
Member
From: San Diego
Registered: 2003-04-18
Posts: 146

[solved] systemd and tftpd

[edited for additional question clarity]
[edited again showing result of running in.tftpd manually]

I have a recently installed systemd based machine with 2 NICs. One faces the LAN and runs dhcpcd, the other faces a local isolated subnet and runs dhcpd and tftpd.

Everything was working until an update early this week (including the new 3.6.9 kernel) caused the eth0 and eth1 to swap places.

I tried a udev rule to assign the eth0 and eth1, but it didn't seem to work.

Subsequently, I just renemaed the eth0 and eth1 in the dhcpd.service file and the /etc/conf.d/network file referenced by the network.service file.

Now dhcpd4 seems to be working, but tftpd is continuing to fail to start with the error:

Dec 12 09:36:57 beezey in.tftpd[1386]: cannot bind to local IPv4 socket: Address already in use
Dec 12 09:36:57 beezey systemd[1]: tftpd.service: main process exited, code=exited, status=71/n/a
Dec 12 09:36:57 beezey systemd[1]: Unit tftpd.service entered failed state

The tftpd.service file:

[root@beezey johnea]# cat /etc/systemd/system/tftpd.service
[Unit]
Description=hpa's original TFTP daemon

[Service]
ExecStart=/usr/sbin/in.tftpd -l -4 -s /srv/tftp/
StandardInput=socket
StandardOutput=inherit
StandardError=journal

[Install]
WantedBy=multi-user.target

I've used the network.service file indicated here:
https://wiki.archlinux.org/index.php/Co … IP_address

Including this file to configure the static eth0:

[root@beezey johnea]# cat /etc/conf.d/network
interface=eth0
 address=10.20.30.1
 netmask=24
 broadcast=10.20.30.255

And started and stopped tftpd.socket prior to .service as instructed here:
https://wiki.archlinux.org/index.php/Tf … er#Systemd

Netstat show the IPv6 port 69 for tftpd, but there is no port 69 listening on IPv4:

[root@beezey johnea]# netstat --udp --tcp -l -n
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:6011          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:6012          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:6013          0.0.0.0:*               LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 ::1:6010                :::*                    LISTEN     
tcp6       0      0 ::1:6011                :::*                    LISTEN     
tcp6       0      0 ::1:6012                :::*                    LISTEN     
tcp6       0      0 ::1:6013                :::*                    LISTEN     
udp        0      0 0.0.0.0:58493           0.0.0.0:*                          
udp        0      0 0.0.0.0:67              0.0.0.0:*                          
udp        0      0 10.20.30.1:123          0.0.0.0:*                          
udp        0      0 192.168.13.73:123       0.0.0.0:*                          
udp        0      0 127.0.0.1:123           0.0.0.0:*                          
udp        0      0 0.0.0.0:123             0.0.0.0:*                          
udp6       0      0 :::32138                :::*                               
udp6       0      0 :::69                   :::*                               
udp6       0      0 fe80::21b:21ff:fe6b:123 :::*                               
udp6       0      0 fe80::1a03:73ff:fe3:123 :::*                               
udp6       0      0 ::1:123                 :::*                               
udp6       0      0 :::123                  :::*

I'm able to start in.tftpd manually via:

[root@beezey johnea]# in.tftpd -l -s /srv/tftp/  

After this command line netstat shows the active socket 69 on IPv4 and IPv6:

[root@beezey johnea]# netstat --udp -l -n
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
udp        0      0 0.0.0.0:44194           0.0.0.0:*                          
udp        0      0 0.0.0.0:67              0.0.0.0:*                          
udp        0      0 0.0.0.0:69              0.0.0.0:*                          
udp        0      0 192.168.13.73:123       0.0.0.0:*                          
udp        0      0 10.20.30.1:123          0.0.0.0:*                          
udp        0      0 127.0.0.1:123           0.0.0.0:*                          
udp        0      0 0.0.0.0:123             0.0.0.0:*                          
udp6       0      0 :::41398                :::*                               
udp6       0      0 :::69                   :::*                               
udp6       0      0 fe80::21b:21ff:fe6b:123 :::*                               
udp6       0      0 fe80::1a03:73ff:fe3:123 :::*                               
udp6       0      0 ::1:123                 :::*                               
udp6       0      0 :::123                  :::*                               

I'm unclear on:
1) why tftpd thinks IPv4 0.0.0.0:69 is already in use
2) how to best configure persistent interface names under sytemd and udev

Any guidance is greatly appreciated...

johnea

Last edited by android (2012-12-14 00:20:19)

Offline

#2 2012-12-14 00:19:58

android
Member
From: San Diego
Registered: 2003-04-18
Posts: 146

Re: [solved] systemd and tftpd

OK, I have it working. There were several things wrong:

1) The modified tftpd.service file was incorrect. The introduction of the '-l' flag, to run tftpd as a standalone service, not inetd driven, was preventing the socket based unit from working. The tftpd.service file below is working correctly with the stock tftpd.socket file provided with the tftp-hpa package. This file has modifications to make tftpd run only on the statically configured interface.

[Unit]
Description=hpa's original TFTP daemon on subnet interface sub0
Requires=network.target
After=network.target

[Service]
ExecStart=/usr/sbin/in.tftpd -a 10.20.30.1 -s /srv/tftp/
StandardInput=socket
StandardOutput=inherit
StandardError=journal

[Install]
WantedBy=multi-user.target

The "Requires=network.target" and "After=network.target" were necessary additions for restricting tftpd to one interface by it's IP address.

The "-a 10.20.30.1" argument specifies the interface to monitor.

2) The /etc/conf.d/network file had typos.

The statically configured interface uses the network.service file specified here:
https://wiki.archlinux.org/index.php/Tf … er#Systemd

However my /etc/conf.d/network file somehow managed to pick up spaces at the beginning of the lines after the first line. This prevented the network.service file from extracting the parameters.

I additionally modified the network.service file by commenting out the wpa_supplicant line, and the "ip route add" line, because this is a wired interface and it is a local subnet with no outbound gateway.

The netstat output was misleading me. Since the tftpd unit is socket driven, it does not show up as a listening socket on port 69 (this also kept it out of ps listings). I believe systemd had started tftpd.socket and was monitoring UDP port 69. This is why I was experiencing the "Address already in use" error on the tftpd.service file that specified the '-l' option.

The persistent interface names where established via a Udev rule, as specified here:
https://wiki.archlinux.org/index.php/Ud … ork_device

This led to custom interface names, which required the /etc/conf.d/network file, and other network config files be updated.

These steps led to a working tftpd service on one statically configured interface only.

The only remaining systemd issue to be resolved on this host is to restrict the dhcpcd client to the other interface only, but that's another post.

johnea

Offline

Board footer

Powered by FluxBB