The magazine of the Melbourne PC User Group
Linix Dialup to Melb PC
Trevor Gosbell |
|
So you've got Linux running and you've explored your new UNIX world a bit.
What now? Well, what's the point of having Linux to play with if you can't go
out and muck around with it in the Internet playground?
This brief guide will give you the basics of setting up a connection to the
Melbourne PC User Group Internet Service.
I've tried to keep it as short and simple as possible without too many "if"s,
"but"s, and "maybe"s. For more detail I recommend you have a
look at some of the resources listed at the end-the "PPP Howto"
document is particularly helpful. If you installed Linux from a CD set, you will
probably have a documentation disc which includes all of the "How to"
documents (and plenty of other reading matter).
You should get your connection working if you follow these directions, but in
reality you are well advised to refer to the documentation also. My aim here is
to give you a short-cut through the documentation to the information you really
need.
Preliminary Notes
I have tested this information using the Red Hat 7.1 distribution. If you have
installed another distribution, you may find some of the configuration files
stored in slightly different places. Check the "PPP-Howto" for details
of differences between systems.
As with any computer system, in Linux there is usually more than one way to get
into the feline fur business. The "PPP-Howto" mentions a number of
easy configuration utilities. I have tried some of these but underneath they all
setup the configuration files more-or-less as shown here. Have a look for
yourself, you might prefer them to writing configuration files by hand.
In looking through this article you might think that this process is all a bit
hard. It can be tricky, but it's worthwhile because once it's setup, you'll be
able to connect to the Internet Service with a single command.
Things You Will Need
|
PPP
The Melbourne PC Internet Service provides dial up connection using the
Point-to-Point Protocol (PPP). This is a widespread method of accessing Internet
(TCP/IP) services over a telephone line. To make a dialup connection, we are
mostly concerned with getting PPP working.
PPP is implemented in Linux by the
pppd
daemon (a daemon is a program that runs
in the background providing services when required).
pppd
is usually located at
/usr/sbin/pppd.
To check if PPP is installed on your system [see Side Box].
|
|
Is PPP Available?
Check by typing the following at the command line:
dmesg|grep PPP
This searches your boot-up messages for references to PPP drivers. If there is no output from this, you probably don't have PPP installed or enabled on your system. Chances are that PPP is already enabled if you are using a recent distribution, and there will be some lines of output from this command. If you need to install it, see the PPP Howto document for help. |
Modem and Serial Interface
Do you know what port your modem is connected to? If you are running Linux on a
PC it is probably one of the "COM" ports (COM1, COM2, ...) In Linux
these ports have "device file" equivalents:
|
Windows/DOS: |
equivalent in Linux: |
|
COM1:
COM2: |
/dev/ttyS0
/dev/ttyS1 |
and so on...
Simply substitute
/dev/ttyS
for COM and start counting from 0 instead of 1.
My modem is on
/dev/ttyS0
(COM1), so I'll use that in my example - substitute
the correct device number for your modem.
Configure PPP
The following is a brief outline of the configuration files used to connect with
PPP. Sample files usually come as part of the PPP package, so just modify them
as shown here or download them from my Web page. Some files don't need to be
changed at all.
You need to be logged-in as "root" to edit the configuration files.
/etc/hosts
Provides simple mapping of IP addresses to host names. The only host name
required here is the local machine, called
localhost
by default (see Figure 1).
The IP address given to
localhost
is 127.0.0.1 - the so-called "loopback
interface", a reserved IP address that essentially means "this
machine". All traffic sent to 127.0.0.1 gets sent "out" on one
port and looped-back "in" on another on the same machine.
|
Figure 1.
|
127.0.0.1 localhost
|
|
/etc/resolv.conf
Contains the IP addresses of domain name servers that can be accessed. Melb PC
has three domain name servers, so include the lines shown in Figure 2, into your
/etc/resolv.conf
file.
|
Figure 2.
|
domain melbpc.org.au
nameserver 203.12.152.1
nameserver 203.12.152.2
nameserver 203.12.152.3
|
|
/etc/host.conf
Indicates the order in which name resolution should occur. The single line
required in this file is shown in Figure 3, indicating that the domain name
resolver should look in
/etc/hosts
before looking anywhere else. You probably
won't need to change this file
|
Figure 3. |
order hosts,bind |
|
/etc/hosts.allow
/etc/hosts.deny
You probably won't need to change these two, either. They determine which
machines (hosts) are allowed or denied access to Internet services on your
system. The system checks
hosts.allow
first (Figure 4). In this case we are
allowing local machines only (ie. your machine) to have access. Then the system
checks
hosts.deny
(Figure 5), and blocks all other machines from gaining access
- not a bad fallback position!
|
Figure 4. |
#
# hosts.allow This file describes the names of the
#
hosts which are allowed to use the
#
local INET services, as decided by the
#
'/usr/sbin/tcpd' server.
#
ALL:LOCAL |
|
|
|
|
|
Figure 5. |
#
# hosts.deny This file describes the names of the
# hosts which are are *not* allowed
to use
# the local INET services, as
decided by
# the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to
# remind you that the new secure portmap uses
# hosts.deny and hosts.allow.
# In particular you should know that NFS uses portmap!
ALL:ALL |
|
/etc/ppp/options
Contains arguments to the
pppd
command. In Figure 6 the first eight lines are
lifted straight out of the "PPP-Howto" (see the "What options
should I use?" section in that document). The "name" and
"password" options allow login to occur automatically.
|
Figure 6 |
-detach
lock
asyncmap 0
crtscts
defaultroute
modem
mru 552
mtu 552
name YOUR-LOGIN-HERE
password YOUR-PASSWORD-HERE |
|
Connection Scripts
/etc/ppp/melbpc
One of the two script you actually run directly. Log in as "root" and
run this script (Figure 7) to kick it all off. It sets up a few things then runs
/etc/ppp/ppp-on-dialer.
Figure 7
#!/bin/sh
TELEPHONE=96974000
export TELEPHONE
exec /usr/sbin/pppd debug /dev/ttyS0 38400 0.0.0.0:0.0.0.0 connect
/etc/ppp/ppp-on-dialer |
/etc/ppp/ppp-on-dialer
The script that does the dialling and connection. Actually it is a wrapper that
passes options to a program called chat, which handles the connection. The
options used with chat are a bit arcane, so just use the script as shown in
Figure 8. Only if you're a glutton for punishment should you look at the manual
page for chat.
|
Figure 8. |
#!/bin/sh
/usr/sbin/chat -v \
TIMEOUT 3
\
ABORT
'\nBUSY\r' \
ABORT
'\nNO ANSWER\r' \
ABORT
'\nRINGING\r\n\r\nRINGING\r' \
''
\rAT \
'OK-+++\c-OK' ATH0
\
TIMEOUT 45
\
OK
ATDT$TELEPHONE \
CONNECT '' |
|
/etc/ppp/ppp-off
This is the other script you run directly; this one performs an orderly
disconnection. Run this one (Figure 9) as the end of your session. This is the
standard model as I've found no need to modify it. You will need to switch to
another console window to.
|
Figure 9. |
#!/bin/sh
if [ "$1" = "" ]; then
DEVICE=ppp0
else
DEVICE=$1
fi
if [ -r /var/run/$DEVICE.pid ]; then
kill -INT `cat /var/run/$DEVICE.pid`
if [ ! "$?" = "0" ]; then
rm -f /var/run/$DEVICE.pid
echo "ERROR: removed stale pid file"
exit 1
fi
echo "PPP link to $DEVICE terminated
(with moderate prejudice)" exit 0
fi
echo "ERROR: PPP link not active on $DEVICE"
exit 1 |
|
That's All Folks
That's all you need to get going. Now whenever you want to connect, login as
"root" and run
/etc/ppp/melbpc.
You might be able to just set things up as I've shown them here, but the
cautious reader may want to test a few things first.
Test Your Connection
This stage is not essential, but it will reassure you that your modem works with
Linux and that you can connect to the Melb PC service.
Use a terminal program. I have one called minicom1 that was installed as part of
my distribution. Log in as root and run this command from the command line:
minicom
-s
You will be presented with a configuration menu, as shown in Figure 10. Move the
cursor (using the arrow keys) to select Serial port setup, and in this submenu (Figure
11), input your serial device at option A (I type in /dev/ttyS0). Press
enter to shutdown the submenu, then choose Save setup as dfl in the main menu,
then choose Exit. The main terminal program now starts.
|

Figure 10
|

Figure 11
|
minicom prints an introductory message and sequence of obscure characters
(the initialisation string for the modem) then gives the OK prompt. Type in:
atdt96974000
which is the command to dial a MelbPC server. If all goes well you will receive
a message "CONNECT"2 then a few moments later a "login:"
prompt. Your modem has made the connection. Now jump out of minicom by pressing
Ctrl+A, then typing Q. minicom will ask if you want to exit, and you respond
"yes".
Working fairly quickly, at the command line type:
pppd
/dev/ttyS0
and press enter.
Hopefully you will receive the message: "Remote message: Login
Succeeded" followed by the dynamically allocated IP addresses of the local
and remote hosts. You now have an active PPP link. Go surf! Press Ctrl+C or run
/etc/ppp/ppp-off
to kill the link when you are finished.
You could connect this way every time, but why would you when you have
/etc/ppp/melbpc
to do it all for you?
Final caution; don't get "root"-ed
Although I've said that you need to log in as "root" to get your PPP
connection started, you should not go browsing or do anything else online as
"root". When it comes to everyday computing activities, these should
never be done as "root" (especially while online) because of the extra
super-user capabilities that come with the "root" login.
There are ways of setting up PPP so that you don't have to log in as
"root", but we might come back to those some other time.
[Side Box 2]
De constructing the scripts
/etc/ppp/melbpc
/etc/ppp/ppp-on-dialer
These two scripts automate the process of dialing and starting PPP. The key line in
/etc/ppp/melbpc is the last line which actually starts the
pppd daemon. The line can be dissected as follows:
exec /usr/sbin/pppd = run the pppd daemon
debug = run it in debug mode. Debugging output is sent to
/var/log/messages. Look here for error messages if you're having trouble. When things are running well, this option should be removed.
/dev/ttyS0 = run it using this device
38400 = connection speed. Yes, I have a slooow modem.
0.0.0.0:0.0.0.0 = dummy IP addresses for local and remote hosts respectively
connect /etc/ppp/ppp-on-dialer = handle login using this script
I have modified the basic ppp-on-dialer script so that it retrieves the telephone number from the
$TELEPHONE environment variable. This allows me to have a set of startup scripts, called rather originally:
/etc/ppp/melbpc1
/etc/ppp/melbpc2
/etc/ppp/melbpc3
Each with a different Melb PC dialup number assigned to $TELEPHONE, so I can easily choose to use a less frequented number simply by starting the appropriate script. |
|
Resources
Linux "PPP Howto":
http://www.thelinuxreview.com/howto/ppp/
orr
http://www.tldp.org/HOWTO/PPP-HOWTO/index.html.
Linux Serial Howto:
http://www.tldp.org/HOWTO/Serial-HOWTO.html.
Linux ISP Hookup Howto:
http://www.tldp.org/HOWTO/ISP-Hookup-HOWTO.html.
The entire Linux Documentation Project is worth a look:
http://www.tldp.org/.
Linux Unleashed published by SAMS was helpful in the
preparation of this article.
My Web page has all of the scripts and configuration files from this article:
http://member.melbpc.org.au/~tgosbell. |
Reprinted from the September 2002 issue of PC Update, the magazine of Melbourne PC User Group, Australia
|