Home servers and the internet
Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: Home servers and the internet.
For most people, it is not possible to effectively connect a Moodle site installed on a home machine with the internet. IT professionals will say that a home computer can not support many people trying to use a Moodle site. Secondly, most home machines do not have IPs that other computers on the internet can find.
We are tying to answer the question: "Why a Moodle web server on my home computer can not be used by other people on the internet".
- 1 How the internet works 101
- 2 Capacity of a home server or small office intranet
- 3 MACs, NATs, IPs, routers, DHCP, DNS and the internet
- 4 Special circumstances and exceptions
- 5 See also
How the internet works 101
Every computer on the internet has a unique IP address, which is a string of 4 numbers. For example, this server is 220.127.116.11. To get data from moodle.org, your computer needs to connect to that address. Similarly, your computer will have an IP address, which the server will use to send the data you ask for back to you.
Now typing numbers all the time is a pain in the neck, which is why we have the domain name system (DNS). That is simply a lookup service, so you can ask for http://moodle.org/ instead of having to remember things like http://18.104.22.168/.
Now as well as every computer having a real address like 22.214.171.124, the IP address standard defines some magic addresses, of which 127.0.0.1 is the most useful. No matter which computer you are on, 127.0.0.1 means 'this computer'. And in the DNS system, localhost is always an alias for 127.0.0.1.
So, if you are accessing your Moodle site with a URL like http://localhost/moodle/, it will only ever work on your own computer. However, if you can work out the real address of your computer, and change http://123.234.345.456/moodle/ (and if you update wwwroot in config.php), then other people will be able to access your Moodle.
Now, the oversimplification in the above is the bit 'Every computer on the internet has a unique* IP address'. Actually, it is more complicated than that. For example, if you have a home network with several computers behind a router, then actually, to the rest of the internet, it will appear as if there is just one computer (the router) attached to the internet. The router does some magic (also called Network Address Translation - NAT) to make all your computers seem like one. That is because there are only 255*255*255*255 ~ 4 billion IP addresses, and there are more computers than that in the world. That is also why we are moving (very slowly) from IP4 to IP6, which allows more addresses.
If you are behind a NAT router, then getting a real address for your computer is harder. Also, if you are behind a filewall, people may not be able to get to your Moodle, even if they know the address.
Capacity of a home server or small office intranet
Capacity includes bandwidth and memory.
MACs, NATs, IPs, routers, DHCP, DNS and the internet
For those who want a little more in the way of a simple explanation, read this. We are tying to answer the question: "Why a Moodle web server on my home computer can not be used by other people on the internet".
A computer generally communicates to and through a single network router. In the simple network example, routers communicate with each other. Since each router knows the computers attached to it, the router passes along messages to the right computer. The messages are called packets.
A web server on a computer basically listens for something saying "I am looking for MoodleHouse.org" or "I am looking for 192.168.0.11". If the web server hears that and knows it is MoodleHouse.org or is 192.168.0.11, then the web server answers by sending some information back to the sender. The flow of information is contained in packets. The usual example is that the postal service has an envelope addressed to "1234 Anywhere Street", or "The Moodle House" in their area, with a return address on it of "101 Sender Way".
Some terms and context
DNS or a DNS server keeps tracks that MoodleHouse.org is located at 192.168.0.11. A router's NAT table keeps track that 192.168.0.11 is sent to a Media Access Control address (MAC address). A MAC address defines a specific network connection on a specific computer and is unique in the world. An example might be that the MAC address is like saying go to the front door of "The Moodle House", not the back or side door. Your area's postal service makes a note on all your outgoing mail and when it gets something for you it knows it.
Ways to get IP addresses
The Dynamic Host Configuration Protocol (DHCP) process on a router listens for computers that are turned on, do not have an IP in the NAT table. And the computers network connection is requesting an IP address. DHCP assigns that computer's MAC address an IP address and that is added to the NAT table in the router. The postal example: a new house is built and has 3 doors, and one is where the owners want the mail delivered. Or that a child comes home for the summer and wants their mail delivered to the side door at "The Moodle House" while they are there.
- On some networks, you can or must tell your network connection that it is a specific IP address because DHCP is turned off. Further your router may only accept IP addresses in a certain range of numbers. Some networks assign fixed IPs to specific MAC addresses and ignore anything else that is not on it's list.
Mysterious IP addresses
One basic problem is that many home computer's have their IP address assigned by their network provider and these will be intentionally changed/reassigned every few days. This is like saying this week your area's postal service calls The Moodle House's address "1234 Orange Way", but last week it was "9876 Martin Street".
Further, the IP address you see on your computer's network connection is not always what other computers see on the information packets. Packet's can have many layers.
It is all about who you know
Here is where it gets really complicated. We will try to be simple. Generally speaking, communication in a network comes down to who knows who.
Routers know that other 'router like things' exist which have their own set of IPs that they know about. With some IP addresses, there will be many 'router like things' that know where to send a packet that is addressed to a specific IP. Every time it gets sent along, the packet gets another layer. The area postal service puts the envelope in another one. The outside envelope is addressed to the postal service that the area postal service thinks may know where to find the "The Moodle House's" front door. However, the "101 Senders Way" return address on the outside of the envelope becomes the sending postman's. The inside envelope still contains the original return address but now it is hidden by the outside envelope.
Imagine that the original packet is forwarded through 10 routers before it reaches the right MAC address. There can be a lot of layers that are covering the return MAC address. Being very simple, when the packet reaches it's destination, it is opened and the original message is read along with the original IP address. In other words the envelope reaches the back door of "The Moodle House" and is opened. The message says send the front page to "101 Senders Way".
The Moodle House sends a packet with information out to the return address originally supplied by "101 Senders Way". The process works in reverse. The returning packet may not take the same route back (another long story).
Tell me again
Tell me again why people on the internet can not use my home Moodle server? In short, since you don't have a special address, ONLY your personal postal service knows your address. However, all the other postal services in the world wide web can find your personal postal service's address. Your postal service will not let your computer use it's IP address. Thus your Moodle Server will never hear any messages address to it.
Of course their are exceptions but for most home computers, that is the way it is.
Special circumstances and exceptions
There are places where you basically can rent a public ip for you computer. When your local friendly internet provider changes your IP, you log into one of these places, identify your self and the service will now recognize that your IP is not 192.168.0.42 but has changed to 192.168.40.14. However, more importantly all the computers in the world that know your computer as 127.127.127.127, will be able to find you.
There is an international body that essentially registers IP addresses. It might be possible to get them to issue you an IP address. Or if you work for a large college or organization that has its own range of IP address, they might make it possible for your computer to be assigned an IP that any computer on the internet can find.
An intranet describes all the computers "behind" a router that assigns N
To be continued