February 03, 2023, 04:32:51 AM

News : LinuxSolved.com Linux Help Community Forum..

Author Topic: Static NAT How to  (Read 2282 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-

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...

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]
EXTIP=<external ip address>

# ----- 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.