iptables ruleset to allow http


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users iptables ruleset to allow http
# 1  
Old 06-29-2014
Computer iptables ruleset to allow destination port http/s

Hello gentlemen.
I want to solve a little problem with iptables.

Let's suppose that i've a valid ruleset called MYBLOCK with all ips i want to block.
Code:
$ iptables --list

Chain FORWARD (policy DROP)
DROP       all  --  anywhere             anywhere            set MYBLOCK src,dst

Everything works fine but if I've this ip: 2.2.2.2 in the ruleset I can't access it via browser because I've blocked it (drop). Is there a way to block the ip but allow me to access it via browser (allow destination port 80 and 443)?

ipset v4.5, protocol version 4
iptables v1.3.8

This is the command i use to apply my ruleset:

Code:
$ iptables -I FORWARD -m set --set MYBLOCK src,dst -j DROP

Shortly, I don't know how to make iptable to allow destination port 80. I've tried everything without success Smilie

Please tell me if you need more info.
Thanks in advance for your attention and support.

Last edited by accolito; 06-30-2014 at 02:42 AM.. Reason: sorry vbe, I'll be more careful :-P
# 2  
Old 07-01-2014
Not tested, but the rules would be something like the following:
Code:
iptables -A INPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT

# 3  
Old 07-01-2014
IBM

From my point of view offered solution should work but with FORWARD chain instead of the INPUT and OUTPUT.

Former rule denies only forwarded traffic and not the local one so I assume that asker uses it as a transparent FW therefore rules should be before the DROP rule and for the FORWARD chain.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script to find time difference between HTTP PUT and HTTP DELETE requests in access.log

Hi, I'm trying to write a script to determine the time gap between HTTP PUT and HTTP DELETE requests in the HTTP Servers access log. Normally client will do HTTP PUT to push content e.g. file_1.txt and 21 seconds later it will do HTTP DELETE, but sometimes the time varies causing some issues... (3 Replies)
Discussion started by: Juha
3 Replies

2. Web Development

HTTP Headers Reference: HTTP Status-Codes

Hypertext Transfer Protocol -- HTTP/1.1 for Reference - HTTP Headers 10 Status Code Definitions Each Status-Code is described below, including a description of which method(s) it can follow and any metainformation required in the response. (1 Reply)
Discussion started by: Neo
1 Replies

3. UNIX for Advanced & Expert Users

Sendmail Rewrite Ruleset

Hi all, I like to write a rule which do the following: INPUT ADDRESS REWRITTEN TO ----------------------------- ----------------------------- foo.bar@sub.domain.com bar@domain.com foo@othersub.domain.com ... (1 Reply)
Discussion started by: bashily
1 Replies

4. Shell Programming and Scripting

sending http url through http socket programming..

hi am senthil am developing a software to send and receive SMS using HTTP connection first of all am forming a URL and sending that URL to a remote server using my Client Program i send that url through Socket(using Send() Function) if i send more than one URL one by one using the same... (4 Replies)
Discussion started by: senkerth
4 Replies

5. Programming

sending http url through http socket programming..

hi am senthil am developing a software to send and receive SMS using HTTP connection first of all am forming a URL and sending that URL to a remote server using my Client Program i send that url through Socket(using Send() Function) if i send more than one URL one by one using the same... (0 Replies)
Discussion started by: senkerth
0 Replies

6. Shell Programming and Scripting

http and https

Hi friends, I have a local host http://ss3/cgi-bin/page/page_list.cgi running on apache webserver perfectly well. But suddenly, it stopped working and gave an error "Internet explorer Explorer cannot display the webpage". But when i added https, as https://ss3/cgi-bin/page/page_list.cgi the... (2 Replies)
Discussion started by: nmattam
2 Replies

7. UNIX for Dummies Questions & Answers

HTTP request

Can anybody tell about http request processing in shell script..? (3 Replies)
Discussion started by: noufal
3 Replies

8. UNIX for Advanced & Expert Users

http

how to downloaad a web page using http server (0 Replies)
Discussion started by: krishnavel
0 Replies

9. Linux

HTTP server

Hello all, Please tell me that how to configure a HTTP server in Fedora Core 3 Also tell me about WEB HOSTING under Linux. (4 Replies)
Discussion started by: jaibw
4 Replies
Login or Register to Ask a Question