The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]

Things look quiet here. But I've been doing a lot of blogging at dan.langille.org because I prefer WordPress now. Not all my posts there are FreeBSD related. I am in the midst of migrating The FreeBSD Diary over to WordPress (and you can read about that here). Once the migration is completed, I'll move the FreeBSD posts into the new FreeBSD Diary website.

Installing PPP 15 March 1999
Share
Need more help on this topic? Click here
This article has no comments
Show me similar articles
I've just finished Installing FreeBSD on a Windows 95 machine and now I want to get the modem running.  So the next step is to install User PPP.   I'm starting with the PPP - Pedantic PPP Primer section of The FreeBSD Handbook.   You should read that document in conjunction with this article.

Eventually I will be using the -alias option and maybe adding in some firewall stuff.  But that will be for another article.

Which PPP?
There are two types of PPP but we will deal only with one of them: User-PPP.  This is the version of PPP which is commonly used by people.  Kernel-PPP requires much more work to set up and configure.
Before you begin
The best thing you can do before you start with PPP is figure out the details of your hardware.  You'll need to know the following things:
  1. the port your modem is on
  2. the speed of your modem
  3. your login id for your ISP
  4. your login password for your ISP
  5. whether or not your ISP assigns you a dynamic or a static IP
Things to read now
The following articles should be read before you continue.  You don't have to read all of it, just be aware of the terms they use and the topics they cover.  They will be useful during the setup.  I recommend them in the order they appear.  I suggest you set up your machine using the first resource and referring to my examples.   They might help.
Setting up User PPP The FreeBSD Handbook - this is what I followed when writing this article.
PPP - Pedantic PPP Primer The FreeBSD Tutuorial
Point to Point Protocol The User-PPP guide as written by the FreeBSD maintainer.
Point to Point Protocol written by the maintainer of user PPP
Configuration
This section talks about creating your /etc/ppp/ppp.conf file.  The contents of my file are listed below.  The following items should be changed.  They are in bold italics for emphasis.
  • speed
  • phone
  • authname
  • authkey
  • ifaddr

Please note that this section assumes that your ISP assigns you a static IP.  If you are assigned an IP dynamically, please see PPP Configuration section of the FreeBSD Handbook.  See the link below for a non-HTML formatted copy of this file.

default:
 set log Phase Chat Connect LCP tun command
 set device /dev/cuaa0
 set speed 38400
 deny lqr
 set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 60 \"\" ATE1Q0
                        OK-AT-OK \\dATDT\\T TIMEOUT 40 CONNECT"
myisp:
 set phone 555-1212
 set redial 10 4
 set login
 set authname blumsky
 set authkey 42over90
 set timeout 0
 set ifaddr 203.96.56.57/32 192.168.0.1/0 255.255.255.255 0.0.0.0
 add default HISADDR
 enable dns

Note that the space at the start of some of the lines is needed..  I have supplied a straight text copy which will probably copy/paste better than that listed above..

I'll be using COM1 (sio0) for my modem.  From Windows, I found that COM1 is using IRQ 4 and I/O Base of 0x3F8.  You can find this out from Control Panel/System/Device Manager.  This varies from the standard kernel so I had to create a custom kernel.

The ifaddr deserves special attention.  Remember that my ISP assigns me a static IP address.  The first number (203.96.56.57/32) is that IP.  You should refer to the CONTROLLING IP ADDRESS section of man ppp for more detail.  It contains serveral examples and you should pick the one that suits you best.

Manually using the modem
I was having trouble getting the above script to work.  So I decided to try dialing manually.  At this confirms that my modem can and will work!  I have been able to dial up my ISP by trying the following:
kennett# ppp
Working in interactive mode
Using interface: tun0
ppp ON kennett> term
deflink: Entering terminal mode on /dev/cuaa0
atdt555-1212
CONNECT 28800/ARQ/V34/LAPM/V42BIS

Myisp Networks Ltd

NOTE: Please configure your system to dial 555-1212 
                                           ONLY for PPP.

For assistance, or to report a problem, check out our web page
http://www.myisp.com, or email helpdesk@myisp.com, or phone
555 1212 (office hours).

cs2 line 6 

User Access Verification

login: mylogin
Password: 
Entering PPP mode.
Async interface address is unnumbered (Ethernet0)
Your IP address is xxx.xx.xx.xx. MTU is 1500 bytes
Header compression will match your system.

