You are not logged in.

#1 2020-11-10 08:23:09

eriol
Member
Registered: 2020-08-29
Posts: 14

[SOLVED] iptables and network scanner

Hi

I can not find what I am missing, so I need some help.

With iptables stopped on my local server, my scanner is perfectly working. With iptables started, using simple-scan, the scanner is activated, and scans, but on the client side the image is never received.

I followed the wiki and added a file

nf_conntrack_sane.conf

under

/etc/modules-load.d/

(not sure if this was necessary).

This is the result of

#iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere            
DROP       all  --  anywhere             anywhere             ctstate INVALID
ACCEPT     icmp --  anywhere             anywhere             icmp echo-request ctstate NEW
UDP        udp  --  anywhere             anywhere             ctstate NEW
TCP        tcp  --  anywhere             anywhere             tcp flags:FIN,SYN,RST,ACK/SYN ctstate NEW
REJECT     udp  --  anywhere             anywhere             reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             anywhere             reject-with tcp-reset
REJECT     all  --  anywhere             anywhere             reject-with icmp-proto-unreachable

Chain FORWARD (policy DROP)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain TCP (1 references)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ipp state NEW,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ipp state NEW,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https state NEW,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:snmp state NEW,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:printer state NEW,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:8095 state NEW,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:sane-port

Chain UDP (1 references)
target     prot opt source               destination         
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     udp  --  anywhere             anywhere             udp dpt:mdns state NEW,ESTABLISHED
ACCEPT     udp  --  anywhere             anywhere             udp dpt:mdns state NEW,ESTABLISHED
ACCEPT     udp  --  anywhere             anywhere             udp spt:snmp
ACCEPT     udp  --  anywhere             anywhere             udp dpt:sane-port

I think I am missing something about conntrack, so did some attempts, but went nowehere sad

Last edited by eriol (2020-11-12 08:39:26)

Offline

#2 2020-11-10 09:49:12

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,090
Website

Re: [SOLVED] iptables and network scanner

Did you read and follow these instructions?
https://wiki.archlinux.org/index.php/SANE#Firewall

Last edited by schard (2020-11-10 09:49:32)


Inofficial first vice preseident of the Rust Evangelism Strike Force

Offline

#3 2020-11-10 10:21:01

eriol
Member
Registered: 2020-08-29
Posts: 14

Re: [SOLVED] iptables and network scanner

schard wrote:

Did you read and follow these instructions?
https://wiki.archlinux.org/index.php/SANE#Firewall

Yes, but, as stated in

/etc/sane.d/saned.conf
## Daemon options
# Port range for the data connection. Choose a range inside [1024 - 65535].
# Avoid specifying too large a range, for performance reasons.
#
# ONLY use this if your saned server is sitting behind a firewall. If your
# firewall is a Linux machine, we strongly recommend using the
# Netfilter nf_conntrack_sane connection tracking module instead.
#

I would like to use nf_conntrack_sane instead of opening a port range for the data connection. As far as I can understand, using nf_conntrack_sane makes unecessary to open the data port range. Am I wrong?

Offline

#4 2020-11-10 11:31:59

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,861

Re: [SOLVED] iptables and network scanner

sane page on archwiki wrote:

To set up the server, first indicate which hosts on your network are allowed access.

Which addresses did you add ?

please post the output of

$ scanimage -L

Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#5 2020-11-10 11:41:07

eriol
Member
Registered: 2020-08-29
Posts: 14

Re: [SOLVED] iptables and network scanner

Lone_Wolf wrote:
sane page on archwiki wrote:

To set up the server, first indicate which hosts on your network are allowed access.

Which addresses did you add ?

localhost
192.168.1.0/24
Lone_Wolf wrote:

please post the output of

$ scanimage -L

on client

