LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-08-2015, 04:02 PM   #1
sethl
LQ Newbie
 
Registered: Mar 2015
Posts: 2

Rep: Reputation: Disabled
Block Website from Centos IP Tables? (OpenVPN)


Okay, so I have a small VPN and I received an abuse report due to port scanning on a website. I wish to block the website entirely from ever being accessed again to prevent this problem.

How would I go about blocking the website?

I have tried a few things that don't seem to work so I made an account here, thank you.
 
Old 03-08-2015, 04:59 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
To drop all packets to the website, you can insert a rule like this, where x.x.x.x is the IP address returned by host.

Code:
host www.example.com
iptables -I INPUT 1 -d "x.x.x.x" -j DROP
After you've tested that it is what you want, use iptables-save to make it stay through reboots.
 
Old 03-09-2015, 12:09 PM   #3
sethl
LQ Newbie
 
Registered: Mar 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
What if I wanted to block a site like facebook with many IP addresses?
 
Old 03-09-2015, 03:32 PM   #4
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Do they?
Code:
host www.facebook.com
www.facebook.com is an alias for star.c10r.facebook.com.
star.c10r.facebook.com has address 31.13.71.1
star.c10r.facebook.com has IPv6 address 2a03:2880:f012:1:face:b00c:0:1
star.c10r.facebook.com mail is handled by 10 msgin.vvv.facebook.com.
 
Old 03-09-2015, 06:54 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by smallpond View Post
Do they?
Facebook itself actually has AS32934 which right now contains 45 IP ranges. That's not to say they use them all but it also doesn't say they won't ever. Also it doesn't take any distributed ^.*whatever.*$ networks usage into account. Some things are better blocked on multiple levels and including a filtering proxy.
 
Old 03-10-2015, 08:07 AM   #6
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
The OP said they want to block the site, not all IPs owned by FB.
 
Old 03-10-2015, 11:25 AM   #7
Miati
Member
 
Registered: Dec 2014
Distribution: Linux Mint 17.*
Posts: 326

Rep: Reputation: 106Reputation: 106
Quote:
Okay, so I have a small VPN and I received an abuse report due to port scanning on a website. I wish to block the website entirely from ever being accessed again to prevent this problem.
Quote:
To drop all packets to the website, you can insert a rule like this, where x.x.x.x is the IP address returned by host.

Code:

host www.example.com
iptables -I INPUT 1 -d "x.x.x.x" -j DROP
Perhaps I misread, but I believe the OP is asking to prevent packets being sent to the address, not received
While x.x.x.x wouldn't be able to connect to you, I think someone using the VPN could connect to website x and continue port scanning.

Code:
iptables -I OUTPUT 1 -d "x.x.x.x" -j REJECT
It may serve to reject the packet as well, to let the user know that this behaviour is being restricted (or at least know that it's blocked)

Additionally, the OP says the abuse report was from a port scan, is there any reason to not just reject all traffic to any ports except 443,80 for this website?
It's a little more complicated but I wouldn't want to be claimed for censorship for the other users (just a thought)
If it's a complex site and uses more ports, this probably won't work but for a simple site it could.

Code:
iptables -I OUTPUT 1 -d x.x.x.x -m multiport ! --dport 80,443 -j REJECT
This will reject the packet if sent to destination x.x.x.x and is to any port except 80 or 443.

Last edited by Miati; 03-10-2015 at 11:31 AM.
 
Old 03-10-2015, 11:47 AM   #8
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
If blocking at a firewall for a LAN, then the rule should go in the FORWARDING chain. Also add it to the OUTPUT chain to block packets from the local machine.

Last edited by smallpond; 03-10-2015 at 12:15 PM.
 
Old 03-23-2015, 06:11 PM   #9
jakep219
LQ Newbie
 
Registered: Jun 2012
Posts: 11

Rep: Reputation: 0
Although you inquired about an iptables based block, you may open /etc/hosts file in your favorite text editor as root and redirect the domain name to a non-existant IP address or (if you are particularly evil) redirect the domain to the ip address of a different server that you may or may not have complete control over.

Add a line like this to the hosts file and save.
Quote:
127.0.0.1 facebook.com
 
  


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
IP Tables, How to block range of ip address from ip table gash Linux - Software 4 05-31-2012 08:05 AM
block ftp brute force without ip tables reeseslover531 Linux - Server 2 11-24-2006 06:48 PM
Block/open all port using IP Tables rules shipon_97 Linux - Networking 1 09-06-2006 11:20 PM
Is it possible to block text strings with IP tables? abefroman Linux - Security 27 06-29-2005 05:36 PM
Setting ip tables to block all traffic LinuxBAH Linux - Security 1 02-07-2004 06:15 AM

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

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