Next Previous Contents

15. �ϧA���s���۰ʤ� - �гy�s�����O�Z

�@���A�i�H�ΤW�z����k�Τ�ʤ覡ñ�J�A��n�����k�O�إߤ@�ǫ��O�Z�Ӧ۰ʬ��A�i��o�Ǥu�@�D

�@�� chat ���O�Z�i�H�۰ʤ�ñ�J�H�ΰ_�� PPP ���{�ǡA�]���Ҧ��A�o�����]�H root �άO ppp �s�ղխ��������^�u�O�o�X��@�ӫ��O�Ӱ_�ʧA���s�u�D

15.1 �H�ϥΪ̦W�١��K�X�{�Ҫ����O�Z

�p�G�A�� ISP �ä��n�D�ϥ� PAP/CHAP ���ܡA�o�ǴN�O���A�dzƪ�!

�p�G ppp �M��w�˥��T�A�A���ӷ|����ӽd���ɮסD �b PPP 2.1.2 ���O�b /usr/sbin �Ӧb PPP 2.2 �̬O�b /etc/ppp/scripts�D�o�ǬO

�b PPP-2.1.2

ppp-on
ppp-off

�Ӧb PPP-2.2

ppp-off
ppp-on
ppp-on-dialer

�{�b�A�p�G�A���b�ϥ� PPP 2.1.2�A�ڱj�P��ij�A�R���o�ǽd���ɮסD ���̦���b�����D - ���n�i�D�ڥ��̤u�@�o�ܦn - �ڤ]�ΤF�ܪ��@�q�ɶ�(�ӥB�٦b�o�� HOWTO ���Ĥ@�������˥���)!

���F ppp 2.1.2 �ϥΪ̪��v�q�A�o�̦�����n���˪O�ɮסA�o�ǬO�q ppp 2.2 �o��M��̮��Ӫ��D �ګ�ij�A�����èϥγo�ǫ��O�Z�Ӥ��n�A���ª� PPP-2.1.2 ���O�Z�D

15.2 ppp-on ���O�Z

�o�O��ڱҰʳs�u���@����O�Z�����Ĥ@�ӡD


#!/bin/sh
#
# Script to initiate a PPP connection. This is the first part of the
# pair of scripts. This is not a secure pair of scripts as the codes
# are visible with the 'ps' command.  However, it is simple.
#
# These are the parameters. Change as needed.
TELEPHONE=555-1212      # The telephone number for the connection
ACCOUNT=george          # The account name for logon (as in 'George Burns')
PASSWORD=gracie         # The password for this account (and 'Gracie Allen')
LOCAL_IP=0.0.0.0        # Local IP address if known. Dynamic = 0.0.0.0
REMOTE_IP=0.0.0.0       # Remote IP address if desired. Normally 0.0.0.0
NETMASK=255.255.255.0   # The proper netmask if needed
#
# Export them so that they will be available to 'ppp-on-dialer'
export TELEPHONE ACCOUNT PASSWORD
#
# This is the location of the script which dials the phone and logs
# in.  Please use the absolute file name as the $PATH variable is not
# used on the connect option.  (To do so on a 'root' account would be
# a security hole so don't ask.)
#
DIALER_SCRIPT=/etc/ppp/ppp-on-dialer
#
# Initiate the connection
#
#
exec /usr/sbin/pppd debug /dev/ttySx 38400 \
        $LOCAL_IP:$REMOTE_IP \
        connect $DIALER_SCRIPT

�ӳo�O ppp-on-dialer ���O�Z:-


#!/bin/sh
#
# This is part 2 of the ppp-on script. It will perform the connection
# protocol for the desired connection.
#
/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         30                              \
        OK              ATDT$TELEPHONE                  \
        CONNECT         ''                              \
        ogin:--ogin:    $ACCOUNT                        \
        assword:        $PASSWORD

�b PPP-2.2 ���Appp-off ���O�Z�ݰ_�ӹ�:-


#!/bin/sh
######################################################################
#
# Determine the device to be terminated.
#
if [ "$1" = "" ]; then
        DEVICE=ppp0
else
        DEVICE=$1
fi

######################################################################
#
# If the ppp0 pid file is present then the program is running. Stop it.
if [ -r /var/run/$DEVICE.pid ]; then
        kill -INT `cat /var/run/$DEVICE.pid`
#
# If the kill did not work then there is no process running for this
# pid. It may also mean that the lock file will be left. You may wish
# to delete the lock file at the same time.
        if [ ! "$?" = "0" ]; then
                rm -f /var/run/$DEVICE.pid
                echo "ERROR: Removed stale pid file"
                exit 1
        fi
#
# Success. Let pppd clean up its own junk.
        echo "PPP link to $DEVICE terminated."
        exit 0
fi
#
# The ppp process is not running for ppp0
echo "ERROR: PPP link is not active on $DEVICE"
exit 1

15.3 �s��o�̩Ҵ��Ѫ��_�l���O�Z

�]���o���s�����O�Z�����ⳡ���A�ڭ̤��O�s�襦�̡D

ppp-on ���O�Z

�A�N�o�s��o�ӫ��O�Z�H�ϬM�A�b ISP ���ϥΪ̦W�١A�A�b ISP ���K�X�A�A ISP ���q�ܸ��X�D

�C�@�湳�O TELEPHONE= ��ڤW�]�w�F�o���ܼƥ]�t�b�����k�䪺��T (���M���]�A���ѳ���)�D �]���s��C�@��ϥ���A�� ISP �P�s�u�O���T���D

�ӥB�A�p�G�A(�ݭn)�b /etc/ppp/options �ɮ׸̳]�w�F IP ���X�A�R���o��


$LOCAL_IP:$REMOTE_IP \

�٦��A�T�w�ܼ� DIALER_SCRIPT ���V�A�N�n�ϥΪ��������O�Z���������|�W�١D �]���A�p�G�A���ʩΧ��ܳo�ӫ��O�Z���W�١A�T�w�A���T�a���� ppp-on ���O�Z�̪��o�@��D

ppp-on-dialer ���O�Z

�o�O�ĤG�ӫ��O�Z��ګإ߰_�ڭ̪� PPP �s���D

�`�N: �@�� chat ���O�Z�@�������b�P�@��̡D�˱׽u�O�Ψ����@��i�H��L�Ʀ檺�����]�K��H�̾\Ū�^�Өä��O���O�Z�����զ����@�����D

�M�ӡA�J�Ӧa�ݬݥ����Ӹ`�����H�K���ڭ̤F�ѥ����(���]��)�n������O�D�`���Ϊ�!

15.4 �@�� chat ���O�Z�䤤���t�N...

�@�� chat ���O�Z�O�@�t�C���ݦr�� �e�X�r�����t��D �S�O�O�A�`�N��ڭ��`�O�b�e�X�Y�ǰT�����e�������Y�ǰT���X�{�D

�p�G�ڭ̦b�S�������������T�������p�U�n�e�X�Y�ǰT�����ܡA�ڭ̥����ϥΪŪ����ݦr��]�ǥ� �����^�Ӧb�S���e�X����T�������p�U�n���ݬY�ǰT���@�k�]����! �ӥB�A�p�G�r��]�t�n�X�Ӧr�]�Ҧp NO CARRIER�^�A�A������r��Τ޸��A���A�o�� chat �|��r����@�O��@�Ӷ��ءD

�b�ڭ̼˪O�̪� chat ���O��O:


exec /usr/sbin/chat -v

�_�� chat �A-v �i�D chat �N��Ҧ�����X���J������t�ΰO���̡]�q�`�O /var/log/messages�^�D �@���Aı�o chat ���O�Z���B�@í�w�ӥi�a�A�s��o�@��� -v �����H�K��֧A�t�ΰO�����V���D


TIMEOUT         3

�o�]�w�����Ҵ��ݪ���J�O�ɮɭ����T���D�p�G�A�ϥίu���O�ܺC���ƾھ�����A�i��o�n�W�[�o�ӳ]�w�줭���άO�Q��!


ABORT           '\nBUSY\r'

�p�G������ BUSY �r��A�������D


ABORT           '\nNO ANSWER\r'

�p�G������ NO ANSWER �r��A�������D


ABORT           '\nRINGING\r\n\r\nRINGING\r'

�p�G������]���ƪ��^RINGRING �r��A�������D�o�O�]���Y�H�����q�ܵ��A!


“              \rAT

�����ݼƾھ��ǰe����T���åB�e�X AT �r��D


OK-+++\c-OK   ATH0

�o�@�Ӥ�������@�I�A�]�����ϥΤF�Y�� chat �����~�^�_�\��D

���ҥN�����O...���� OK �A�p�G�S������]�]���ƾھ��ä��b���O�Ҧ��U�^����e�X +++ �]�ϼƾھ���^���O�Ҧ����з� Hayes �ۮe�ƾھ��r��^�åB���� OK�F���۰e�X ATH0 �]�ƾھ����_�r��^�D �o���A�����O�Z�i�H���I�A���ƾھ��H�b�u�W�L�k�_�u�����p�D


TIMEOUT         30

�]�w���O�Z��l�������檺�O�ɮɭ��� 30 ���D�p�G�A���g�]���O�ɦӸg��L chat ���O�Z�Q�פ���D�A�⥦�W�[�� 45 ���Χ�[�D


OK              ATDT$TELEPHONE

���� OK �]�ƾھ��� ATH0 ���O���^���^�åB������ڭ̷Q�n�I�s�����X�D


CONNECT         ”

���� CONNECT �r��]�����ݼƾھ����^���ɧڭ̪��ƾھ��e�X���^�åB���e�X���^�аT���D


ogin:--ogin:    $ACCOUNT

�A�@���A�o�̭��ڭ̦��@�ǿ��~�^�_�]�w�D����ñ�J����(...ogin:)�A���O�p�G�ڭ̦b�O�ɫe�S��������A�e�X�@�Ӫ�^�r��(return)�M��A����Mñ�J���ܡD �������촣�ܮɡA�e�X�ϥΪ̦W�١]�s��b�ϥΪ̬ɭ��� $ACCOUNT �����ܼƸ̡^�D


assword:        $PASSWORD

���ݱK�X���ܨåB�e�X�K�X�]�A�@���A�s��b�ϥΪ̬ɭ����@�������ܼƸ̡^�D

�o�� chat ���O�Z���X�z�����~�^�_�\��D Chat �٦��\�h���n���S��A��o�̩Үi���٭n��h�D ��ԲӪ���T�аѾ\ chat ���u�W�ϥΤ�U(man 8 chat)�D

�b���A���ݱҰ� PPP

���M�o�� ppp-on-dialer ���O�Z���b�Añ�J��|�۰ʱҰ� pppd �����A���ӻ��D�`���n�ΡA�M�ӬY�Ǧ��A���ݭn�A���զa�b���A���W�Ұ� PPP�D

�p�G�A�ݭn�b���A���W�U���O�H�Ұ� PPP�A�A�����n�s�� ppp-on-dialer ���O�Z�D

�b�o���O�Z������(�b password �o��᭱)�[�W ���� �e�X �r��� - �o�O�M��A�� shell ���ܲŸ� (�S�O�p�߹� Bourne shell ���S���N�q���r�� - ���O $ �P [ �� ] ���k��A����)�D

�@�� chat ���F shell ���ܲŸ��Achat �����U���O�H�ҰʧA ISP �� PPP ���A���D

�H�ڪ��Ҥl�Ө��A�ڪ� PPP ���A���ϥμзǪ� Linux Bash ���ܲŸ�


[hartr@kepler hartr]$

�ӥB�ݭn�ڥ�


ppp

�H�Ұʦ��A���W�� PPP�D

�b�����\�@�I���~�^�_�O�Ӧn�D�N�A�ҥH�b�ڪ��Ҥl���ڥ�


        hartr--hartr    ppp

�o�N�O���A�p�G�ڦb�O�ɫe�S���촣�ܲŸ��A�e�X return �åB�A�����ݴ��ܲŸ��D

�@�����촣�ܲŸ��A�N�e�X ppp �r��D

�`�N: �O�ѤF�b�e�@�浲���e�[�W \ �H�K�� chat �{���o��ӫ��O�Z�O�b�@���!

�������O�A�Y�Ǧ��A���|���ͫD�`�h�ܪ����ܲŸ�! �A�i�ॲ���ϥ� minicom �hñ�J�X���H�K�F�Ѥ���i�H�ΨӰ����T�w��“����”�r��D

15.5 �ϥΩ� PAP/CHAP ��{�s�u�� chat ���O�Z

�p�G�A�� ISP �ϥ� PAP/CHAP ��{�A����A�� chat ���O�Z�|²��o�h�D �A�� chat ���O�Z�ҭn���������u�O�����q�ܡA���ݱ��W�u�A�M��N�� pppd �h�B�zñ�J�Ʃy!


#!/bin/sh
#
# This is part 2 of the ppp-on script. It will perform the connection
# protocol for the desired connection.
#
exec /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         30                              \
        OK              ATDT$TELEPHONE                  \
        CONNECT         ''                              \

15.6 pppd �� debug �P file option_file �ﶵ

�N���ڭ̤w�g�ݹL���A�A�i�H�� pppd �ϥ� -d �ﶵ���}�����T���O���D 'debug' �ﶵ�M�o�ӬO�@�˪��D

�]���ڭ̥��b�ϥηs�����O�Z�إ߷s���s�u�A����ۦ��ﶵ���ޡD (ĵ�i: �p�G�A���ϺЪŶ����j���A�O�� pppd ���T���i��|�j�q�W�[�A���t�ΰO���ɤj�p�èϧA�J��·� - ���L�b���A���w�|�s�u���Ѩù��ճ\�[)�D

�@���A�����a�{���@���u�@���`�A�A�i�H���h���ﶵ�D

�p�G�A���O�q /etc/ppp/options �� /etc/ppp/options.ttySx �ɮפ��s�X ppp �ﶵ�A �i�H�b pppd �W�� file �ﶵ���w�ɮצW�� - �Ҧp


exec /usr/sbin/pppd debug file options.myserver /dev/ttyS0 38400 \


Next Previous Contents