hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : iptables redirect rule - please help
Reply

Hosting Security and Technology Configuring and optimizing web hosting servers and operating systems, developing administration scripts, building servers, protecting against hackers, and general security (SSL certificates, etc.)
Forum Jump

iptables redirect rule - please help

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 08-07-2009, 03:14 PM
SysTeam SysTeam is offline
Junior Guru Wannabe
 
Join Date: May 2007
Posts: 75

iptables redirect rule - please help


Hello!

Please help me to write iptables rule, I need to redirect specific external IPs to another IP instead main website IP.

Any way to do this?

Thank you!

Reply With Quote


Sponsored Links
  #2  
Old 08-07-2009, 03:30 PM
khunj khunj is offline
Web Hosting Guru
 
Join Date: Mar 2009
Location: /home/khunj
Posts: 313
Try something like this :

Code:
fromIP=xx.xx.xx.xx
fromPort=xx
toIP=xx.xx.xx.xx
toPort=xx
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING --dst $fromIP -p tcp --dport $fromPort -j DNAT --to-destination $toIP:$toPort
iptables -t nat -A POSTROUTING -p tcp --dst $toIP --dport $toPort -j SNAT --to-source $fromIP
iptables -t nat -A OUTPUT --dst $fromIP -p tcp --dport $fromPort -j DNAT --to-destination $toIP:$toPort

__________________
NinTechNet : IT Security, Virus & Hacking Recovery, Monitoring

Reply With Quote
  #3  
Old 08-07-2009, 03:39 PM
SysTeam SysTeam is offline
Junior Guru Wannabe
 
Join Date: May 2007
Posts: 75
What does it mean?

Quote:
--dport $fromPort
Which port I need to specify, if this is standard request from user to website?

Reply With Quote
Sponsored Links
  #4  
Old 08-07-2009, 09:03 PM
khunj khunj is offline
Web Hosting Guru
 
Join Date: Mar 2009
Location: /home/khunj
Posts: 313
Your visitors will connect to fromIP:fromPort and then iptables will redirect them to toIP:toPort
Note that due to SNAT/DNAT, when your visitors will reach toIP, their IP will be fromIP, not their originating IP. If you need to identify them, use preferably a HTTP reverse proxy that will add their originating IP in the X-Forwarded-For variable.

__________________
NinTechNet : IT Security, Virus & Hacking Recovery, Monitoring

Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete rule in iptables Adwis Hosting Security and Technology 3 08-15-2011 12:15 PM
The VPS iptables rule limit persianwhois Hosting Security and Technology 3 08-07-2008 10:59 AM
Iptables rule limit (numiptent) persianwhois Hosting Security and Technology 4 06-02-2008 03:47 AM
iptables rule for ftp SmartTux Hosting Security and Technology 4 01-07-2005 12:38 PM
iptables rule assistance enquire Hosting Security and Technology 3 09-03-2004 02:56 AM

Related posts from TheWhir.com
Title Type Date Posted
CloudFlare Crashes After Juniper Edge Routers Fail Web Hosting News 2013-03-04 15:31:30
Branding and Positioning in the Hosting Industry -- HostingCon 2012 Web Hosting News 2012-07-17 14:36:34
CoreLink Completes Data Center Audit, Establishes HIPAA Compliant Hosting Web Hosting News 2012-03-27 12:55:43
Google to Build $300 Million, 300K-Square-Foot Hong Kong Data Center Web Hosting News 2011-12-09 15:58:44
Officials Arrest Six Estonians in DNSChanger Cybercrime Bust Web Hosting News 2011-11-10 21:52:48


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?