Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-24-2005, 10:23 AM
|
#1
|
Member
Registered: Nov 2004
Distribution: Fedora Core 2
Posts: 330
Rep:
|
Why this script cannot enable surfing?
Dear friends,
I have the following firewall script, all I want to experiment is a script that stops everything else but allow internet surfing. the script is as follow:
#!/bin/sh
iptables="/sbin/iptables"
$iptables -P FORWARD DROP
$iptables -P INPUT DROP
$iptables -P OUTPUT DROP
$iptables -A OUTPUT -p tcp -m state --state NEW --destination-port 80 -j ACCEPT
$iptables -A OUTPUT -p udp -m state --state NEW --destination-port 53 -j ACCEPT
$iptables -A OUTPUT -p tcp -m state --state NEW --destination-port 53 -j ACCEPT
$iptables -A INPUT -p tcp -m state --state ESTABLISHED,RELATED --destination-port 80 -j ACCEPT
$iptables -A INPUT -p udp -m state --state ESTABLISHED,RELATED --destination-port 53 -j ACCEPT
$iptables -A INPUT -p tcp -m state --state ESTABLISHED,RELATED --destination-port 53 -j ACCEPT
echo "firewall rules applied"
As seen above, i have enabled DNS port 53, http port 80 but it doesn't allow internet surfing...where did I go wrong here?
thanks for takin time reading my thread...thanks a lot.
regards
Fong
|
|
|
12-24-2005, 04:12 PM
|
#2
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
give this cleaned-up version of your script a shot:
Code:
#!/bin/sh
iptables="/sbin/iptables"
echo "0" > /proc/sys/net/ipv4/ip_forward
$iptables -F
$iptables -F -t nat
$iptables -F -t mangle
$iptables -X
$iptables -X -t nat
$iptables -X -t mangle
$iptables -P FORWARD DROP
$iptables -P INPUT DROP
$iptables -P OUTPUT DROP
$iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -o lo -j ACCEPT
$iptables -A OUTPUT -p tcp -m state --state NEW --dport 80 -j ACCEPT
$iptables -A OUTPUT -p udp -m state --state NEW --dport 53 -j ACCEPT
$iptables -A OUTPUT -p tcp -m state --state NEW --dport 443 -j ACCEPT
$iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -i lo -j ACCEPT
echo "firewall rules applied"
Last edited by win32sux; 12-24-2005 at 04:45 PM.
|
|
|
12-24-2005, 04:24 PM
|
#3
|
Senior Member
Registered: Nov 2004
Distribution: Mint, MX, antiX, SystemRescue
Posts: 2,337
|
Quote:
Originally Posted by Niceman2005
$iptables -A OUTPUT -p tcp -m state --state NEW --destination-port 80 -j ACCEPT
|
The above rule will allow your outgoing requests to port 80 (web surfing traffic) for initial connections (SYN), but it won't allow subsequent packets (ACK, etc.) I don't believe. This because you limited the rule to "--state NEW". I'd modify it to:
$iptables -A OUTPUT -p tcp --destination-port 80 -j ACCEPT
Quote:
$iptables -A INPUT -p tcp -m state --state ESTABLISHED,RELATED --destination-port 80 -j ACCEPT
|
I think you intended for this rule to allow the incoming replies to your web surfing traffic, but it won't. You limited it to only things coming in on port 80, which is not where you web surfing replies will be coming. These replies will be coming back to higher numbered ports (random). Ports above 1025. Simply remove the "--destination-port 80" part so your rule looks like this:
$iptables -A INPUT -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT
|
|
|
12-25-2005, 01:31 AM
|
#4
|
Member
Registered: Nov 2004
Distribution: Fedora Core 2
Posts: 330
Original Poster
Rep:
|
thanks a lot friends!
Your help helped me to understand better now. thanks a lot!
|
|
|
01-09-2006, 04:37 AM
|
#5
|
Senior Member
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291
Rep:
|
Is this running on a router with 2 network cards or a workstation with a single network card?
|
|
|
01-09-2006, 05:55 AM
|
#6
|
Member
Registered: Nov 2004
Distribution: Fedora Core 2
Posts: 330
Original Poster
Rep:
|
This one I am working on a workstation.
Its ok now, I gradually understood the concept already.
thanks a lot
|
|
|
All times are GMT -5. The time now is 08:34 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|