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 - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-09-2013, 06:44 AM   #1
rjdbarsal
LQ Newbie
 
Registered: Jun 2013
Posts: 23

Rep: Reputation: Disabled
How can I block a website using iptables with this rules?


Hello again guys,

I already set up a rule with mac filtering with this rule:

I set the iptables default rule to:
Code:
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
then with macfiltering this rule a certain mac address can access an internet/other networks:

Code:
iptables -A POSTROUTING -t nat -o eth0 -s 192.168.1.0/24 -d 0/0 \
         -j MASQUERADE
iptables -A FORWARD -t filter -i eth0 -d 192.168.1.0/24 -m state \
        --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -t filter -o eth0 -m mac --mac-source 00:26:6C:C7:81:C4 -m state \
        --state NEW,ESTABLISHED,RELATED -j ACCEPT
and what I want is, to block a website with this iptables rules but how?

I need any ideas, suggestions or tips from you guys.

Thanks
 
Old 07-09-2013, 07:01 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Words like "website" really don't mix with iptables. But you've not said a thing about what this site is, so it's hard to know if anything is possible. There are ways to attempt to match certain strings in web traffic which can be used to filter at a deeper level, but it's really not appropriate most of the time. You need to stay in a world of IP addresses and port numbers, so if you can define what this site is in those terms, then great, otherwise, that's what http proxies are for.
 
Old 07-09-2013, 07:57 AM   #3
rjdbarsal
LQ Newbie
 
Registered: Jun 2013
Posts: 23

Original Poster
Rep: Reputation: Disabled
Thank you for your response, Chris.
The website is google.com. How can we able to block this site?
Applying iptables.
 
Old 07-09-2013, 08:31 AM   #4
M4nd4R
LQ Newbie
 
Registered: Jul 2013
Posts: 3

Rep: Reputation: Disabled
First thing- You are using IPTABLES, so you should know the IP address of the website you want to block.
And Google has a range of IP addresses and you will have to block each of them.

Code:
sudo iptables -A INPUT -s IP_ADDRESS -j REJECT
Something like this might help.
 
Old 07-09-2013, 08:51 AM   #5
rjdbarsal
LQ Newbie
 
Registered: Jun 2013
Posts: 23

Original Poster
Rep: Reputation: Disabled
Thanks but this rule not working to the iprules given above.
Code:
sudo iptables -A INPUT -s IP_ADDRESS -j REJECT
Code:
               +---+        
         eth0=>| F |        +----------+
internet ======| w |        |          |------PC1
               | / |        |  switch  |------PC2
               | S |========|          |------PC3
               |   |eth1    +----------+
               +---+
FW: FIREWALL
S: SERVER
eth0: connection from the internet/other network
eth1: internal network
 
Old 07-09-2013, 09:31 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you can't block google from IP tables. Google has HUNDREDS of potential IP addresses serving a myriad of different sites that can change at any given second. That's absolutely NOT a plan. You need a proxy, something that understands HTTP.
 
Old 07-09-2013, 09:38 AM   #7
rjdbarsal
LQ Newbie
 
Registered: Jun 2013
Posts: 23

Original Poster
Rep: Reputation: Disabled
Hello Chris,

May I know how we can use proxy to block a website in ubuntu server?
any guidelines or steps?
 
Old 07-09-2013, 09:43 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
sure, just google information about squid, that's exactly what it's for.
 
  


Reply

Tags
block, firewall, iptables, server



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
[SOLVED] during system startup, iptables rules not loaded from /etc/sysconfig/iptables danyim Linux - Security 3 04-13-2013 02:09 AM
Restore iptables Rules that have been saved with iptables-save tiuz Linux - Security 4 08-14-2010 05:50 PM
iptables 1.27a still loading rules after installing iptables 1.3.0 yawe_frek Linux - Software 1 06-07-2007 09:50 PM
Block FORWARD Rules Manuel-H Linux - Security 1 01-21-2005 11:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:40 AM.

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