# Forward external IP to internal network



## Dane (Nov 20, 2009)

I have three ethernet interfaces.
First looks in Internet and has a external IP
Second and third - are local network.
FreeBSD on server installed as a gateway.
I've a pool of external IPs that belong to second interface. I need to forward one of that external IPs to third interface (so network of third interface can use external IP).

Can you help me?
Sorry for my bad english.


----------



## SirDice (Nov 20, 2009)

Use any of the three firewalls to forward a port (or all of them) to the internal IP address.


----------



## Dane (Nov 20, 2009)

SirDice said:
			
		

> Use any of the three firewalls to forward a port (or all of them) to the internal IP address.



Thanks for your answer. All three ethernet interfaces are on one server and so I can use one firewall to all of them. Would you please to teach me how to do that (what commands) so to forward all packets from local network of third interface to internet with substitute of internal IP to external IP and that the local network of third interface will be reachable from internet with sertain external IP.
Exaple:
First interface: 83.103.103.83 default gateway
Second interface: 192.168.1-8.0/24
                  83.103.103.201/255.255.255.248
Third interface: 192.168.103-109.0/24

Need to:
All packets from 192.168.107.1 goes to 83.103.103.201 with external IP 83.103.103.203.

I'm novice in this, but I'll try to do my best to explain what I need to do.


----------



## SirDice (Nov 20, 2009)

Using PF (Handbook: 30.4 The OpenBSD Packet Filter (PF) and ALTQ):

/etc/pf.conf

```
# Replace these with yours
ext_if="rl0"
int_if1="rl1"
int_if2="rl2"
webserver="192.168.103.223" # use what you need

localnetwork="{ 192.168.1.0/24, 192.168.2.0/24, [b]etc. etc.[/b] }"

nat on $ext_if from $localnetwork to any -> ($ext_if)

rdr on $ext_if inet proto tcp to port 80 -> $webserver port 80
```

I suggest reading http://www.openbsd.org/faq/pf/


----------



## vivek (Nov 20, 2009)

PF is recommend. Another option is to use natd and ipfw. It is also documented in handbook.


----------