$ scanimage -L
device `net:192.168.1.52:xerox_mfp:libusb:001:002' is a Samsung M2070 Series multi-function peripheral

Offline

#6 2020-11-10 11:46:12

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,090
Website

Re: [SOLVED] iptables and network scanner

wiki wrote:

so you must enable connections to 6566/tcp and data_portrange from /etc/sane.d/saned.conf or use conntrack firewall module for sane to enable data ports as described above

I read that as

6566/tcp AND (data_portrange from /etc/sane.d/saned.conf OR use conntrack firewall module)

not as

(6566/tcp AND data_portrange from /etc/sane.d/saned.conf) OR use conntrack firewall module

But since I do not have a network attached scanner, I did not test this.
In any case, I'd check whether allowing 6566/tcp makes it work for you.


Inofficial first vice preseident of the Rust Evangelism Strike Force

Offline

#7 2020-11-10 12:07:20

eriol
Member
Registered: 2020-08-29
Posts: 14

Re: [SOLVED] iptables and network scanner

schard wrote:

In any case, I'd check whether allowing 6566/tcp makes it work for you.

That should already be allowed (see sane-port in iptables -L)

I think I miss some rule that says ti iptables that connection related to sane on some data port can be accepted.
I tryed with something like

 -A TCP -p tcp -m conntrack --cstate ESTBLISHED,RELATED -m helper --helper sane -j ACCEPT 

and some other variants, but had no result.

Last edited by eriol (2020-11-10 12:15:15)

Offline

#8 2020-11-10 15:09:24

seth
Member
Registered: 2012-09-03
Posts: 57,935

Re: [SOLVED] iptables and network scanner

added a file nf_conntrack_sane.conf under /etc/modules-load.d/

cat /etc/modules-load.d/nf_conntrack_sane.conf
lsmod | grep conntrack

Offline

#9 2020-11-10 15:22:29

eriol
Member
Registered: 2020-08-29
Posts: 14

Re: [SOLVED] iptables and network scanner

seth wrote:

added a file nf_conntrack_sane.conf under /etc/modules-load.d/

cat /etc/modules-load.d/nf_conntrack_sane.conf
lsmod | grep conntrack
xt_conntrack           16384  13
nf_conntrack          172032  2 xt_conntrack,xt_state
nf_defrag_ipv6         24576  1 nf_conntrack
nf_defrag_ipv4         16384  1 nf_conntrack
libcrc32c              16384  1 nf_conntrack
x_tables               53248  6 xt_conntrack,iptable_filter,xt_state,xt_tcpudp,ipt_REJECT,ip_tables

Offline

#10 2020-11-10 15:24:46

seth
Member
Registered: 2012-09-03
Posts: 57,935

Re: [SOLVED] iptables and network scanner

sudo modprobe nf_conntrack-sane

I assume the file is empty?
https://wiki.archlinux.org/index.php/Ke … th_systemd

Offline

#11 2020-11-10 16:05:28

eriol
Member
Registered: 2020-08-29
Posts: 14

Re: [SOLVED] iptables and network scanner

seth wrote:
sudo modprobe nf_conntrack-sane

I assume the file is empty?
https://wiki.archlinux.org/index.php/Ke … th_systemd

Sorry, I did not notice the cat in your previous answer.
Anyway, before my previous answer, I removed /etc/modules-load.d/nf_conntrack_sane.conf for one of the attempts (and did not work, anyway).

Now,

# cat /etc/modules-load.d/nf_conntrack_sane.conf 
nf_conntrack_sane
#lsmod | grep conntrack
xt_conntrack           16384  13
nf_conntrack_sane      20480  0
nf_conntrack          172032  3 xt_conntrack,xt_state,nf_conntrack_sane
nf_defrag_ipv6         24576  1 nf_conntrack
nf_defrag_ipv4         16384  1 nf_conntrack
libcrc32c              16384  1 nf_conntrack
x_tables               53248  6 xt_conntrack,iptable_filter,xt_state,xt_tcpudp,ipt_REJECT,ip_tables
modprobe nf_conntrack_sane

give no output

But client still does not receive image mad

Offline

#12 2020-11-10 17:21:57

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,861

Re: [SOLVED] iptables and network scanner

tipbox from wiki wrote:

Note: saned intentionally refuses to share scanners that use the net: backend (which includes some USB scanners). There is a crude patch to allow this in FS#54786, but note it may cause problems on some networks. Check output of scanimage -L on the server to see the scanner url.

What is the output of scanimage -L   on the server


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#13 2020-11-11 09:06:32

eriol
Member
Registered: 2020-08-29
Posts: 14

Re: [SOLVED] iptables and network scanner

Lone_Wolf wrote:
tipbox from wiki wrote:

Note: saned intentionally refuses to share scanners that use the net: backend (which includes some USB scanners). There is a crude patch to allow this in FS#54786, but note it may cause problems on some networks. Check output of scanimage -L on the server to see the scanner url.

What is the output of scanimage -L   on the server

# scanimage -L
device `xerox_mfp:libusb:001:004' is a Samsung M2070 Series multi-function peripheral

Offline

#14 2020-11-11 12:16:51

seth
Member
Registered: 2012-09-03
Posts: 57,935

Re: [SOLVED] iptables and network scanner

https://wiki.archlinux.org/index.php/Iptables#Logging so we might see where this hangs.

Offline

#15 2020-11-11 16:16:17

eriol
Member
Registered: 2020-08-29
Posts: 14

Re: [SOLVED] iptables and network scanner

seth wrote:

I made a couple of attempts to see if the ports involved are the same.

# journalctl -k | grep "IN=.*OUT=.*"
nov 11 17:01:21 minipcchio kernel: IN=enp2s0 OUT= MAC=$(mac) SRC=192.168.1.156 DST=192.168.1.52 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=9642 DF PROTO=TCP SPT=54542 DPT=38083 WINDOW=64240 RES=0x00 SYN URGP=0
# journalctl -k | grep "IN=.*OUT=.*"
nov 11 17:07:16 minipcchio kernel: IN=enp2s0 OUT= MAC=$(mac) SRC=192.168.1.156 DST=192.168.1.52 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=21701 DF PROTO=TCP SPT=49350 DPT=43629 WINDOW=64240 RES=0x00 SYN URGP=0

(Btw using the data port range works, but I want to understand why nf_conntrack does not)

Offline

#16 2020-11-11 21:37:12

seth
Member
Registered: 2012-09-03
Posts: 57,935

Re: [SOLVED] iptables and network scanner

http://home.regit.org/wp-content/upload … lpers.html

Conntrack helpers seem to be disabled by default, you must either explicitly assign them to the rule or  enable them via /proc/sys/net/netfilter/nf_conntrack_helper

Offline

#17 2020-11-12 08:35:26

eriol
Member
Registered: 2020-08-29
Posts: 14

Re: [SOLVED] iptables and network scanner

seth wrote:

http://home.regit.org/wp-content/upload … lpers.html

Conntrack helpers seem to be disabled by default, you must either explicitly assign them to the rule or  enable them via /proc/sys/net/netfilter/nf_conntrack_helper

So this

# echo "options nf_conntrack nf_conntrack_helper=1" >> /etc/modprobe.d/local.conf

seems to solve the question

Thank you everyone for your help big_smile

Offline

Board footer

Powered by FluxBB