~

But when I tried the following, it didn't dial at all:

kennett# ppp
Working in interactive mode
Using interface: tun0
ppp ON kennett> dial myisp
Warning: Add route failed: default already exists
ppp ON kennett> Warning: Chat script failed
ppp ON kennett> 

Here's what I was getting in my ppp log:

ppp[285]: Phase: Using interface: tun0
ppp[285]: Phase: deflink: Created in closed state
ppp[285]: tun0: Command: default: set device /dev/cuaa0
ppp[285]: tun0: Command: default: set speed 38400
ppp[285]: tun0: Command: default: deny lqr
ppp[285]: tun0: Command: default: set dial ABORT BUSY ABORT 
                             NO\sCARRIER TIMEOUT 45 "" ATE1
ppp[285]: tun0: Phase: PPP Started (interactive mode).
ppp[285]: tun0: Command: /dev/tty: dial myisp
ppp[285]: tun0: Command: myisp: set phone 801-6622
ppp[285]: tun0: Command: myisp: set login             
ppp[285]: tun0: Command: myisp: set authname dvlsoft
ppp[285]: tun0: Command: myisp: set authkey ********
ppp[285]: tun0: Command: myisp: set timeout 0     
ppp[285]: tun0: Command: myisp: set ifaddr 203.96.56.57 
                           192.100.53.23 255.255.255.255 0.0
ppp[285]: tun0: Command: myisp: add default HISADDR
ppp[285]: tun0: Command: myisp: enable dns
ppp[285]: tun0: Phase: bundle: Establish
ppp[285]: tun0: Phase: deflink: closed -> opening
ppp[285]: tun0: Phase: deflink: Connected!
ppp[285]: tun0: Phase: deflink: opening -> dial
ppp[285]: tun0: Phase: Phone: 801-6622
ppp[285]: tun0: Chat: deflink: Dial attempt 1 of 1
ppp[285]: tun0: Chat: Send: ATE1Q0^M
ppp[285]: tun0: Chat: Expect(45): OK
ppp[285]: tun0: Chat: Received: ATE1Q0^M^M
ppp[285]: tun0: Chat: Received: OK^M
ppp[285]: tun0: Chat: Send: ATDT801-6622^M
ppp[285]: tun0: Chat: Expect(40): CONNECT
ppp[285]: tun0: Chat: Expect timeout
ppp[285]: tun0: Phase: deflink: dial -> hangup
ppp[285]: tun0: Phase: deflink: Disconnected!
ppp[285]: tun0: Phase: deflink: Connect time: 42 secs: 
                                  0 octets in, 0 octets out
ppp[285]: tun0: Phase:  total 0 bytes/sec, peak 0 bytes/sec 
                                 on Mon Mar 15 05:43:47 1999
ppp[285]: tun0: Phase: deflink: hangup -> closed
ppp[285]: tun0: Phase: bundle: Dead

So what I did was increase my timeout to 45 from 40.  And I connected!   Here's what I was getting in my log then:

ppp[314]: Phase: Using interface: tun0 
ppp[314]: Phase: deflink: Created in closed state 
ppp[314]: tun0: Command: default: set device /dev/cuaa0 
ppp[314]: tun0: Command: default: set speed 38400 
ppp[314]: tun0: Command: default: deny lqr 
ppp[314]: tun0: Command: default: set dial ABORT BUSY ABORT 
                         NO\sCARRIER TIMEOUT 45 "" ATE1Q0 
                         OK-AT-OK \dATDT\T TIMEOUT 40 CONNECT
ppp[314]: tun0: Phase: PPP Started (interactive mode). 
ppp[314]: tun0: Command: /dev/tty: dial myisp 
ppp[314]: tun0: Command: myisp: set phone 801-6622 
ppp[314]: tun0: Command: myisp: set login 
ppp[314]: tun0: Command: myisp: set authname dvlsoft 
ppp[314]: tun0: Command: myisp: set authkey ******** 
ppp[314]: tun0: Command: myisp: set timeout 0 
ppp[314]: tun0: Command: myisp: set ifaddr 203.96.56.57 
                       192.100.53.23 255.255.255.255 0.0.0.0 
ppp[314]: tun0: Command: myisp: add default HISADDR 
ppp[314]: tun0: Command: myisp: enable dns 
ppp[314]: tun0: Phase: bundle: Establish 
ppp[314]: tun0: Phase: deflink: closed -> opening 
ppp[314]: tun0: Phase: deflink: Connected! 
ppp[314]: tun0: Phase: deflink: opening -> dial 
ppp[314]: tun0: Phase: Phone: 801-6622 
ppp[314]: tun0: Chat: deflink: Dial attempt 1 of 1 
ppp[314]: tun0: Chat: Send: ATE1Q0^M 
ppp[314]: tun0: Chat: Expect(45): OK 
ppp[314]: tun0: Chat: Received: ATE1Q0^M^M 
ppp[314]: tun0: Chat: Received: OK^M 
ppp[314]: tun0: Chat: Send: ATDT801-6622^M 
ppp[314]: tun0: Chat: Expect(40): CONNECT 
ppp[314]: tun0: Chat: Received: ATDT801-6622^M^M 
ppp[314]: tun0: Chat: Received: CONNECT 
ppp[314]: tun0: Phase: deflink: dial -> login 
ppp[314]: tun0: Phase: deflink: login -> lcp 
ppp[314]: tun0: LCP: FSM: Using "deflink" as a transport 
ppp[314]: tun0: LCP: deflink: State change Initial --> Closed 
ppp[314]: tun0: LCP: deflink: State change Closed --> Stopped 
ppp[314]: tun0: LCP: deflink: LayerStart 
ppp[314]: tun0: LCP: deflink: SendConfigReq(1) state = Stopped
ppp[314]: tun0: LCP:  ACFCOMP[2] 
ppp[314]: tun0: LCP:  PROTOCOMP[2] 
ppp[314]: tun0: LCP:  ACCMAP[6] 0x00000000 
ppp[314]: tun0: LCP:  MRU[4] 1500 
ppp[314]: tun0: LCP:  MAGICNUM[6] 0x4b6ae4d1 
ppp[314]: tun0: LCP: deflink: State change Stopped 
                                              --> Req-Sent
ppp[314]: tun0: LCP: deflink: SendConfigReq(1) 
                                           state = Req-Sent
ppp[314]: tun0: LCP:  ACFCOMP[2] 
ppp[314]: tun0: LCP:  PROTOCOMP[2] 
ppp[314]: tun0: LCP:  ACCMAP[6] 0x00000000 
ppp[314]: tun0: LCP:  MRU[4] 1500 
ppp[314]: tun0: LCP:  MAGICNUM[6] 0x4b6ae4d1 
ppp[314]: tun0: LCP: deflink: RecvConfigReq(225) 
                                          state = Req-Sent
ppp[314]: tun0: LCP:  ACCMAP[6] 0x000a0000 
ppp[314]: tun0: LCP:  AUTHPROTO[4] 0xc023 (PAP) 
ppp[314]: tun0: LCP:  MAGICNUM[6] 0x0fc4f116 
ppp[314]: tun0: LCP:  PROTOCOMP[2] 
ppp[314]: tun0: LCP:  ACFCOMP[2] 
ppp[314]: tun0: LCP: deflink: SendConfigAck(225) 
                                           state = Req-Sent
ppp[314]: tun0: LCP:  ACCMAP[6] 0x000a0000 
ppp[314]: tun0: LCP:  AUTHPROTO[4] 0xc023 (PAP) 
ppp[314]: tun0: LCP:  MAGICNUM[6] 0x0fc4f116 
ppp[314]: tun0: LCP:  PROTOCOMP[2] 
ppp[314]: tun0: LCP:  ACFCOMP[2] 
ppp[314]: tun0: LCP: deflink: State change Req-Sent 
                                            --> Ack-Sent
ppp[314]: tun0: LCP: deflink: SendConfigReq(1) 
                                          state = Ack-Sent
ppp[314]: tun0: LCP:  ACFCOMP[2] 
ppp[314]: tun0: LCP:  PROTOCOMP[2] 
ppp[314]: tun0: LCP:  ACCMAP[6] 0x00000000 
ppp[314]: tun0: LCP:  MRU[4] 1500 
ppp[314]: tun0: LCP:  MAGICNUM[6] 0x4b6ae4d1 
ppp[314]: tun0: LCP: deflink: RecvConfigAck(1) state = Ack-Sent
ppp[314]: tun0: LCP: deflink: State change Ack-Sent --> Opened
ppp[314]: tun0: LCP: deflink: LayerUp 
ppp[314]: tun0: Phase: bundle: Authenticate 
ppp[314]: tun0: Phase: deflink: his = PAP, mine = none 
ppp[314]: tun0: Phase: Pap Output: dvlsoft ******** 
ppp[314]: tun0: Phase: Pap Input: SUCCESS () 
ppp[314]: tun0: Phase: deflink: lcp -> open 
ppp[314]: tun0: Phase: bundle: Network 
ppp[314]: tun0: LCP: deflink: RecvProtocolRej(226) 
                                               state = Opened
ppp[314]: tun0: LCP: deflink: -- Protocol 0x80fd (Compression
                                Control Protocol) was rejected!
ppp[314]: tun0: LCP: deflink: RecvEchoRequest(1) state = Opened
ppp[314]: tun0: LCP: deflink: SendEchoReply(1) state = Opened
ppp[314]: tun0: LCP: deflink: RecvEchoRequest(2) state = Opened
ppp[314]: tun0: LCP: deflink: SendEchoReply(2) state = Opened
ppp[314]: tun0: Phase: deflink: HDLC errors -> FCS: 1, ADDR: 0,
                                             COMD: 0, PROTO: 0
ppp[314]: tun0: LCP: deflink: RecvEchoRequest(3) state = Opened
ppp[314]: tun0: LCP: deflink: SendEchoReply(3) state = Opened
ppp[314]: tun0: LCP: deflink: RecvEchoRequest(4) state = Opened
ppp[314]: tun0: LCP: deflink: SendEchoReply(4) state = Opened
Routing tables and interfaces
Here's what tun0 looked like after connecting:
$ ifconfig tun0
tun0: flags=8051 mtu 1500
        inet 203.96.56.57 --> 192.100.53.23 netmask 0xffffffff 

Here's what my routing table looked like before I connected.  Note that unless you have a network card, you probably won't have a line like the ones with Netif = ed0.

kennett# netstat -rn
Routing tables

Internet:
Destination   Gateway       Flags  Refs   Use     Netif Expire
127.0.0.1     127.0.0.1     UH       0      0      lo0
192.168       link#1        UC       0      0      ed0

And after connecting:

kennett# netstat -rn
Routing tables

Internet:
Destination   Gateway       Flags  Refs   Use     Netif Expire
default       192.100.53.23 UGSc     0      0     tun0
127.0.0.1     127.0.0.1     UH          0        0      lo0
192.100.53.23 203.96.56.57  UH          1        0     tun0
192.168       link#1        UC          0        0      ed0

You can see that the IP specified in my ifaddr line of my configuration file appears under Gateway for the destination 192.100.52.23, which is the local address of tun0.   The default address is also the same destination.  This means that unless another destination is found, the traffic will go out on that address, to your ISP.

If you have problems
  • If the modem is external, make sure the modem is plugged into the correct serial port and is powered on.
  • Check that you are specifying the correct port in the ppp configuration file.
  • Verify that your ifaddr line is correct.  Look at the CONTROLLING IP ADDRESS section of man ppp.
Advanced configurations
This example involves only one configuration, namely, the myisp setup.   You can have more than one configuration within the file.  See the PPP - Pedantic PPP Primer for examples on how this can be done.
Auto dialing
You can configure PPP so that it dials your ISP whenever traffic is ready to go out.   For example, whenever someone browses to a webpage, etc.  This can be done by issuing the following command:
ppp -auto myisp

You could do this at boot time by adding the following to /etc/rc.local (NOTE:  /etc/rc.local is deprecated; use /usr/local/etc/rc.d/ instead; see Starting stuff at boot time and Installing IP Filter 3.3.3 for an example):

echo " ppp" && ppp -auto myisp

If you were adding this to /usr/local/etc/rc.d/, you would have this instead:

#!/bin/sh
echo " ppp" && ppp -auto myisp
Auto hangup
You can set this connection to automatically hang up after an idle period by adding the following line to your configuration file:
set timeout 600

This will hang up after 600 seconds.  If you set it to zero, it will never time out.

Manual hangup
If you issue the following command, ppp will terminate the current connection:
killall -INT ppp

This will cause ppp to terminate:

killall -HUP ppp

See man ppp for more information.

Share
Need more help on this topic? Click here
This article has no comments
Show me similar articles