LinuxQuestions.org
Visit Jeremy's Blog.
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 09-14-2004, 04:32 AM   #1
swmok
Member
 
Registered: Jul 2003
Posts: 152

Rep: Reputation: 30
Change the destination URL by IPTABLES


Hello:

I would like to change the destination URL of the client by IPTABLES.

The command I used is:

/sbin/iptables -t nat -A PREROUTING -i eth1 -p tcp -s 10.100.129.0/24 --dport 80 [what should I do here]

The command checks that:
If the client IP is 10.100.129.0/24,
don't care about the original URL (may be "www.hotmail.com" or "www.myserver.com/abc")
it goes to "www.hello.com".

Pls. HELP!
Thanks.
 
Old 09-14-2004, 05:42 AM   #2
ppuru
Senior Member
 
Registered: Mar 2003
Location: Beautiful BC
Distribution: RedHat & clones, Slackware, SuSE, OpenBSD
Posts: 1,791

Rep: Reputation: 50
This thread is perhaps a continuation of the discussion below ...
http://www.linuxquestions.org/questi...hreadid=228165

However, take a look at this Linux Hack from OReilly
 
Old 09-14-2004, 08:35 AM   #3
swmok
Member
 
Registered: Jul 2003
Posts: 152

Original Poster
Rep: Reputation: 30
Yes. This is the OLD questions but ...

Hi:

I am sorry that I post the OLD question. I just rephrase it.

Why? It is because noone can answer my question. They just say read this and read that.

Actuall I've tried all your suggestions and nothing works.

My NAT server is activated and I just add a command to block all the clients 10.100.129.0/24.
These clients go to the NAT apache.

When this client goes to "www.hotmail.com" or "www.yahoo.com", it is redirected to the NAT server homepage.
It works by this command.

/sbin/iptables -t nat -A PREROUTING -i eth1 -p tcp -s 10.100.129.0/24 --dport 80 -j REDIRECT --to-port 80



However, when this client goes to "www.xxxxx.com/abcabc", it is redirected to "www.[NAT server].com/abcabc" and the apache inside the NAT server cannot find and homepage and return an error.
It can only replace www.[client input server].com by www.[NAT server].com. Not redirect.

Thus, pls. help. How can I do this?

thanks
 
Old 09-14-2004, 09:42 AM   #4
xinu
LQ Newbie
 
Registered: Sep 2004
Location: tty0, tty7 and sometimes tty2
Distribution: Gentoo, Debian
Posts: 10

Rep: Reputation: 0
The regular iptables works with IP/MAC addresses, perhaps you could achive the whole thing with dnsmasq or other DNS software.

I suggest you tweak the dnsmasq (or other dns soft of your choice) to simply reply www.example.com domains with the IP address of www.example.org.

With iptables you may just forward all traffic coming from your lan with a destination port of 53 (dns, for example if they are trying to connect to a dns server outiside) to the gateway's port 53.

Code:
# Forwards all dns traffic to the gateway:
/usr/sbin/iptables -t nat -A PREROUTING -i $local_interface -p UDP --dport 53 -j REDIRECT --to-ports 53
 
Old 09-14-2004, 11:33 AM   #5
ppuru
Senior Member
 
Registered: Mar 2003
Location: Beautiful BC
Distribution: RedHat & clones, Slackware, SuSE, OpenBSD
Posts: 1,791

Rep: Reputation: 50
swmok, any luck with the rinetd stuff - from Linux Hack#48
 
  


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
change port using destination alaios Linux - Networking 3 03-01-2005 04:06 AM
iptables - Blocking an URL ddaas Linux - Security 2 10-14-2004 06:36 PM
iptables logging destination Strikeman Linux - Security 1 03-12-2004 12:45 PM
iptables - source ? destination ? From where ? Dek Linux - Networking 3 04-30-2003 11:43 PM
IPTABLES --to-destination muliple ip:port hawk4eye Linux - Networking 4 02-07-2003 04:59 AM

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

All times are GMT -5. The time now is 03:05 AM.

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