PDA

View Full Version : Forward external IP to internal network


Dane
November 20th, 2009, 09:10
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
November 20th, 2009, 09:12
Use any of the three firewalls to forward a port (or all of them) to the internal IP address.

Dane
November 20th, 2009, 09:50
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
November 20th, 2009, 11:02
Using PF (Handbook: 30.4 The OpenBSD Packet Filter (PF) and ALTQ (http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/firewalls-pf.html)):

/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, etc. etc. }"

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
November 20th, 2009, 12:47
PF is recommend. Another option is to use natd and ipfw. It is also documented in handbook.