Using serial modem: Difference between revisions

From Alpine Linux
(Initial notes on using/configuring serial modem on Alpine)
 
(19 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Networking]]
[[Category:Networking]]
= General notes =
{{Warning|Page is under heavy construction. Do not use unless you know what you are doing! Funtionallity is still unknown.}}


== 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').
 
Decide which serial port to use and plug you modem there.<BR>
In below examples replace ttyS0 with the ttyS? that applies for your needs.<BR>
''(/dev/ttyS0 is same as COM1, ttyS1=COM2, ttyS2=COM3, ttyS3=COM4, ...)''


== 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


== Load modules ==
== Load modules ==
{{Note|I am not sure what modules is needed}}
Load some needed modules and make sure they get automatically loaded at next reboot
If we need to load some modules we need to make sure we add them to /etc/modules
{{cmd|modprobe ppp_generic
echo "ppp_generic" >> /etc/modules-load.d/ppp.conf}}


== Check and set serial speed ==
== Configfiles ==
{{Note|I am not sure how to do that}}


== Configure ==
=== /etc/ppp/peers/serialmodem ===
Create a missing folder
''(The filename 'serialmodem' can be changed to whatever is appropriate for you, but you will need to remember it when running pon/poff command)''
mkdir -p /etc/ppp/peers
<pre>debug
/dev/ttyS0
115200
modem
crtscts
asyncmap 0
defaultroute
lock
noauth
user '{login_id}'
connect '/usr/sbin/chat -v -f /etc/ppp/chat-serialmodem'
</pre>


=== Create configfiles ===
=== /etc/ppp/chat-serialmodem ===
{{Note|This is a draft config - it needs fixing}}
''(The filename 'chat-serialmodem' can be changed to whatever is appropriate for you, but you will need modify above configfile to reflect your decition)''
'''''/etc/ppp/peers/serialmodem'''''
<pre>ABORT 'BUSY'
/dev/ttyS0
ABORT 'ERROR'
38400
ABORT 'NO ANSWER'
crtscts
ABORT 'NO CARRIER'
modem
ABORT 'NO DIALTONE'
noauth
ABORT 'Invalid Login'
usepeerdns
ABORT 'Login incorrect'
defaultroute
REPORT 'CONNECT'
noipdefault
TIMEOUT '60'
debug
'' 'ATZ'
noccp
OK 'ATDT{phonenumber}'
nobsdcomp
CONNECT '\d\c'
novj
Username: '{login_id}'
user "irrelevant"
Password: '{your_password}'
password "irrelevant"
</pre>
connect '/usr/sbin/chat -f /etc/ppp/chat-serialmodem-pin || /usr/sbin/chat -f /etc/ppp/chat-serialmodem-nopin'


{{Note|This is a draft config - it needs fixing}}
=== /etc/ppp/pap-secrets ===
'''''/etc/ppp/chat-serialmodem-pin'''''
When you look at the logs and see pppd report something like this:
ABORT BUSY
  daemon.debug pppd[5665]: rcvd [LCP ConfReq id=0xf6 <asyncmap 0xa0000> <auth pap> <magic 0xa239b2b1> <pcomp> <accomp>]
  ABORT ERROR
''(Note the "<auth pap>" section)''<BR>
ABORT 'NO CARRIER'
Then you might need to use pap-secrets file (or chap-secrets depending on what pppd reports in the logs).<BR>
REPORT CONNECT
You file might in this case look something like this
  TIMEOUT 10
<pre># client    server secret            IP addresses
"" "ATZ"
{login_id}  *      {your_password}  *
OK "AT+CPIN='''''pin'''''"
</pre>
OK AT+CGDCONT=1,"ip","'''''internet'''''"
If you are using 'pap-secrets' (or 'chat-secrets') you should most likely comment out 'Username:' and 'Password:' lines in your '/etc/ppp/chat-serialmodem' config.
OK "ATE1V1&D2&C1S0=0+IFC=2,2"
OK "AT+IPR=115200"
OK "ATE1"
TIMEOUT 60
"" "ATD*99***1#"
CONNECT \c


{{Note|This is a draft config - it needs fixing}}
== Note for above example configs ==
'''''/etc/ppp/chat-serialmodem-nopin'''''
{{Note|Replace above words '''{login_id}''', '''{your_password}''' and '''{phonenumber}''' with what you received from your ISP. The characters '''{''' and '''}''' should also be removed.}}
ABORT BUSY
{{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}}
ABORT ERROR
{{Tip|You might need to replace  "'''CONNECT '\d\c''''" with "'''CONNECT 'CLIENT''''" in your chat-serialmodem config}}
ABORT 'NO CARRIER'
References:
REPORT CONNECT
* http://axion.physics.ubc.ca/ppp-linux.html
TIMEOUT 10
* http://www.yolinux.com/TUTORIALS/LinuxTutorialPPP.html
"" "ATZ"
* http://www.linux.org/docs/ldp/howto/PPP-HOWTO/options.html
OK AT+CGDCONT=1,"ip","'''''internet'''''"
OK "ATE1V1&D2&C1S0=0+IFC=2,2"
OK "AT+IPR=115200"
OK "ATE1"
TIMEOUT 60
"" "ATD*99***1#"
CONNECT \c
'''Note:''' The above highlighted word(s) ''''''pin'''''' is the PIN of your card (typically a four digit code)<BR>
'''Note:''' The above highlighted word(s) ''''''internet'''''' is the Access Point Name (APN) of the service you use (for instance mine is "web.omnitel.it"). If you don't know the Internet APN, ask your service provider.<BR>


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


= Checks =
= 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}}

Revision as of 09:03, 12 February 2020


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 plug you modem there.
In below examples replace ttyS0 with the ttyS? that applies for your needs.
(/dev/ttyS0 is same as COM1, ttyS1=COM2, ttyS2=COM3, ttyS3=COM4, ...)

Install packages

Install required packages

apk add ppp

Load modules

Load some needed modules and make sure they get automatically loaded at next reboot

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

Configfiles

/etc/ppp/peers/serialmodem

(The filename 'serialmodem' can be changed to whatever is appropriate for you, 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 to whatever is appropriate for you, but you will need modify above configfile to reflect your decition)

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

When you look at the logs and see pppd report 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)
Then you might need to use pap-secrets file (or chap-secrets depending on what pppd reports in the logs).
You file might in this case look something like this

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

If you are using 'pap-secrets' (or 'chat-secrets') you should most likely comment out '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