did I setup iptables correctly to block printer from interne

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
student13
DD-WRT User


Joined: 17 Nov 2016
Posts: 95

PostPosted: Thu Dec 01, 2016 0:48    Post subject: did I setup iptables correctly to block printer from interne Reply with quote
Hi did I setup my iptables correctly to block my printer from accessing the internet? Thanks. It did not seem to work, my printer was still able to access the internet
(HP test server).

Thanks. PS printer has a static ip address.
Sponsor
js1662
DD-WRT Guru


Joined: 23 Jul 2014
Posts: 1237
Location: BC, CA

PostPosted: Thu Dec 01, 2016 3:17    Post subject: Reply with quote
Have you tried this: https://www.dd-wrt.com/wiki/index.php/Access_Restrictions

BTW, next time when you post a picture, please limit the picture width to 800 pixels. It can easily be done by trimming the unnecessary background on the picture. Otherwise, others may not bother to read your post as the text are hard to read when you attached a large picture.
student13
DD-WRT User


Joined: 17 Nov 2016
Posts: 95

PostPosted: Thu Dec 01, 2016 4:40    Post subject: Reply with quote
I have tried access restrictions, and that is the only thing that works.
But I did this to in part learn iptables, and really wanted the iptables to work out.
I added iptables exactly as described, by another member.

In the future I will crop my images to the correct size for others.

But What is wrong with my iptables as I have placed them in the firewall rules.?
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6447
Location: UK, London, just across the river..

PostPosted: Thu Dec 01, 2016 8:28    Post subject: Reply with quote
first IPtables must be saved in firewall script only...

iptables -I FORWARD 1 -d (IP to Block) -j DROP
iptables -I OUTPUT 1 -d (IP to Block) -j DROP


second you can try with blocking by mac address like

iptables -I INPUT -p tcp --dport 80 -m mac ! --mac-source 00:24:81:D7:26:B4 -j REJECT --reject-with tcp-reset

or

filter any non static IP addresses connecting to router

Use dnsmasq and additional options:

Code:
dhcp-host=11:22:33:44:55:66,set:known
dhcp-ignore=tag:!known

First directive will send extra options tagged as "known" to machine with Ethernet address 11:22:33:44:55:66.
The other directive will ignore any clients which are not specified in dhcp-host lines. Equivalent to ISC "deny unknown-clients".
This relies on the special "known" tag which is set when a host is matched.
On linux (!) means NOT.

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55819 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
student13
DD-WRT User


Joined: 17 Nov 2016
Posts: 95

PostPosted: Fri Dec 02, 2016 2:46    Post subject: Reply with quote
The first command that you suggested did the trick very well, I set my printer to a static ip of 192.168.1.110
and used this on my WRT1900AC:

iptables -I FORWARD 1 -d (IP to Block) -j DROP
iptables -I OUTPUT 1 -d (IP to Block) -j DROP


>>RESULT: Gateway blocked + external ip blocked.WORKED! Very Happy

When I used the access restriction on DD-WRT and entered my printer's mac address ;

>>RESULT : Gateway accessible , BUT external ip blocked. Question

This command at least on my router (WRT1900AC), did not yield result

iptables -A INPUT -i eth0 -s 192.168.1.10 -j DROP
iptables -A FORWARD -i eth0 -s 192.168.1.10 -j DROP
iptables -A FORWARD -o eth0 -s 192.168.1.10 -j DROP


>>RESULT : Did not work, printer (HP) corportate web server accesible. Sad





Now on to my question about your other other command :

iptables -I INPUT -p tcp --dport 80 -m mac ! --mac-source 00:24:81:D7:26:B4 -j REJECT --reject-with tcp-reset
This suggests to me, that your are only rejecting requests coming from port 80 to a particular mac address? Is this correct? What if somebody from the
web access the printer aside from port 80 ? PS networking noob here.

Thanks. Very Happy
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Fri Dec 02, 2016 8:25    Post subject: Reply with quote
iptables -I INPUT -p tcp --dport 80 -m mac ! --mac-source 00:24:81:D7:26:B4 -j REJECT --reject-with tcp-reset

This commabd blocks the printer from accessing the web-gui of the router.
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6447
Location: UK, London, just across the river..

PostPosted: Fri Dec 02, 2016 17:06    Post subject: Reply with quote
just change port number for the printer....
_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55819 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
student13
DD-WRT User


Joined: 17 Nov 2016
Posts: 95

PostPosted: Sat Dec 03, 2016 1:47    Post subject: Reply with quote
I can change the port number but that does not exactly help because new printers communicate on 3/4 port numbers right.

A better command would be to block a mac adress from any wan communication on or out. But can it be done via iptables?
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6447
Location: UK, London, just across the river..

PostPosted: Sun Dec 04, 2016 12:55    Post subject: Reply with quote
Use dnsmasq and additional options:

Code:
dhcp-host=11:22:33:44:55:66,set:known
dhcp-ignore=tag:!known

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55819 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Sun Dec 04, 2016 17:08    Post subject: Reply with quote
To block your printer from accessing the Internet on any port:

iptables -I FORWARD -s 192.168.1.110 -o `get_wanface` -m state --state NEW -j DROP
student13
DD-WRT User


Joined: 17 Nov 2016
Posts: 95

PostPosted: Tue Feb 21, 2017 9:23    Post subject: Reply with quote
my printer communicates with my laptop via HP "jet direct" on port 9100. (192.168.1.110:9100)

SO here is how my firewall is set up .

iptables -I FORWARD -s 192.168.1.110 -o `get_wanface` -m state --state NEW -j DROP

iptables -I FORWARD -p tcp --dport 20005 -j DROP
iptables -I FORWARD -p tcp --dport 9100 -j DROP


Does this stop port 9100 from communicating with the Internet? PS , I use to use iptables forward/output rules, but it made the printer go fritz-y.

Thanks.
student13
DD-WRT User


Joined: 17 Nov 2016
Posts: 95

PostPosted: Sat Mar 11, 2017 18:25    Post subject: Reply with quote
BTW, when I try to setup and UBuntu printer driver, to make it print on my local network, this command, blocks all communication between my computer 's driver and the printer.
Anyone know why ? Shouldn't these commands only block outside (WAN) communication on to the lan?


iptables -I FORWARD 1 -d (IP to Block) -j DROP
iptables -I OUTPUT 1 -d (IP to Block) -j DROP
student13
DD-WRT User


Joined: 17 Nov 2016
Posts: 95

PostPosted: Thu Aug 03, 2017 21:43    Post subject: Reply with quote
Per Yngve Berg wrote:
To block your printer from accessing the Internet on any port:

iptables -I FORWARD -s 192.168.1.110 -o `get_wanface` -m state --state NEW -j DROP





iptables -I FORWARD -m mac --mac-source aa:bb:cc:dd:ee:ff -o `get_wanface` -m state --state NEW -j REJECT

whereas aa:bb:cc:dd:ee:ff is my printer mac address.


Would this discriminate by mac adress ? IS this the right syntax? I know I can do this by GUI, but I want to learn how to block mac adresses by mac, from the internet.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum