# host redirection via ipfw



## SaveTheRbtz (Dec 16, 2008)

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 (Dec 17, 2008)

Oh, i guess i was so sleepy that missed thread... somebody move it to Firewalls.


----------



## blackjack (Dec 17, 2008)

ipfw add fwd 192.168.0.1,8080 ip from $my_net to me 80


----------



## SaveTheRbtz (Dec 18, 2008)

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 (Dec 22, 2008)

=( 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 (Dec 24, 2008)

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 [thread=230]this thread[/thread].


----------



## paulfrottawa (Dec 26, 2008)

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.


----------

