November 25, 2024, 07:33:36 AM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: Static NAT How to  (Read 4240 times)

Offline stephen

  • Linux Learner
  • ***
  • Posts: 56
Static NAT How to
« on: September 17, 2006, 05:56:05 AM »
Dear all,

 This is Stephen logging after a long time...
Hi i am having a new server and new leased line ...
These are all i am having...
1) A new brand server with fedora core2 linux
2)Leased line with 6 ip public ip
3)Existing local linux apache server(Example-192.168.15.5)

Here our boss asked me to setup static nat over the new linux and the apache(ie)i want to nat the linux server public address to a static nat of my apache server.He don't want to put the public ip in my apache...
If i call the public address of new linux,it should call my apache server (which is local ip)...
As well as i want to nat some other nat in my linux server for the other public ips..

How to setup the above . Pls help me to do the thing...

Thanks in Advance...
Stephen.J

Offline Ricky

  • LST CareTaker
  • Specially Skilled
  • *****
  • Posts: 2381
Static NAT How to
« Reply #1 on: September 18, 2006, 03:11:06 PM »
It means ur boss want ur apache to be inside the lan but also want its available to public for http serving. You need to do port forwarding ie. all request to port 80 to be forwarded to internal apache server located inside ur lan.

I found an small script for that
Code: [Select]
XTIF="ppp0"
INTIF="eth0"
EXTIP=<external ip address>
PORTFWIP="192.168.1.6"
INTNET="192.168.1.0/24"

# ----- Begin OPTIONAL FORWARD Section -----
#
# Allow forwarding of new and existing port 80 connections
#
$IPTABLES -A FORWARD -i $EXTIF -o $INTIF -p tcp --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

#Enable PORTFW of this port 80 traffic
#
$IPTABLES -A PREROUTING -t nat -p tcp -d $EXTIP --dport 80 -j DNAT --to $PORTFWIP:80

Add that in NAT and its done.