Using serial modem: Difference between revisions

From Alpine Linux
(→‎Create configfiles: Turn on some debugging)
m (→‎Note for above example configs: Fixed broken link.)
 
(17 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Draft}}
[[Category:Networking]]
[[Category:Networking]]


== Requirements ==
== Requirements ==
Install alpine-2.1.3 or newer (see [[Installation|these]] notes if you are unsure how to do it).<BR>
Install alpine-2.1.3 or newer (see [[Installation|these]] notes if you are unsure how to do it).
And do basic setup (run 'setup-alpine').


== Hardware ==
Decide which serial port to use and connect your modem to it.<BR>
Choose what ttyS port to use. ''(In below examples replace ttyS? with the ttyS? that applies for your needs)''<BR>
In the example below, replace ttyS0 with ttyS'''X''' where '''X''' matches your com port number.<BR>
* /dev/ttyS0 is same as COM1
''(/dev/ttyS0 is the same as COM1, ttyS1=COM2, ttyS2=COM3, ttyS3=COM4, ...)''
* /dev/ttyS1 is same as COM2
* ''(and so on...)''


== Install packages ==
== Install packages ==
=== Configure repository ===
When this article was written, some of the packages was still in 'testing'. So we need to add testing to repository.
echo "http://dl-3.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repository
apk update
=== Install packages ===
Install required packages
Install required packages
apk add ppp
{{cmd|apk add ppp}}
apk add setserial


== Modules ==
== Load modules ==
Load some needed modules and make sure they get automatically loaded at next reboot
Load the required modules and make sure they're automatically loaded at next reboot
modprobe ppp
{{cmd|modprobe ppp_generic
echo "ppp" >> /etc/modules
echo "ppp_generic" >> /etc/modules-load.d/ppp.conf}}


== Configure ==
== Config files ==


=== Create configfiles ===
=== /etc/ppp/peers/serialmodem ===
'''''/etc/ppp/peers/serialmodem'''''
''(The filename 'serialmodem' can be changed, but you will need to remember it when running pon/poff command)''
<pre>debug
<pre>debug
/dev/ttyS0
/dev/ttyS0
Line 39: Line 28:
asyncmap 0
asyncmap 0
defaultroute
defaultroute
noipdefault
lock
lock
noauth
user '{login_id}'
connect '/usr/sbin/chat -v -f /etc/ppp/chat-serialmodem'
connect '/usr/sbin/chat -v -f /etc/ppp/chat-serialmodem'
</pre>
</pre>


'''''/etc/ppp/chat-serialmodem'''''
=== /etc/ppp/chat-serialmodem ===
<pre>'ABORT' 'BUSY'
''(The filename 'chat-serialmodem' can be changed, but you will need modify the config file shown above to reflect your choice)''
'ABORT' 'ERROR'
<pre>ABORT 'BUSY'
'ABORT' 'NO ANSWER'
ABORT 'ERROR'
'ABORT' 'NO CARRIER'
ABORT 'NO ANSWER'
'ABORT' 'NO DIALTONE'
ABORT 'NO CARRIER'
'ABORT' 'Invalid Login'
ABORT 'NO DIALTONE'
'ABORT' 'Login incorrect'
ABORT 'Invalid Login'
'REPORT' 'CONNECT'
ABORT 'Login incorrect'
'TIMEOUT' '60'
REPORT 'CONNECT'
TIMEOUT '60'
'' 'ATZ'
'' 'ATZ'
'OK' 'ATDT{phonenumber}'
OK 'ATDT{phonenumber}'
'CONNECT' ''
CONNECT '\d\c'
'ogin:' '{login_id}'
Username: '{login_id}'
'sword:' '{your_password}'
Password: '{your_password}'
</pre>
</pre>


{{Note|Replace above words '''{login_id}''', '''{your_password}''' and '''{phonenumber}''' with what you received from your ISP.}}
=== /etc/ppp/pap-secrets ===
See [http://www.yolinux.com/TUTORIALS/LinuxTutorialPPP.html this] link for more details.
If your pppd log reports something like this:
daemon.debug pppd[5665]: rcvd [LCP ConfReq id=0xf6 <asyncmap 0xa0000> <auth pap> <magic 0xa239b2b1> <pcomp> <accomp>]
''(Note the "<auth pap>" section)''<BR>
you might need to use a pap-secrets file (or chap-secrets depending on what pppd reports in the logs).<BR>
Your file might look something like this:
<pre># client    server  secret            IP addresses
{login_id}  *      {your_password}  *
</pre>
If you are using 'pap-secrets' (or 'chap-secrets') you should most likely comment out the 'Username:' and 'Password:' lines in your '/etc/ppp/chat-serialmodem' config.
 
== Note for above example configs ==
{{Note|Replace above words '''{login_id}''', '''{your_password}''' and '''{phonenumber}''' with what you received from your ISP. The characters '''{''' and '''}''' should also be removed.}}
{{Note|You might need to replace the''' 'Username:' '''and''' 'Password:' '''parts to reflect the words your ISP is using to ask you to enter your credentials}}
{{Tip|You might need to replace  "'''CONNECT '\d\c''''" with "'''CONNECT 'CLIENT''''" in your chat-serialmodem config}}
References:
* http://axion.physics.ubc.ca/ppp-linux.html
* http://www.yolinux.com/TUTORIALS/LinuxTutorialPPP.html
* https://tldp.org/HOWTO/PPP-HOWTO/options.html


= Start/Stop=
= Start/Stop=
== Start connection ==
== Start connection ==
pon serialmodem
{{cmd|pon serialmodem}}
== Stop connection ==
== Stop connection ==
poff serialmodem
{{cmd|poff serialmodem}}


= If something goes wrong... =
= If something goes wrong... =
Check if process is running
Check if process is running
ps | grep pppd
{{cmd|pidof pppd}}
Logfile would also give you information on what happened
Logfile might give you a clue on what went wrong
grep pppd /var/log/messages
{{cmd|egrep "pppd{{!}}chat" /var/log/messages}}
Check nic information
Check nic information
ifconfig ppp0
{{cmd|ifconfig ppp0}}
pppd seems to have some pppstats function
pppd has a statusinformation function that could come in handy
pppstats
{{cmd|pppstats}}
 
== Check and set serial speed ==
Check your ttyS settings
setserial -ga /dev/ttyS1
You should see something like this:
<pre>
/dev/ttyS1, Line 1, UART: 16550A, Port: 0x02f8, IRQ: 3
    Baud_base: 115200, close_delay: 50, divisor: 0
    closing_wait: 3000
    Flags: spd_normal skip_test
</pre>

Latest revision as of 14:58, 25 August 2023


Requirements

Install alpine-2.1.3 or newer (see these notes if you are unsure how to do it).

Decide which serial port to use and connect your modem to it.
In the example below, replace ttyS0 with ttySX where X matches your com port number.
(/dev/ttyS0 is the same as COM1, ttyS1=COM2, ttyS2=COM3, ttyS3=COM4, ...)

Install packages

Install required packages

apk add ppp

Load modules

Load the required modules and make sure they're automatically loaded at next reboot

modprobe ppp_generic echo "ppp_generic" >> /etc/modules-load.d/ppp.conf

Config files

/etc/ppp/peers/serialmodem

(The filename 'serialmodem' can be changed, but you will need to remember it when running pon/poff command)

debug
/dev/ttyS0
115200
modem
crtscts
asyncmap 0
defaultroute
lock
noauth
user '{login_id}'
connect '/usr/sbin/chat -v -f /etc/ppp/chat-serialmodem'

/etc/ppp/chat-serialmodem

(The filename 'chat-serialmodem' can be changed, but you will need modify the config file shown above to reflect your choice)

ABORT 'BUSY'
ABORT 'ERROR'
ABORT 'NO ANSWER'
ABORT 'NO CARRIER'
ABORT 'NO DIALTONE'
ABORT 'Invalid Login'
ABORT 'Login incorrect'
REPORT 'CONNECT'
TIMEOUT '60'
'' 'ATZ'
OK 'ATDT{phonenumber}'
CONNECT '\d\c'
Username: '{login_id}'
Password: '{your_password}'

/etc/ppp/pap-secrets

If your pppd log reports something like this:

daemon.debug pppd[5665]: rcvd [LCP ConfReq id=0xf6 <asyncmap 0xa0000> <auth pap> <magic 0xa239b2b1> <pcomp> <accomp>]

(Note the "<auth pap>" section)
you might need to use a pap-secrets file (or chap-secrets depending on what pppd reports in the logs).
Your file might look something like this:

# client     server  secret            IP addresses
{login_id}   *       {your_password}   *

If you are using 'pap-secrets' (or 'chap-secrets') you should most likely comment out the 'Username:' and 'Password:' lines in your '/etc/ppp/chat-serialmodem' config.

Note for above example configs

Note: Replace above words {login_id}, {your_password} and {phonenumber} with what you received from your ISP. The characters { and } should also be removed.
Note: You might need to replace the 'Username:' and 'Password:' parts to reflect the words your ISP is using to ask you to enter your credentials
Tip: You might need to replace "CONNECT '\d\c'" with "CONNECT 'CLIENT'" in your chat-serialmodem config

References:

Start/Stop

Start connection

pon serialmodem

Stop connection

poff serialmodem

If something goes wrong...

Check if process is running

pidof pppd

Logfile might give you a clue on what went wrong

egrep "pppd|chat" /var/log/messages

Check nic information

ifconfig ppp0

pppd has a statusinformation function that could come in handy

pppstats