Running A Server Behind A Router
Using A USB Modem
The average computer's Broadband internet setup traditionally consists of either an internal ADSL
modem plugged into a spare PCI socket inside the computer or an external one plugged into a USB
socket. In some ways, it is a legacy from the dial-up days so the setup is at least familiar to
anyone setting up their Broadband connection for the first time.|
Both of these methods have one
thing in common: The computer is in charge of connecting to the internet. In fact, the terminology
and software the computer uses is virtually identical to a dial-up connection and, when you turn
your computer off, you lose your internet connection.
Using A Modem/Router
If you want to have two computers, both able to connect to the internet, it can be done
with this same setup using what Microsoft call "Internet Connection Sharing" or ICS
but by far the better way is to use an external modem/router - in fact, it makes connecting
to the internet so much simpler (and safer), that I'd recommend using one even if you only have one computer.
A modem/router is, in reality, a simple purpose-built, single-minded computer whose sole purpose in life is to look after your internet connection and to route any computers which are connected to it, onto the internet and to each other.
Why safer? Well, your internet connection stops at the modem/router and your computer, which is
conencted to it, doesn't even know that the internet exists.
The modem/router's "firewall" is great for normal purposes but it makes things a little
more complicated when you run a server. If you're using a modem/router and you start your server,
it's log will probably say something like: Listening for conections on 192.168.0.2. Something seems wrong here. That 192.168.0.2 address is your computer's local (ie LAN) IP address so how can anyone outside talk to it? People on
the outside, only know your Internet IP Address and anyone using that isn't going to get any further
that your modem/router.
When you, as the computer's user, think you're telling the computer to "go out on the internet," in reality, you're
only sending the data as far as the modem/router. It's the computing power in the modem/router that
actually sends the data out into the internet using your Internet IP Address.|
Conversely, traffic arriving from outside - perhaps to access your server - only knows of your
Internet IP Address which, as I wrote above, doesn't get any further than your modem/router.
default action of the modem/router is to block all incoming traffic, which is why
using a modem/router is safer - unless you configure the modem/router otherwise, nothing will
get through to your computer. (I should, perhaps, qualify that statement by adding that the modem/router blocks all unsolicited inbound traffic - ie, traffic that has not resulted as
a response to outbound traffic).
Even if someone outside tried using your local 192.168.0.2 address,
every piece of equipment out on the internet is configured to ignore the 192 address 'block' so they
wouldn't get very far. It seems like your server could listen for ever and would hear nothing!
The solution is to tell the modem/router to expect "calls" on your Internet IP address
and, if they meet certain criteria, to route them onto the computer which is running the server. At the same time, the modem/router changes the IP address from your Internet Address to your
LAN IP Address, so your server program, which is listening on your LAN IP Address can respond.
But, we're getting a little ahead of ourselves. Let's backtrack a bit to see how the computer and the
modem/router communicate with each other in the first instance...