[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.6

IPTables Script

Asked by hithayath in Linux Networking

Tags: iptables

I am having two NIC on linux box ( hereafter by name INTserver). I have set this box as router ( for servicing internet services to my clients), webserver, FTP server. This box is connected to my ISP via ADSL router.

Now it is serving fine as webserver, FTP for external clients/Public and  providing internet to my LAN Clients.

In order to have security, to start with i have implemented a basic rule of iptables on the same server.

Rules are below :
#comments
#LanIP - 172.16.0.0 - 255 / 255.255.0.0 - alias - eth0
#static IP - xx.xx.xx.xx - alias eth1 - external NIC
#172.16.0.1 - alias - eth0 - internal NIC

#(1) policies ( default)
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

#(2) User-defined chain for ACCEPTED TCP packets
iptables -N okay
iptables -A okay -p TCP --syn -j ACCEPT
iptables -A okay -p TCP -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A okay -p TCP -j DROP

#(3) INPUT chain rules

# Rules for incoming packets from LAN
iptables -A INPUT -p ALL -i  eth0  -s 172.16.0.0/255.255.0.0 -j ACCEPT
iptables -A INPUT -p ALL -i  lo    -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -p ALL -i  lo    -s 172.16.0.1 -j ACCEPT
iptables -A INPUT -p ALL -i  lo    -s xx.xx.xx.xx -j ACCEPT
iptables -A INPUT -p ALL -i  eth0  -d 172.16.0.255 -j ACCEPT

# Rules for incoming packets from the internet
# Packets for established connections
iptables -A INPUT -p ALL -d xx.xx.xx.xx -m state --state ESTABLISHED,RELATED -j ACCEPT

#Rules for incoming packets from the internet to LAN
iptables -A INPUT -p tcp --sport telnet -j REJECT

# TCP rules
iptables -A INPUT -p TCP -i eth1 -s 0/0 --destination-port 21 -j okay
iptables -A INPUT -p TCP -i eth1 -s 0/0 --destination-port 22 -j okay
iptables -A INPUT -p TCP -i eth1 -s 0/0 --destination-port 80 -j okay
iptables -A INPUT -p TCP -i eth1 -s 0/0 --destination-port 113 -j okay


#UDP rules
iptables -A INPUT -p UDP -i eth1 -s 0/0 --destination-port 53 -j ACCEPT
iptables -A INPUT -p UDP -i eth1 -s 0/0 --destination-port 2074 -j ACCEPT
iptables -A INPUT -p UDP -i eth1 -s 0/0 --destination-port 4000 -j ACCEPT

#ICMP rules
iptables -A INPUT -p ICMP -i eth1 -s 0/0 --icmp-type 8 -j ACCEPT
iptables -A INPUT -p ICMP -i eth1 -s 0/0 --icmp-type 11 -j ACCEPT

# (4) FORWARD chain rules
# Accept the packets we want to forward
iptables  -A FORWARD -i eth0 -j  ACCEPT
iptables  -A FORWARD -i eth1 -j ACCEPT
iptables  -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

# (5) OUTPUT chain rules
#only output packets with local address ( no spoofing )
iptables -A OUTPUT -p ALL -s 127.0.0.1 -j ACCEPT
iptables -A OUTPUT -p ALL -s 172.16.0.1 -j ACCEPT
iptables -A OUTPUT -p ALL -s xx.xx.xx.xx -j ACCEPT

# (6) POSTROUTING chain rules - Main Connection for connecting to Internet - ROUTER
iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to-source xx.xx.xx.xx



Now the problem is i am able to browse the internet from client but not from my INTserver console.I am also able to connect to all the sites via http or ftp or telnet immediately from the client. If i try to connect to ftp server or webserver on INTserver from the client, it is taking long time. Same way public also taking time to connect.

If i stop the iptable then i can connect to internet in INTserver console itself.

What will be the problem? Seems to have proble with rule.

Any suggestions or Any help will be appreciated....

Also how i can block particular range of internal or external ip address or machine address sending request (accessing the server) in or out ie both from internal(LAN) or external(from internet)
 
Related Solutions
 
Loading Advertisement...
 
[+][-]02/27/04 09:08 AM, ID: 10470834Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Linux Networking
Tags: iptables
Sign Up Now!
Solution Provided By: amp
Participating Experts: 5
Solution Grade: A
 
[+][-]02/07/03 01:31 PM, ID: 7905812Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/07/03 01:40 PM, ID: 7905852Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/07/03 01:56 PM, ID: 7905942Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/07/03 02:11 PM, ID: 7906029Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/10/03 07:55 AM, ID: 7918316Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/10/03 07:57 AM, ID: 7918338Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/10/03 09:56 AM, ID: 7919203Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/10/03 10:26 AM, ID: 7919391Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/10/03 10:26 AM, ID: 7919400Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/11/03 03:53 AM, ID: 7924640Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/12/03 11:21 PM, ID: 7939990Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/05/03 12:46 AM, ID: 9077869Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/23/04 01:21 AM, ID: 10430576Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92