LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-04-2017, 03:10 AM   #1
sunils1973
Member
 
Registered: Jan 2007
Location: INDIA
Distribution: Ubuntu, Debian
Posts: 340

Rep: Reputation: 30
Port forwarding help


Friends,

The networking setup in my office is as follows.

One Ubuntu machine with 2 NIC is made as a gateway

eth1 : The Public interface which is connected to the modem
The IP no 192.168.1.1 is assigned(dhcp) in eth1 interface

We have static IP address provided by the ISP (117.218.X.X)


eth0 : The Local interfaces connecting to internal
(static IP assigend as 192.168.0.78)
machines(192.168.0.x/255.255.255.0)

Now, a web application has been developed in LAMP and hosted in the machine 192.168.0.48 and is available to around 50 computers in our office.

We would like to this machine 192.168.0.48 as a public server so that the sub offices (around 200 nos) can access the application. I think port forwarding the procedure and adding the following rules to the iptables will work ( Am I correct?)

#iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT --to 192.168.0.48:80

#iptables -A FORWARD -p tcp -d 192.168.0.48 -j ACCEPT

This is the iptables rules of the gateway

===============================================

:PREROUTING ACCEPT [19:1629]

:INPUT ACCEPT [8:693]

:OUTPUT ACCEPT [3:178]

:POSTROUTING ACCEPT [1:73]

-A POSTROUTING -o eth0 -j MASQUERADE

COMMIT

# Completed on Thu Jul 30 12:24:51 2015

# Generated by iptables-save v1.4.21 on Thu Jul 30 12:24:51 2015

*filter

:INPUT ACCEPT [22:1237]

:FORWARD ACCEPT [5:420]

:OUTPUT ACCEPT [18:762]

-A FORWARD -i eth1 -j ACCEPT

COMMIT
=============================================================


If I am wrong, correct and guide me [It is urgent pls]
 
Old 07-05-2017, 05:39 AM   #2
camp0
Member
 
Registered: Dec 2016
Location: Dublin
Distribution: Fedora
Posts: 70

Rep: Reputation: 4
Did you check the value of /proc/sys/net/ipv4/ip_forward? Should be one by the way
 
Old 07-10-2017, 05:18 AM   #3
sunils1973
Member
 
Registered: Jan 2007
Location: INDIA
Distribution: Ubuntu, Debian
Posts: 340

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by camp0 View Post
Did you check the value of /proc/sys/net/ipv4/ip_forward? Should be one by the way
It is 1
 
Old 07-10-2017, 05:34 AM   #4
sunils1973
Member
 
Registered: Jan 2007
Location: INDIA
Distribution: Ubuntu, Debian
Posts: 340

Original Poster
Rep: Reputation: 30
Now I have forwarded the port ( 80 ) in the router ( the ISP modem) and the machine is accessible to the public by using the static IP.

The modem is having network interfaces
1) Static IP 117.x.x.x as the incoming network from ISP
2) IP Nos 192.168.1.1 as the internal interface ( dhcp )

The Linux gateway has the following NICS

1) 192.168.1.2 from the modem.
2) 192.168.0.1 (Rules were already there as mentioned in the first post)

Now the web server is accessible from the internal machine 192.168.1.2, but I want to use a machine in 192.168.0.x as the web server using the IP tables rules of the gateway Ubuntu Machine.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] IPtables : ssh port forwarding one port to another port issue routers Linux - Networking 7 08-07-2018 08:41 AM
Redirec port in device eth0 to port+ip in device wlan0 ( port forwarding on hostpd wireless network) MattFly Linux - Networking 2 08-28-2016 07:21 PM
Shorewall: port forwarding problem, port is closed even after forwarding Synt4x_3rr0r Linux - Networking 2 12-13-2009 04:36 PM
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
Simple Port Forwarding Firewall - not forwarding MadTurki Linux - Security 14 04-09-2006 12:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration