LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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
 
LinkBack Search this Thread
Old 06-04-2005, 08:39 AM   #1
zippo85
Member
 
Registered: Dec 2004
Distribution: Fedora Core 3
Posts: 66

Rep: Reputation: 15
server at home, behind router


Basically, when I was at school I used apache to have a webserver, and I only really used it so I could listen to music at work and stuff. Now I'm at home and behind a router, and when I turn on apache and go to my IP it doesn't connect. I read some other posts, and I ended up going to 127.x.x or whatever that number is. Site came up. Now how do I get it to work for outsiders?
 
Old 06-04-2005, 10:05 AM   #2
Xolo
Member
 
Registered: Jul 2004
Location: The Netherlands
Distribution: Mandrake, Knoppix, Coyote Linux, RedHat
Posts: 354
Blog Entries: 3

Rep: Reputation: 30
The reason you can't connect to your own IP (Your public IP given to you by your ISP, which in this case will be given to the router) is because your router is doing NAT (Network Address Translation), which means it acts as the computer that is directly connected to the Internet, and 'shields' you off by creating a network of the machines you connect to it, yet allows you to have direct access to the internet from any machine connected to the router. Trying to go in from the 'outside' with your networked machines (by using your public IP) won't work, because the IP is outside your own network, and since your router doesn't run those services.. (Apache in this case) you'll find yourself staring into a black hole.
127.0.0.1 is the internal 'loopback' address of your own computer, it is a reserved address that exists on every computer. Using that address, you can connect directly to your own machine with a browser or somesuch if you are running a service such as Apache. However, 127.0.0.1 can not be used to refer to a machine on the internet, because it refers to the machine the request is sent from (Internal loopback).

To make machines outside your own network (from the Internet) able to access a machine inside your network, you need to set up port forwarding on your router.

Your Apache server will need a static IP address such as 192.168.0.1 (If you want to keep things simpler, for instance if you use DHCP to configure your Apache server's IP address, and you reboot it and it changes, you'll be forced to change the IP that your router uses to forward port 80 to.), and you'll need to set up your router to forward port 80 to your Apache server on that IP. That way, on the outside (The Internet) port 80 will become publicly available through your public IP, and any request sent to that port will be forwarded to your Apache server, by the router.
Have a look in your router's manual for specific instructions on how to set up port forwarding.
 
Old 06-08-2005, 09:29 AM   #3
zippo85
Member
 
Registered: Dec 2004
Distribution: Fedora Core 3
Posts: 66

Original Poster
Rep: Reputation: 15
Well, I gave it a shot and couldn't find anything on the router's software (it's microsoft base) that lets me forward to any ports. Am I going about this the wrong way?
 
Old 07-17-2005, 09:04 AM   #4
or1onas
Member
 
Registered: Mar 2004
Location: Athens,Greece
Distribution: Debian,Ubuntu
Posts: 181

Rep: Reputation: 30
It's a bit old thread, but fyi, i'm facing the exact same problem with you, and the only way i've found in order to make apache2 visible from outside is to add to /etc/hosts the fqdn of my dyndns.org account as an alias to the computer's hostname...
Can you try this and see if it works? On the other hand, i'm not sure if this kind of setup is a good one (i believe there has to be something on apache's conf in order to automatically accept requests for my dyndns name and not to have to add it to hosts...)
 
Old 07-17-2005, 09:30 AM   #5
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: arch, slackware 10.2
Posts: 2,020

Rep: Reputation: 45
Quote:
Originally posted by or1onas
It's a bit old thread, but fyi, i'm facing the exact same problem with you, and the only way i've found in order to make apache2 visible from outside is to add to /etc/hosts the fqdn of my dyndns.org account as an alias to the computer's hostname...
Can you try this and see if it works? On the other hand, i'm not sure if this kind of setup is a good one (i believe there has to be something on apache's conf in order to automatically accept requests for my dyndns name and not to have to add it to hosts...)
that seems a bit odd to me, but what do i know? have you tried to access the site on other computers outside your network and not just your own? it seems to me that resolving your dyndns.org account to localhost will just tell your local machine to do that. iow, when you are at your computer and you enter the dyndns.org address, /etc/hosts tells it to go to localhost, and so it just loops back to your own machine. you aren't really going out to the web at all, but just back to your own server. and as you might guess by now, that also won't affect computers other than the one on which you changed the /etc/hosts.

as Xolo already described, for other people to connect to you, you need to forward the http port (usually 80) on your router so that computers on the "other side" of the router can get through it to access your web server. that should be fairly easy to do if you look around in your router's configuration options. or else post what kind of router you have and someone will try to give more specific instructions.

Last edited by synaptical; 07-17-2005 at 09:34 AM.
 
Old 07-17-2005, 09:51 AM   #6
or1onas
Member
 
Registered: Mar 2004
Location: Athens,Greece
Distribution: Debian,Ubuntu
Posts: 181

Rep: Reputation: 30
Port-forwarding is certainly already set up on the router (zyxel 650R-31).
You're right though about hosts, it's not working...
I'm really stuck on this, any other ideas? Is there something i need to change in apache conf?
 
Old 07-17-2005, 10:23 AM   #7
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: arch, slackware 10.2
Posts: 2,020

Rep: Reputation: 45
Quote:
Originally posted by or1onas
Port-forwarding is certainly already set up on the router (zyxel 650R-31).
You're right though about hosts, it's not working...
I'm really stuck on this, any other ideas? Is there something i need to change in apache conf?
i guess the original thread is old enough that we can slightly "hijack" it here. it's about the same subject anyway, so it could help with the OP's problem. if it's not appropriate, one of the mods will probably let us know.

if you can connect to the server at all, that would seem to indicate the apache configuration is good. i would guess the problem is somewhere else, e.g., the dyndns configuration (can you post that info? in general terms if you want, etc.), or the router. are you absolutely sure the router is configured to allow port 80? some screen shots might help in case you have any doubts that it's set correctly.

just to be sure, however, it probably wouldn't hurt to post the first parts of your httpd.conf file, the global part and the first part of main, or whatever they call it. i.e., down to about right under where your first <Directory> "allow override," etc. options are. you can leave out all that stuff after that that you probably didn't mess with (unless you did mess with it, then post it. )
 
Old 07-17-2005, 10:37 AM   #8
or1onas
Member
 
Registered: Mar 2004
Location: Athens,Greece
Distribution: Debian,Ubuntu
Posts: 181

Rep: Reputation: 30
I'm working on ubuntu 5.04. The apache2 file structure is a bit different than of other distros.
apache2.conf shows the following (i've got them altogether):

AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
HostnameLookups Off
UseCanonicalName Off

and my 'default' site config shows:

NameVirtualHost *
<VirtualHost *>
ServerAdmin admin@localhost.

DocumentRoot "/var/www/"
<Directory />
Options FollowSymLinks -Indexes
AllowOverride None
</Directory>
<Directory /var/www/photos/eb2005>
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

It's working perfectly from LAN. Could there be something related to iptables maybe?
It's my first time trying to set up apache and i'm a bit of a newbie in general...
Oh, and thanx for helping me ;-)
 
Old 07-17-2005, 10:45 AM   #9
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: arch, slackware 10.2
Posts: 2,020

Rep: Reputation: 45
oh you have iptables? In that case, post the http part of your iptables script. i only know basic iptables stuff, but if it's anything more complicated a guru might chime in.

Last edited by synaptical; 07-17-2005 at 10:46 AM.
 
Old 07-17-2005, 10:55 AM   #10
or1onas
Member
 
Registered: Mar 2004
Location: Athens,Greece
Distribution: Debian,Ubuntu
Posts: 181

Rep: Reputation: 30
'iptables -L' produces this:

Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

is that ok?
 
Old 07-17-2005, 11:00 AM   #11
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: arch, slackware 10.2
Posts: 2,020

Rep: Reputation: 45
i think that just says you have no user rules yet.

go to /etc/init.d and find your iptables script (hopefully it will be called iptables), and search through it for anything that says http. you should have a line in there somewhere that says:

$IPTABLES -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT

if it's commented (has # in front of it), that's your problem. remove the comment mark and restart the service:

./iptables restart

then test your server again.

there might even be a gui way to do that depending on what desktop you use, but you might as well just go right to the source.

hopefully that's it, but as i said, i'm not an iptables guru by any means.


>> p.s. if your script has a different format and it's not as easy as just uncommenting something, post the http part so someone can take a look at it for you. or else i'll give you the script i use on my debian box, which works and allows http. it's also very simple and easy to modify/edit, you could use that instead.

Last edited by synaptical; 07-17-2005 at 11:05 AM.
 
Old 07-17-2005, 11:06 AM   #12
or1onas
Member
 
Registered: Mar 2004
Location: Athens,Greece
Distribution: Debian,Ubuntu
Posts: 181

Rep: Reputation: 30
/etc/init.d does not have an iptables script.
i just found this link: http://ubuntuforums.org/showthread.php?t=31663
which says that the default ubuntu installation comes with iptables open to anything in/out. So i guess this should not be the prob.
Could there be any other service besides iptables which could create this problem?
 
Old 07-17-2005, 12:42 PM   #13
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: arch, slackware 10.2
Posts: 2,020

Rep: Reputation: 45
what IP is your dyndns name pointing to?
 
Old 07-17-2005, 04:57 PM   #14
or1onas
Member
 
Registered: Mar 2004
Location: Athens,Greece
Distribution: Debian,Ubuntu
Posts: 181

Rep: Reputation: 30
I'll let u know when you're back online cause it's a dynamic one (of course), but could this be of any help?
 
Old 07-17-2005, 05:12 PM   #15
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: arch, slackware 10.2
Posts: 2,020

Rep: Reputation: 45
Quote:
Originally posted by or1onas
I'll let u know when you're back online cause it's a dynamic one (of course), but could this be of any help?
if it's dynamic that's most likely your problem if you're not changing it each time in dyndns.com. you can always check your current IP at whatismyip.com to verify it's what you have in dyndns.

are you sure that your ISP allows port 80? some don't, you know, making you have to change it to something else (8080, etc.). then you just append the port number to the end of your urls with a colon, e.g., http://my.domain.com:8080


>>edit: i just looked at the dyndns site, and they have third-party linux tools to automatically update for dynamic dns. you might want to check them out if that's the problem:
https://www.dyndns.com/support/clients/

Last edited by synaptical; 07-17-2005 at 05:13 PM.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best distro for home router tadziu23 Linux - Networking 7 11-15-2005 08:14 AM
want to ssh/ftp to home machine (Slack) from office through home router fincher69 Linux - Networking 2 09-21-2005 10:55 PM
Home Network Setup Help Linux Server running Windoze XP clients + ADSL router BeaverusIV Linux - Networking 10 04-22-2005 04:07 PM
@home with hardware router drisay Linux - Networking 4 12-08-2004 11:55 AM
Home network using linksys router -- DHCP server? GoinEasy9 Linux - General 12 04-01-2004 11:32 PM


All times are GMT -5. The time now is 01:58 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration