Howto Start TFTP server on macOS
macOS has built in TFTP daemon - which is useful for developer to transfer firmware during development. Ex. if you are OpenWrt developer :)

When working with devices that requires TFTP server like flash router via TFTP, ... we could either deploy a using docker
or using build-in TFTP daemon in macOS.
Deploy TFTP Server with docker
This method could apply to either Linux/macOS/Windows using docker
or podman
with bind mount to a folder tftpboot
inside the current folder.
docker run -d -p 0.0.0.0:69:69/udp -v ./tftpboot:/var/tftpboot -i -t docker.io/pghalliday/tftp
docker-compose
file:
version: '2'
services:
tftpd:
image: docker.io/pghalliday/tftp
container_name: tftpd
volumes:
- ./tftpboot:/var/tftpboot
tty: true
ports:
- "69:69/udp"
macOS TFTP Daemon
macOS
has built in TFTP
daemon - which is useful for developer to transfer firmware during development.
Daemon location: /System/Library/LaunchDaemons/tftp.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>Label</key>
<string>com.apple.tftpd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/libexec/tftpd</string>
<string>-i</string>
<string>/private/tftpboot</string>
</array>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<true/>
</dict>
<key>InitGroups</key>
<true/>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>tftp</string>
<key>SockType</key>
<string>dgram</string>
</dict>
</dict>
</dict>
</plist>
Modify TFTP service parameters
From above TFTP daemon settings, by default, TFTP folder location is /private/tftpboot
. As files under /System
is protected by SIP, so we could leave with this default location and add needed files into this default path: /private/tftpboot
However, remember to chmod
whole folder and added files with correct permission, else TFTP client can't get that file.
# chmod whole folder to 777
sudo chmod -R 777 /private/tftpboot
# add a file (let's say fw.bin and also chmod 777)
cp fw.bin /private/tftpboot
chmod 777 /private/tftpboot/fw.bin
Start and Stop daemon
Start daemon:
sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plist
Stop daemon:
sudo launchctl unload /System/Library/LaunchDaemons/tftp.plist
Test with tftp
client
We could test how TFTP daemon is running with build-in tftp
client.
## Fetch file fw.bin
tftp -e 127.0.0.1
tftp> get fw.bin
Received 4979 bytes in 0.0 seconds
## In case file is not available
get fw.bin
Error code 256: File not found
Good luck!