LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 11-25-2018, 01:14 PM   #1
cepicier
LQ Newbie
 
Registered: Nov 2018
Posts: 10

Rep: Reputation: Disabled
firewalld howto block internet access for a couple of mac addresses?


Hi all

I have two sons who abuse the internet. Myself and my daughter should have permenta access to the internet. I have deleted all acounts of my sons on the many computers we use exept on theit machines, wihich includes handies, tablets etc.

I do not want to go into a good / bad parental discussion here. My scope is to cut them off the internet for good, while they still can access local intranet infrastructure. I would like to give them a certain time say from 16:30 to 18:30, where the can use the internet and I am home, so I can check on their (ab)use of the internet.

We have opensuse leap 15.0 machines throughout. My firewall is based on firewalld. For the time being we have just two zones, external and internal. I do have a dns and dhcp server running. My best guess is to use rules like this :

==========================================================
iptables -N blocked_access
iptables -A blocked_access -m mac ! --mac-source xx:xx:xx:xx:xx:xx -j RETURN
iptables -A blocked_access -m time --timestart 20:00 --timestop 22:00 --weekdays Sun,Mon,Tue,Wed,Thu --syn -j ACCEPT
iptables -A blocked_access -j DROP
===========================================================

Which I found here https://www.linuxquestions.org/quest...ddress-787456/

The example above is based on iptables. I would like to use firewalld though. I could not find a single reference to a similar exmpla.

Can anyone help?

Greez
chris
 
Old 11-25-2018, 01:23 PM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
why don't you specify static ip addresses?
You may also want to check pi-hole, which will filter sites.
 
Old 11-25-2018, 03:09 PM   #3
cepicier
LQ Newbie
 
Registered: Nov 2018
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
why don't you specify static ip addresses?
You may also want to check pi-hole, which will filter sites.
Hi and thanks for your reply. Allow a few questions though:

What do I gain from static ip's? Especially looking at the time window. I believe, I will have a lot of configuration work ahead and probably increased maintenance efforts. I might be able to set fixed ip's in the dhcp server though. but still: what is the benefit of it and how do static ips with some additionla steps solve my problem?

The hint to pi hole is great! So big fat thanks for it. However I cannot see, how I can block the devices of my sons for a defined period and still allowing my daughter and myself unlimited access.

Greez
chris
 
Old 11-25-2018, 04:05 PM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Code:
firewall-cmd --zone=work --add-source=00:11:22:33:44:55
firewall-cmd --zone=work --add-rich-rule='rule source mac=11:22:33:44:55:66 drop'
Found here by searching for firewalld block mac address firewalld.org looks to have all the documentation and a couple of fora.

I'm not quickly finding anything about time windows, tho. Perhaps a cron job to open open/close the firewall for the mac addresses at desired times? Just an idea.
 
Old 11-26-2018, 12:12 AM   #5
cepicier
LQ Newbie
 
Registered: Nov 2018
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
[CODE]...Perhaps a cron job to open open/close the firewall for the mac addresses at desired times? Just an idea.
scasey
Thanks for the valuable input. I will try the cron job idea, I think it is great! I'll report back, as I believe I am not alone with my problem.
Greez
chris
 
Old 11-26-2018, 04:26 AM   #6
cepicier
LQ Newbie
 
Registered: Nov 2018
Posts: 10

Original Poster
Rep: Reputation: Disabled
How about the "direct" directive as referenced here. The links included point to firewalld.org/documentation/direct/ and man-pages/firewalld.direct.

I am not my place at the time of writing. I will try this:

Quote:
firewall-cmd --permanent --direct --add-rule ipv4 blocked_access
firewall-cmd --permanent --direct --add-rule ipv4 blocked_access \
-m mac ! --mac-source xx:xx:xx:xx:xx:xx -j RETURN
firewall-cmd --permanent --direct --add-rule ipv4 blocked_access \
-m time --timestart 20:00 --timestop 22:00 \
--weekdays Sun,Mon,Tue,Wed,Thu --syn -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 blocked_access -j DROP
Could this work?

