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 01-27-2016, 10:24 AM   #1
packetsmacker
Member
 
Registered: Jun 2006
Posts: 68

Rep: Reputation: 15
firewalld block ip ranging but allow single ip


So I need the following.


allow 192.168.1.5 http
deny 192.168.1.0\24 http


So here are my firwalld command.
Code:
firewall-cmd --zone=public --add-rich-rule 'rule family="ipv4" source address="192.168.1.5" service name="http" accept'
firewall-cmd --zone=public --add-rich-rule 'rule family="ipv4" source address="192.168.1.0/24" service name="http" drop'
if i apply the first rule everyone gets in.If I apply both rules no one gets in. Basically I only want one IP getting to the web site.
 
Old 01-27-2016, 12:11 PM   #2
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Have you tried only to add the first rule without the second? I believe others are blocked by default, but don't quote me on this as I haven't worked with firewalld.
 
Old 01-27-2016, 12:45 PM   #3
packetsmacker
Member
 
Registered: Jun 2006
Posts: 68

Original Poster
Rep: Reputation: 15
That did it. I swear I had tried that before. Thanks
 
Old 01-27-2016, 01:32 PM   #4
packetsmacker
Member
 
Registered: Jun 2006
Posts: 68

Original Poster
Rep: Reputation: 15
ok maybe this isnt solved.


I added a log rule now everyone can access it. Here is my output

Code:
firewall-cmd --list-all
public (default, active)
  interfaces: enp0s3
  sources: 
  services: dhcpv6-client ssh
  ports: 
  masquerade: no
  forward-ports: 
  icmp-blocks: 
  rich rules: 
	rule family="ipv4" service name="http" log prefix="httpd" level="debug" limit value="1/m" accept
	rule family="ipv4" source address="192.168.1.5" service name="http" accept
 
Old 01-27-2016, 02:01 PM   #5
packetsmacker
Member
 
Registered: Jun 2006
Posts: 68

Original Poster
Rep: Reputation: 15
I removed all those rules and added this one.


rule family="ipv4" source address="192.168.1.5" service name="http" log prefix="httpd" level="info" limit value="1/m" accept

Now only 1.5 can get to the site and it gets a log in /var/log/message. I don't see any log for ips other then 1.5. I need to log all request to the web site.
 
Old 01-28-2016, 08:11 AM   #6
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Have you tried adding the logging rule after the access rule?
 
Old 01-28-2016, 09:48 AM   #7
packetsmacker
Member
 
Registered: Jun 2006
Posts: 68

Original Poster
Rep: Reputation: 15
I would love to but I have tried adding and removing them in different orders but they always end up like this.

rule family="ipv4" service name="http" log prefix="httpd" level="info" limit value="1/m" accept
rule family="ipv4" source address="192.168.1.5" service name="http" accept


This way everyone gets in and it gets logged. I tried adding the log with a drop instead of accept but it blocks everyone again. I am going to remove the log rule and come back to this when I have time.

Thanks lazydog for your help.
 
Old 01-28-2016, 02:14 PM   #8
packetsmacker
Member
 
Registered: Jun 2006
Posts: 68

Original Poster
Rep: Reputation: 15
I couldn't resist I had to try again.


This works.

firewall-cmd --zone=public --add-rich-rule 'rule family="ipv4" service name="http" log prefix="httpd" level="info" limit value="1/m"' --permanent


Removing accept seems to have fixed it.
 
  


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
how to get fail2ban to block a single port ? papampi Linux - Security 6 07-26-2012 07:38 AM
DHCP block single IP addresses noir911 Linux - Server 4 02-17-2009 02:59 AM
Does any body knows the ranging steps of an ADSL modem? fahadaziz Linux - Networking 1 02-15-2009 05:16 AM
Block Single User Mode lincoln.runwal Linux - Newbie 1 01-19-2009 05:22 AM

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

All times are GMT -5. The time now is 12:24 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