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-11-2005, 04:49 PM
|
#1
|
Member
Registered: May 2004
Posts: 46
Rep:
|
port address tranlstion
ive been struggling with this for days, wondering if any one cud give me some help.
i need to apply port address translation (overloaded network address translation) to all traffic originating on my network and destined for the outside network and beyond - using iptables.
any ideas on a command?
cheers for any help
|
|
|
12-11-2005, 06:55 PM
|
#2
|
Senior Member
Registered: Mar 2003
Distribution: Fedora
Posts: 3,658
Rep:
|
Could you explain a bit more about what you'd like to do? Are you trying to do Port->Host mappings or load-balancing? Or did you mean NAT?
|
|
|
12-12-2005, 09:36 AM
|
#3
|
Member
Registered: May 2004
Posts: 46
Original Poster
Rep:
|
NAT i think, im really stuck - this is what i have at the moment
externalinterface="eth1"
externaladdress="`ifconfig $externalinterface | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`"
iptables -t nat -A PREROUTING -p tcp -i eth0 -d $externaladdress --dport 80 --sport 1024:65535 -j DNAT --to 172.24.15.0:8080
iptables -t nat -A PREROUTING -p tcp -i eth0 -d $externaladdress --dport 443 --sport 1024:65535 -j DNAT --to 172.24.15.0:8080
to me it seems like it shud work but i dunno lol
|
|
|
12-12-2005, 10:49 AM
|
#4
|
Senior Member
Registered: Mar 2003
Distribution: Fedora
Posts: 3,658
Rep:
|
That looks like it should work for the DNAT part. Do you have rules to handle the outgoing traffic (like SNAT or Masquerading)? Also do you have rules in the FORWARD chain to pass packets from the external to internal interfaces (and vice versa)? Did you enable packet forwarding in the kernel (echo "1" > /proc/sys/net/ipv4/ip_forward)?
|
|
|
12-12-2005, 11:01 AM
|
#5
|
Member
Registered: May 2004
Posts: 46
Original Poster
Rep:
|
Quote:
Originally Posted by Capt_Caveman
That looks like it should work for the DNAT part. Do you have rules to handle the outgoing traffic (like SNAT or Masquerading)? Also do you have rules in the FORWARD chain to pass packets from the external to internal interfaces (and vice versa)? Did you enable packet forwarding in the kernel (echo "1" > /proc/sys/net/ipv4/ip_forward)?
|
i havent enabled port forwarding ill try that now, i have snat rules but i think they are in the same condition as my dnat rules lol and i have the following for the FORWARD chain:
iptables -A FORWARD -p tcp -s 192.168.0.0/16 -d 172.24.15.1 --dport 443 -j ACCEPT
iptables -A FORWARD -p tcp -s 192.168.0.0/16 -d 172.24.15.1 --dport ! 80 -j DROP
cheers for the help, much appreciated
|
|
|
12-12-2005, 01:19 PM
|
#6
|
Senior Member
Registered: Jan 2003
Location: Portland, OR USA
Distribution: Slackware, SLAX, Gentoo, RH/Fedora
Posts: 1,024
Rep:
|
Quote:
Originally Posted by cashton2k
NAT i think, im really stuck - this is what i have at the moment
externalinterface="eth1"
externaladdress="`ifconfig $externalinterface | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`"
iptables -t nat -A PREROUTING -p tcp -i eth0 -d $externaladdress --dport 80 --sport 1024:65535 -j DNAT --to 172.24.15.0:8080
iptables -t nat -A PREROUTING -p tcp -i eth0 -d $externaladdress --dport 443 --sport 1024:65535 -j DNAT --to 172.24.15.0:8080
to me it seems like it shud work but i dunno lol
|
So your intent is to send all web (port 80 http and 443 https) requests to a proxy server?
Two things I noticed are that the NAT rules you set up seem too specific and you are forwarding to what appears to be a network address, rather than a specific host. Try something like:
Code:
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 80 -j DNAT --to 172.24.15.5:8080
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 443 -j DNAT --to 172.24.15.5:8080
where 172.24.15.5 is the actual IP of the proxy server.
|
|
|
All times are GMT -5. The time now is 07:10 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
|
|