Setting up a network scanner with SANE

First, install Avahi and SANE on the server:

sudo apt install avahi-daemon libnss-mdns sane-utils

Then edit the SANE daemon configuration:

/etc/default/saned
# Set to yes to start saned
RUN=yes


Add user saned to the lp and scanner groups.

sudo usermod -a -G lp,scanner saned


Check whether your scanner is recognized. If it’s not, you’re probably missing a driver, such as hplip. Or worse.

scanimage -L

The output will look something like this:

device 'hpaio:/usb/Photosmart_C4500_series' is a Hewlett-Packard Photosmart_C4500_series all-in-one


If all is well, edit the SANE server configuration and add your subnet to the access list.

/etc/sane.d/saned.conf
# The hostname matching is not case-sensitive.
192.168.0.0/24


If you’re using a firewall (ufw in this case), you’ll have to open some ports:

sudo ufw allow from 192.168.0.0/24 to any port 5353 proto udp
sudo ufw allow from 192.168.0.0/24 to any port 6566 proto tcp
sudo ufw allow from 192.168.0.0/24 to any port 40000:40100 proto tcp

Then set the port range in /etc/sane.d/saned.conf accordingly:

/etc/sane.d/saned.conf
# Port range for the data connection.
data_portrange = 40000 - 40100


Finally, start saned:

sudo systemctl start saned.socket
sudo systemctl enable saned.socket


All that’s left to do now is having the client computers look for the SANE server. Unlike CUPS, this isn’t autodetected.
Edit /etc/sane.d/net.conf and add your server’s hostname or IP address to the bottom.

/etc/sane.d/net.conf
scanserver.local

Launch Simple Scan (or another SANE front-end), and your network scanner should be found within a few seconds.