1. Subscriptions
  2. Services
  3. Hardware
  4. Support

ClearFoundation

Home Forums
Welcome, Guest

Need help - REDIRECT traffic to a different port
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: Need help - REDIRECT traffic to a different port
#4961
Need help - REDIRECT traffic to a different port 1 Month ago  
I can't get my brain wrapped around this..
I want to force some IP addresses through the proxy/content filter transparently, but not all of them.

I know that to do that I need to force requests to port 80 on those IPs to port 8080, and also block access to port 3128. I just don't know how the heck to write the iptable rule to do it, or exactly where to place it.

If someone familiar with iptables can help me out I'd really appreciate it.
thanks
J Kelly
Fresh Boarder
Posts: 15
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#4972
Re: Need help - REDIRECT traffic to a different port 1 Month ago  
Have a play with:-
Code:

iptables -t nat -I PREROUTING -i eth0 -s 192.168.0.5 -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -I INPUT -i eth0 -s 192.168.0.5 -p tcp --dport 3128 -j DROP


Change 192.168.0.5 to what ever IP you want to redirect.
Assumes eth0 is your LAN interface,
Change --to-ports 3128 to direct to proxy instead of content filter on 8080

Review your changes by using, if it doesn't work wipe it out with 'service firewall restart'
Code:

iptables -t nat -L -n -v
iptables -L -n -v


If everything works as you want it then add the lines to /etc/rc.d/rc.firewall.local so that they stick after the firewall restarts.
Tim Burgess
Moderator
Posts: 793
graph
User Offline Click here to see the profile of this user
Last Edit: 2010/02/08 04:55 By timb80.
The administrator has disabled public write access.
Nothing is fool proof to a talented fool
http://starlane.gotdns.org
RPM FTP Mirror
 
#4984
Re: Need help - REDIRECT traffic to a different port 1 Month ago  
Thanks Tim!

I'll give that a try when I'm at home tonight.

Can I substitute the IP address for a range of IP's?

How about filtering it by MAC instead of IP? I haven't seen anything in the iptables docs that says I can, so I'm assuming not.
J Kelly
Fresh Boarder
Posts: 15
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#4986
Re: Need help - REDIRECT traffic to a different port 1 Month ago  
you can specify subnets in the CIDR form 192.168.0.0/24 for example

I'[ve not tried but you maybe able to do something similar with -m mac --mac-source AA:BB:CC:DD:EE. But as mac address can be spoofed i'm not sure it's worth it?
Tim Burgess
Moderator
Posts: 793
graph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
Nothing is fool proof to a talented fool
http://starlane.gotdns.org
RPM FTP Mirror
 
#4987
Re: Need help - REDIRECT traffic to a different port 1 Month ago  
I'm not worried about someone spoofing the MAC. It's a home network, just trying to keep my kids from the naughtier bits of the internet. I can see scenarios where the IP could get changed, but the MAC will stay the same.

I'll give both methods a try and let you know how it works out.
Thanks again.
J Kelly
Fresh Boarder
Posts: 15
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#5027
Re:Need help - REDIRECT traffic to a different port 1 Month ago  
Tim-

This works beautifully!! Both the IP method and the MAC method worked.
Thanks much! I really appreciate the help.

Now if we could come up with a webconfig module, but I highly doubt I can figure out the php to do that, LOL.
J Kelly
Fresh Boarder
Posts: 15
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#5039
Re:Need help - REDIRECT traffic to a different port 1 Month ago  
Great no problems, we should add it to the wish list
Tim Burgess
Moderator
Posts: 793
graph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
Nothing is fool proof to a talented fool
http://starlane.gotdns.org
RPM FTP Mirror
 
Go to topPage: 1
  get the latest posts directly to your desktop