PDA

View Full Version : host redirection via ipfw


SaveTheRbtz
December 17th, 2008, 00:58
On our gateway we have FrreBSD with ipfw.
Sometimes we need to redirect all clients requests going to 80 port to out internal server's port 8080. What rule should I add to ipfw to do this?
I'm kinda lost with this fwd and divert commands.

SaveTheRbtz
December 17th, 2008, 07:57
Oh, i guess i was so sleepy that missed thread... somebody move it to Firewalls.

blackjack
December 17th, 2008, 08:39
ipfw add fwd 192.168.0.1,8080 ip from $my_net to me 80

SaveTheRbtz
December 18th, 2008, 01:41
Thank you! In my case rule will look like
ipfw add fwd 192.168.0.1,8080 ip from $my_net to any 80
It's for isp's gateway.
General meaning of this is to pass _any_ request for web page to our dedicated web server from any user whose balance < 0. Web server has mini-faq about paying for Internet.

SaveTheRbtz
December 22nd, 2008, 16:50
=( No this code doesn't work =(
Requests to 192.168.0.1 arrives as
"all tcp 78.108.88.83:80 <- *.*.*.*:61726"

So there is no change in destination address and port.
How can i make ipfw change dst addr&port?

Or can i do it on webserver FreeBSD box (on which that requests arrives). It has only pf.

aragon
December 25th, 2008, 00:42
I don't think you can use fwd in the manner you describe. It's only useful for forwarding packets on the same localnet.

Use NAT. Read natd(8) and see this thread.

paulfrottawa
December 26th, 2008, 07:49
natd -redirect_port 192.168.0.1:8080 8080 public_ip:80 -interface vr0


Im not good but no tells you about the last part.