- Install the sane network daemon (and other stuff):
# apt-get install sane-utils - Follow the instructions outlined in the man page, namely:
- add a line for saned in /etc/inetd.conf
sane-port stream tcp nowait saned.saned /usr/sbin/saned /usr/sbin/saned - specify a list of allowed clients in /etc/sane.d/saned.conf
- restart inetd with
# /etc/init.d/openbsd-inetd restart
- add a line for saned in /etc/inetd.conf
- Install SaneTwain on my wife's laptop and configure it to connect to my laptop
- Add a line to /etc/shorewall/rules to accept connections on the saned control port 6566, and restart the firewall with
# /etc/init.d/shorewall restart
It turns out that the scanned data isn't transferred thru the saned control port, but rather thru a different, dynamically set port. This is actually mentioned in the man page under the restrictions section, and their suggestion is
"If you must use a packet filter, make sure that all ports > 1024 are open on the server for connections from the client"which seems like a bad idea.
The interim solution to the problem, until proper saned connection tracking is available, is outlined on the Gentoo-Wiki, and here is how I implemented it with shorewall:
- create an empty file /etc/shorewall/action.SaneConntrack
- create a file /etc/shorewall/SaneConntrack
# track SANE control connections
run_iptables -A $CHAIN -m recent --update --seconds 600 --name SANE
# related traffic (ACK, FIN, DNS UDP responses etc.)
run_iptables -A $CHAIN -m state --state ESTABLISHED,RELATED -j ACCEPT
# SANE server uses a dynamic data port above 1024
run_iptables -A $CHAIN -p tcp -m tcp --dport 6566 --syn -m recent --set --rsource --name SANE -j ACCEPT
run_iptables -A $CHAIN -p tcp -m tcp --dport 1024: --syn -m recent --rcheck --rsource --seconds 3 --name SANE -j ACCEPT - Add a line to /etc/shorewall/actions (create the file if it does not exist):
SaneConntrack - Add the following lines to /etc/shorewall/rules
# saned
SaneConntrack loc $FW tcp 6566
SaneConntrack loc $FW tcp 1024: - Restart shorewall.