LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 10-29-2004, 02:00 PM   #1
andrewjjones
Member
 
Registered: Sep 2004
Distribution: Mandrake 10
Posts: 48

Rep: Reputation: 15
Server from inside LAN


Now I have my linux internet gateway going, I'm thinking of setting up a web server. This is what my LAN looks like at the moment:

Code:
             --------------
            |              | -- 192.168.0.1
internet -- | 192.168.0.10 | -- 192.168.0.2
            |              | -- 192.168.0.20
            |              | -- 192.168.0.21
             --------------
Is is possible to run apache on say, 192.168.0.1, but so it can be 'seen' from the internet?
 
Old 10-29-2004, 02:12 PM   #2
NetAX
Member
 
Registered: Mar 2004
Location: Boston, MA
Distribution: SuSE Linux Open/Enterprise, Red Hat, Ubuntu
Posts: 147

Rep: Reputation: 17
You can have your webserver visible on both internal/external networks. You will have to add the IP address going to the internet/modem to your DNS record. Doing that will allow the domain to be resolved by the DNS. Apache will then use IP address that was used to resolve the domain, and forward pages to the requesting computer.

DNS confignot the exact configuration)

A 192.168.0.1 ( IP used for the internal network)
A 138.53.23.1 (IP address assigned to the external NIC. This could be private if your modem is also a router that uses private IP addressing)



When you finish editing the DNS configuration restart apache, then type httpd -s or if your using apache 2 httpd2 -s

This will list the IP addresses that apache will respond to.
 
Old 10-29-2004, 02:14 PM   #3
jeickal
Member
 
Registered: Oct 2004
Distribution: Mandrake, DSL, SuSE, RedHat
Posts: 71

Rep: Reputation: 15
Sure it is
You need to configure NAT/PAT on your router.

You have to redirect anything comming from the web to the TCP port 80 of you router to your PC where you webserver is running.

Check out your router's doc, it should tell you how to. I can give you an example I did with mine if you want
 
Old 10-29-2004, 02:20 PM   #4
jeickal
Member
 
Registered: Oct 2004
Distribution: Mandrake, DSL, SuSE, RedHat
Posts: 71

Rep: Reputation: 15
This will probably interest you ==> http://www.dyndns.org/services/dyndns/
You can freely register a hostname for you webserver there. Sth like mywebserver.linuxhome.org
So that you can give your friends sth else than a lame IP@ they'll never remember.

Note that if you didn't ask you ISP for a static IP you'll have to update it on the site regularly.
 
Old 10-29-2004, 02:27 PM   #5
andrewjjones
Member
 
Registered: Sep 2004
Distribution: Mandrake 10
Posts: 48

Original Poster
Rep: Reputation: 15
Thing is it's not really a router. It's just a gateway... or is that the same thing? I don't have any DNS servers set up either. Sorry, but I'm not exactly a networking expert!
 
Old 10-29-2004, 02:40 PM   #6
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
iptables -t net -A PREROUTING ! -i $EXT_IFACE -p tcp --destination-port 80 -j DNAT --to 192.168.0.1:80


Er something of this nature to forward all requests from the external iface to the internal machine. I just copied pasted this from "Linux Server Hacks"
 
Old 10-29-2004, 02:49 PM   #7
jeickal
Member
 
Registered: Oct 2004
Distribution: Mandrake, DSL, SuSE, RedHat
Posts: 71

Rep: Reputation: 15
You don't need no local DNS server if you use the service provided on the site I gave you. They do it for you. They match yourwebserver.linuxhome.org (in my ex to the public IP address (provided by you ISP) of your router/gateway (whatever, doing the same job).

It works like this:

Internet <=====> Public IP of router --- 192.168.0.10 <======> local LAN

People out there on the web only see you public IP, there is no way they can see 192.168.x.x IP. So each connection from the web to you local LAN will use you gateway's public IP address.
Each service you wanna provide use a diferent TCP port number like for a web server, HTTP uses port 80 (FTP is 21, SMTP (email) use 25 etc...).

So to allow people from the net to reach the port 80 of your PC (the one with the webserver), you need to redirect all the connection reaching the public IP of your gateway on the port 80 to the IP of your webserver.

micxz post up there is showing you how to do it.
Hope my extra explanation will help you understand it
 
Old 11-02-2004, 04:57 PM   #8
andrewjjones
Member
 
Registered: Sep 2004
Distribution: Mandrake 10
Posts: 48

Original Poster
Rep: Reputation: 15
Yes, that's great. Thanks a lot!
 
Old 01-08-2005, 10:34 AM   #9
andrewjjones
Member
 
Registered: Sep 2004
Distribution: Mandrake 10
Posts: 48

Original Poster
Rep: Reputation: 15
Quote:
iptables -t net -A PREROUTING ! -i $EXT_IFACE -p tcp --destination-port 80 -j DNAT --to 192.168.0.1:80
Actually when I said that, I couldn't try it - I just presumed that it was right

I've finally got round to putting a monitor on the computer. But when I type it, I get told that the -p command 'contains wierd characters'
 
Old 01-08-2005, 06:07 PM   #10
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
"contains wierd characters" Is that the error?
 
Old 01-08-2005, 06:11 PM   #11
andrewjjones
Member
 
Registered: Sep 2004
Distribution: Mandrake 10
Posts: 48

Original Poster
Rep: Reputation: 15
Yes, that is the error
 
Old 01-08-2005, 06:20 PM   #12
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
You are doing this on the gateway computer right? Please paste what you have here.
 
Old 01-08-2005, 06:25 PM   #13
andrewjjones
Member
 
Registered: Sep 2004
Distribution: Mandrake 10
Posts: 48

Original Poster
Rep: Reputation: 15
Yes, 192.168.0.10. Post what exactly?
 
Old 01-08-2005, 06:33 PM   #14
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Copy paste the whole line you typed and the error. I'm not sure how else to help.
 
Old 01-08-2005, 06:46 PM   #15
andrewjjones
Member
 
Registered: Sep 2004
Distribution: Mandrake 10
Posts: 48

Original Poster
Rep: Reputation: 15
Okay, I typed:
iptables -t net -A PREROUTING ! -i $EXT_IFACE -p tcp --destination-port 80 -j DNAT --to 192.168.0.1:80

And the computer said:
Warning: wierd character in interface '-p' (no aliases, :, ! or *)
Bad argument 'tcp'
 
  


Reply



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
Improoving net connection inside LAN. Palula Linux - Networking 2 08-28-2005 11:59 AM
Apache 2 Server - Can't access it via ip address from inside LAN Robstro Linux - Networking 1 06-30-2004 01:50 PM
Setting up a webserver inside a lan, which should be accessible from outside seidren Linux - Networking 2 05-18-2004 08:26 AM
pop3 inside and outside LAN clinger Linux - Software 2 03-20-2004 10:55 AM
DNS/email issues inside and out of LAN swingheim Linux - Networking 4 11-22-2003 01:02 PM

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

All times are GMT -5. The time now is 12:30 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