Greez
chris
 
Old 11-29-2018, 07:25 AM   #7
cepicier
LQ Newbie
 
Registered: Nov 2018
Posts: 10

Original Poster
Rep: Reputation: Disabled
Hi all

While trying to set up the filters proposed, I had off course to collect the various mac addresses of my sons devices. I don't know but that opened another box. There are 2 iphones and 2 androids. These devices seem to change their mac addresses. Researching the cause, I found this. Thus my approach is rendered useless at least for the devices that sport the "randomize-mac-address-feature".
I thought I was back on field one, but maybe might still be really set to field one I guess:

Tracking the macs and their IP's revealed that interestingly enough, the devices got the same IP as they had on last dhcp request. If that was sound, I could use IP-adresses instead of macs. Using a dchpserver, that cannot be steady. So I guess I am really back on field one.

How to proceed from here?

Greez
chris[/QUOTE]

Last edited by cepicier; 11-29-2018 at 07:26 AM. Reason: typos
 
Old 12-02-2018, 04:36 AM   #8
cepicier
LQ Newbie
 
Registered: Nov 2018
Posts: 10

Original Poster
Rep: Reputation: Disabled
Hi all

Leaving the issue with the mobile devices aside (for now), I tried to block the laptops as follows:

The laptops can be connected through lan and/or Wlan.

On my gateway I have
Zone external eth1
Zone home eth0

If anymore info is required, kindly ask.

Excerpts of home.xml:
Quote:
cat home.xml
<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Home</short>
...
<interface name="eth0"/>
<service name="ssh"/>
...
<protocol value="udp"/>
<masquerade/>
<rule>
<source mac="aa:aa:aa:aa:aa:aa:aa:a1"/>
<log prefix="block-son1" level="info"/>
<reject/>
</rule>
<rule>
<source mac="aa:aa:aa:aa:aa:aa:aa:a2"/>
<log prefix="block-son1" level="info"/>
<reject/>
</rule>
<rule>
<source mac="aa:aa:aa:aa:aa:aa:aa:a3"/>
<log prefix="block-son2" level="info"/>
<reject/>
</rule>
<rule>
<source mac="aa:aa:aa:aa:aa:aa:aa:a4"/>
<log prefix="block-son2" level="info"/>
<reject/>
</rule>
</zone>
after
Quote:
systemctl restart firewalld
, I went to son2's laptop and cols surf the internet as if nothing was done to block it.

I checked the logs:
Quote:
iptables --list | grep MAC
REJECT all -- anywhere anywhere MAC aa:aa:aa:aa:aa:aa:aa:a1 reject-with icmp-port-unreachable
REJECT all -- anywhere anywhere MAC aa:aa:aa:aa:aa:aa:aa:a2 reject-with icmp-port-unreachable
REJECT all -- anywhere anywhere MAC aa:aa:aa:aa:aa:aa:aa:a3 reject-with icmp-port-unreachable
REJECT all -- anywhere anywhere MAC aa:aa:aa:aa:aa:aa:aa:a4 reject-with icmp-port-unreachable
LOG all -- anywhere anywhere MAC aa:aa:aa:aa:aa:aa:aa:a1 LOG level info prefix "block-son1"
LOG all -- anywhere anywhere MAC aa:aa:aa:aa:aa:aa:aa:a2 LOG level info prefix "block-son1"
LOG all -- anywhere anywhere MAC aa:aa:aa:aa:aa:aa:aa:a3 LOG level info prefix "block-son2"
LOG all -- anywhere anywhere MAC aa:aa:aa:aa:aa:aa:aa:a4 LOG level info prefix "block-son2"
So firewalld configured iptables. But no blocking takes effect?

Quote:
journalctl --since="today" | grep son2
...
Dez 02 10:06:06 extra kernel: block-son2IN=eth0 OUT= MAC=33:33:00:00:00:02:aa:aa:aa:aa:aa:aa:aa:a4 SRC=fe80:0000:0000:0000:dddd:daaa:1234:5678 DST=ff02:0000:0000:0000:0000:0000:0000:0002 LEN=48 TC=0 HOPLIMIT=255 FLOWLBL=177097 PROTO=ICMPv6 TYPE=133 CODE=0
Dez 02 10:06:30 extra kernel: block-son2IN=eth0 OUT= MAC=ff:ff:ff:ff:ff:ff:aa:aa:aa:aa:aa:aa:aa:a4 SRC=192.168.23.197 DST=255.255.255.255 LEN=1040 TOS=0x00 PREC=0x00 TTL=64 ID=3557 DF PROTO=UDP SPT=1716 DPT=1716 LEN=1020
Dez 02 10:14:22 extra kernel: block-son2IN=eth0 OUT= MAC=ff:ff:ff:ff:ff:ff:aa:aa:aa:aa:aa:aa:aa:a4 SRC=192.168.23.197 DST=255.255.255.255 LEN=1039 TOS=0x00 PREC=0x00 TTL=64 ID=11976 DF PROTO=UDP SPT=1716 DPT=1716 LEN=1019
Dez 02 10:14:25 extra kernel: block-son2IN=eth0 OUT= MAC=ff:ff:ff:ff:ff:ff:aa:aa:aa:aa:aa:aa:aa:a4 SRC=192.168.23.197 DST=255.255.255.255 LEN=1039 TOS=0x00 PREC=0x00 TTL=64 ID=12342 DF PROTO=UDP SPT=1716 DPT=1716 LEN=1019
The log says, the rules are in force.

What's wrong that the blocking is not in effect?
I would really appreciate help.

greez chris

Last edited by cepicier; 12-02-2018 at 04:37 AM. Reason: Typos
 
Old 12-13-2018, 10:10 AM   #9
cepicier
LQ Newbie
 
Registered: Nov 2018
Posts: 10

Original Poster
Rep: Reputation: Disabled
Hi all
I'm giving this up. It just does not work using firewalld.
Greez
chris
 
Old 12-13-2018, 10:19 AM   #10
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
iOS 12 has a new feature, Screen Time, that allows management of on-line time and which apps are allowed...I think. Haven't dug into it. Don't need it here. Might help you tho.

Don't know if Android has a similar tool.
 
Old 12-13-2018, 10:25 AM   #11
cepicier
LQ Newbie
 
Registered: Nov 2018
Posts: 10

Original Poster
Rep: Reputation: Disabled
Sean
Thanks for the hint. I'll check the iphone of my younger son for that feature.
The trouble is, I now need to run at several devices, where I could have done it at my gatway / firewall only. I did love that concept much more than buing/configuring stuff on currently 4 different platforms. Really a pita, it does not work as planned using firewalld.
I am giving a try using a raspberry and iptables. But that is another topic and thread then.
Greez
chris

PS: I am sure though, I am not the only one with this problem. So where are the other "victims"?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Block incoming IPv6 access to LAN clients with firewalld? n0xlf Linux - Networking 2 09-12-2014 08:23 PM
Block ALL IP addresses only allow 3 IP addresses on port 80/443 yelluc Linux - Security 8 03-28-2012 04:20 AM
Binding 2 NICs (MAC addresses) to 2 IP Addresses in same Subnet RedHat EL4.0 skhira Linux - Networking 13 02-24-2008 08:16 PM
Binding 2 NICs (MAC addresses) to 2 IP Addresses in same Subnet RedHat EL4.0 skhira Linux - Networking 1 02-09-2008 07:17 AM
Mapping IP addresses to MAC addresses basilio Linux - Networking 17 09-12-2007 01:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 03:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration