L120: Linux System Administration II



Yüklə 1,05 Mb.
səhifə11/16
tarix11.10.2017
ölçüsü1,05 Mb.
#4275
1   ...   8   9   10   11   12   13   14   15   16

Setting up PPP



Prerequisites


  • Hardware Configuration (see LPI 101)


Goals


  • Configure a modem for dial up

  • Understand the roles of the pppd daemon and the chat script

  • Configure options in /etc/ppp/options such as hardware flow control or persistent connections


1. Detecting Modems

Linux assumes in general that serial modems are connected to a serial port (one of the /dev/ttySN devices). So you first need to find out which serial port the modem is connected to.


The setserial –g command will query the serial ports. If the resource is not available then the UART value will be unknown.
Sample output for setserial:
setserial -g /dev/ttyS[0-3]

/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4

/dev/ttyS1, UART: 16550A, Port: 0x02f8, IRQ: 3

/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4

/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
For non-serial modems it is possible to get information about available resources in /proc/pci. Here the i/o and IRQ settings can be transferred to a free /dev/ttyS? device. This is achieved with the following 2 lines:
setserial /dev/ttyS2 port 0x2000 irq 3

setserial /dev/ttyS2 autoconfig


The last line simply deals with setting up the proper UART settings.
These settings will be lost at the next boot and can be saved in /etc/rc.serial. This script is one of the last scripts executed by rc.sysinit at boot time.

The rc.serial script:
#!/bin/bash
TTY=/dev/ttyS2

PORT=0x2000

IRQ=3

echo "Setting up Serial Card ..."



/bin/setserial $TTY port $PORT irq $IRQ 2>/dev/null

/bin/setserial $TTY autoconfig 2>/dev/null



2. Dialup Configuration


Once the modem is known to be connected to a serial device it is possible to send modem specific instruction such as ATZ or ATDT. One tool that will act as a terminal interface is minicom.




minicom screenshot:

Another common tool is wvdialconf. This tool will automatically scan for modems on the ttyS’s and create a configuration file called /etc/wvdial.conf. The next command will create or update the configuration file





wvdialconf /etc/wvdial.conf

This file is used to handle password authentication and initialise the pppd daemon once the connection is established. If a dialer called MYISP is defined in wvdial.conf then the connection is started using





wvdial MYISP



3. pppd and chat

First of all the chat script is used to communicate with a remote host’s modem. It is a series of expect/send strings. The format is:





expected query’ ‘answer’



Expected queries from the modem are:
‘ ‘ ‘OK’ ‘CONNECT’ ‘login’ ‘password’ ‘TIMEOUT’ ‘>’

The script is read sequentially and starts with the empty query ‘ ‘ which is matched with the command ‘ATZ’. Once the modem is initialised it sends back the query ‘OK’. To this the script will answer with a ‘ATDT’ dialing command. This conversation goes on and on until the ‘>’ prompt is reached at which stage one can run pppd.


Sample chat script:

'ABORT' 'BUSY'

'ABORT' 'ERROR'

'ABORT' 'NO CARRIER'

'ABORT' 'NO DIALTONE'

'ABORT' 'Invalid Login'

'ABORT' 'Login incorrect'

'' 'ATZ'


'OK' 'ATDT01172341212'

'CONNECT' ''

'ogin:' 'adrian'

'ord:' 'adrianpasswd'

'TIMEOUT' '5'

'>' pppd


Of course this is one way of doing things. One can also start pppd manually and then invoke the chat script as follows:
pppd /dev/ttyS2 115200 \

nodetach \

lock \

debug \


crtscts \

asyncmap 0000000 \

connect "/usr/sbin/chat -f /etc/sysconfig/network-scripts/chat-ppp0"
The lines below the pppd commands can be saved in /etc/ppp/options. This file contains most of the features which make the strength and flexibility of pppd.
The main options for /etc/ppp/options are listed in the next table.


Option

Description

crtscts

use hardware flow control using the RTS and CTS signals

noauth

do not require the peer to authenticate itself

persist

do not exit after a connection is terminated but try to reconnect

require-chap

use /etc/ppp/chap-secrets for authentication

Once a serial connection is established the pppd daemon will start the PPP protocol. At this point a network interface called pppN is assigned an IP address with the script /etc/ppp/ip-up.


When a connection is terminated the pppd daemon releases the IP with the /etc/ppp/ip-down script.


4. PPPD peers

There is a directory called peers in /etc/ppp/. In this directory one can create a file that contains all the necessary command line options for pppd. In this way peer connections can be started by all users.


Below is an example of a PPP peer file:
# This optionfile was generated by pppconfig 2.0.10.

hide-password

noauth

connect "/usr/sbin/chat -f /etc/sysconfig/network-scripts/chat-ppp0"



/dev/ttyS0

115200


defaultroute

noipdefault

user uk2
The previous peer file (called uk2) would be used as follows:
# pppd call uk2
This will dial the number specified in the “chat script” and authenticate as the user “uk2”. Please noteNote that this requires a corresponding entry in the /etc/ppp/chap-secrets, and /etc/ppp/pap-secrets. The format for pap and chap secrets is as follows:
# Secrets for authentication using CHAP

# client server secret IP addresses

uk2 * "uk2" *
This format allows different passwords to be used if you connect to different servers. It also allows you to specify an IP address. This is probably not going to work when connecting to an ISP, but when making private connections, you can specify IP addresses if there is a need. One example would be where you need to audit your network activity, and want to specify which users get a certain IP address.

5. Wvdial

This is the default method used by Red Hat to connect to a dial up network. To configure wvdial, it is easier to use one of the configuration tools provided with either Gnome or KDE. They configure the

file.
Below is a sample wvdial.conf file:
[Modem0]

Modem = /dev/ttyS0

Baud = 115200

Dial Command = ATDT

Init1 = ATZ

FlowControl = Hardware (CRTSCTS)

[Dialer UK2]

Username = uk2

Password = uk2

Phone = 08456091370



Inherits = Modem0
To use wvdial from the command line, you would execute it with the following syntax:
# wvdial
In the example configuration file the following command would dial the connection called “uk2”
# wvdial uk2


6. Exercises and Summary



Files


File

Description

/etc/ppp/options

options used by the pppd daemon (additional options can be passed on the command line

/etc/ppp/chap-secrets

contains login information available when using the challenge handshake authentication protocol (CHAP)

/etc/ppp/pap-secrets

contains login information available when using the password authentication protocol (PAP)

/etc/ppp/peers/

contains files with connection information (user name, chat script) as well as pppd options

/etc/wvdial.conf

configuration file used by wvdial



Commands


Command

Description

chat

chat(8) – The chat program defines a conversational exchange between the computer and the modem. Its primary purpose is to establish the connection between the Point-to-Point Protocol Daemon (pppd) and the remote pppd process

minicom

program used to communicate over a serial connection. Can be given a phone number, user name and password. Once the connection is established minicom acts as a terminal

pppd

pppd(8) – PPP is the protocol used for establishing internet links over dial-up modems, DSL connections, and many other types of point-to-point links. The pppd daemon works together with the kernel PPP driver to establish and maintain a PPP link with another system (called the peer) and to negotiate Internet Protocol (IP) addresses for each end of the link. Pppd can also authenticate the peer and/or supply authentication information to the peer.

wvdial

wvdial(1) – wvdial is an intelligent PPP dialer, which means that it dials a modem and starts PPP in order to connect to the Internet. It is something like the chat(8) program, except that it uses heuristics to guess how to dial and log into your server rather than forcing you to write a login script




Yüklə 1,05 Mb.

Dostları ilə paylaş:
1   ...   8   9   10   11   12   13   14   15   16




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə