LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-14-2005, 03:09 PM   #1
patvrs
LQ Newbie
 
Registered: Jul 2005
Posts: 12

Rep: Reputation: 0
forward ip to another


Hi
i'm using iptables for the first time..
masquerade work very well

but i would like to redirect an ip to another.. all ports
for example: 64.233.167.147 (google ip) to 192.168.0.11
so:
ping 64.233.167.147 .. will ping 192.168.0.11
telnet 64.233.167.147 will telnet to 192.168.0.11
ht1p://64.233.167.147/test.html .. will show ht1p://192.168.0.11/test.html

my setup:
192.168.0.10 is my server/router
192.168.0.20,21,22,... get internet acces from 192.168.0.10...

thanks
sorry for bad english..
 
Old 07-14-2005, 03:14 PM   #2
demian
Member
 
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303

Rep: Reputation: 30
iptables -A PREROUTING -d 64.233.167.147 -j DNAT --to 192.168.0.11
 
Old 07-14-2005, 03:45 PM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
You forgot the nat table
Code:
iptables -A PREROUTING -t nat -d 64.233.167.147 -j DNAT --to 192.168.0.11
[edit]
There is also another solution...

Add the IP in your /etc/hosts like:
Code:
...
192.168.0.11    www.google.com google.com

Last edited by keefaz; 07-14-2005 at 03:50 PM.
 
Old 07-14-2005, 05:14 PM   #4
patvrs
LQ Newbie
 
Registered: Jul 2005
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by keefaz
You forgot the nat table
Code:
iptables -A PREROUTING -t nat -d 64.233.167.147 -j DNAT --to 192.168.0.11
[edit]
There is also another solution...

Add the IP in your /etc/hosts like:
Code:
...
192.168.0.11    www.google.com google.com
cool it's working
thanks !

for the /etc/hosts.. it's what I used before .. but it<s local only.. so I needed to change hosts file of each computer...

and if I connect my laptop to another network.. (outside of my network) ... I want to use the "true" www.google.com

another question...
so.. www.google.com will be redirect to 192.168.0.11
because 64.233.167.147=www.google.com
btw.. www.google.com has 3 ip.. and if I do "iptables [..] -d www.google.com" .. one filter are added for each three ip.. but anyways.. my domain has only one ip
but what happen if www.google.com become 64.64.64.64
answer.. next time I restart my server.. or iptables script ..if I used "-d www.google.com" all will be okay ..

but i need to restart my server or my script..
idea ?

ps: it's so funny.. i think i will redirect www.altavista.com -> www.google.com for fews days.. and see if my users like it
 
Old 07-14-2005, 05:28 PM   #5
demian
Member
 
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303

Rep: Reputation: 30
iptables knows about ip addresses only. If you set up a rule using a fully qualified domain name it will do a lookup on that name and create a rule for all ip addresses found at the time the lookup is done. So, yes, if the ip address changes the redirect won't work anymore. If you want to redirect altavista to google you should think about setting up a squid proxy. Then you can instruct squid to rewrite requests for www.altavista.com to www.google.com. Using iptables DNAT will cause the URL in the address bar to still display www.altavista.com when people are infact seeing the google page. I guess that will be quite confusing to most users.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
ip forward syl20 Linux - Networking 5 12-03-2004 10:25 AM
I want .forward to not forward attachments nigelj12 Linux - Software 1 09-30-2004 03:13 PM
cant see .forward file in home directory >> mail forward/copy steve_babbage Linux - Newbie 0 03-02-2004 06:25 AM
iptables FORWARD ArnaudVR Linux - Security 6 07-07-2003 05:05 PM
Port forward help please hanxuerui Linux - Networking 6 05-05-2003 01:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration