need some pointers for iptables

Posted on 2002-05-15
Last Modified: 2010-03-18
I've been reading docs for iptables for a week now, and still can't figure out how to do what I want to do. Here it is :

I have a firewall (one public interface, one private interface.) with 3 web servers behind it, I want the servers on a private subnet, say,,

All three servers have different hostname, and I have sufficient public IPs to handle them.

I need to set the firewall so that when it gets a request for it forwards to, goes to, and so on.

Can someone come up with a sample iptables script for me please ?
Question by:cgirouard

Expert Comment

ID: 7026513
I guess this cannot be done using iptables, because as far as I know it cannot handle DNS names - it's "just" an IP filter. I think what you need is to run squid on that machine, because it can act as a virtual host accelerator.

Edit squid's config file just like:
        httpd_accel_port 80
This should work.

You might use iptables if you redirect ports - meaning e.g. goes to and goes to and so on.

Accepted Solution

zzconsumer earned 100 total points
ID: 7027092
I just read a part of the Apache documentation today. Maybe what you need is mentioned there, so you don't need to run a squid proxy:

You may want to have a look at chapter 17, where there is an example on how to redirect a virtual server. The intention is another one, but as far as I can see, you might achieve what you need that way.

Expert Comment

ID: 7048601
What you want is static NAT. iptables can do this quite well, IIRC.
See the documentation on the REDIRECT target on how to achieve this.
Actually, why not give each server a publically routable IP address and remove the need to NAT?

Expert Comment

ID: 9078486
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
LVL 12

Expert Comment

ID: 10004261
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: zzconsumer {http:#7027092}

Please leave any comments here within the next seven days.

EE Cleanup Volunteer

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Layer 7 Transparent cookie checker 22 60
Fail2ban says an IP is banned, but not 12 117
Getting Ubuntu Linux Console to show boot beyond error notification 5 76
Linux neworking 4 77
I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now