Опубликован: 06.08.2012 | Доступ: свободный | Студентов: 1189 / 25 | Оценка: 5.00 / 5.00 | Длительность: 53:41:00
Лекция 20:

Configuring PPP

The net mask for the link

As we saw on page 290, with a broadcast medium you use a net mask to specify which range of addresses can be addressed directly via the interface. This is a different concept from routing, which specifies ranges of addresses that can be addressed indirectly via the interface. By definition, a point-to-point link only has one address at the other end, so the net mask must be

Static and dynamic addresses

Traditionally, each interface has had a specific address. With the increase in the size of the Internet, this has caused significant problems: a few years ago, people claimed that the Internet was running out of addresses. As a solution, Version 6 of the Internet Protocol (usually called IPv6) has increased the length of an address from 32 bits to 128 bits, increasing the total number of addresses from 4,294,967,296 to 3.4x10^38—enough to assign multiple IP addresses to every atom on Earth (though there may still be a limitation when the Internet grows across the entire universe). FreeBSD contains full support for IPv6, but unfortunately that’s not true of most ISPs, so at present, IPv6 is not very useful. This book doesn’t discuss it further.

ISPs don’t use IPv6 because they have found another "solution" to the address space issue: dynamic IP addresses. With dynamic addresses, every time you dial in, you get a free IP address from the ISP's address space. That way, an ISP only needs as many IP addresses as he has modems. He might have 128 modems and 5000 customers. With static addresses, he would need 5000 addresses, but with dynamic addresses he only needs 128. Additionally, from the ISPs point of view, routing is trivial if he assigns a block of IP addresses to each physical piece of hardware.

Dynamic addresses have two very serious disadvantages:

  1. IP is a peer-to-peer protocol: there is no master and no slave. Theoretically, any system can initiate a connection to any other, as long as it knows its IP address. This means that your ISP could initiate the connection if somebody was trying to access your system. With dynamic addressing, it is absolutely impossible for anybody to set up a connection: there is no way for any other system to know in advance the IP address that you will get when the link is established.

    This may seem unimportant—maybe you consider the possibility of the ISP calling you even dangerous—but consider the advantages. If you're travelling somewhere and need to check on something on your machine at home, you can just connect to it with ssh. If you want to let somebody collect some files from your system, there’s no problem. In practice, however, very few ISPs are prepared to call you, though that doesn't make it a bad idea.

  2. Both versions of PPP support an idle timeout feature: if you don’t use the link for a specified period of time, it may hang up. Depending on where you live, this may save on phone bills and ISP connect charges. It only disconnects the phone link, and not the TCP sessions. Theoretically you can reconnect when you want to continue, and the TCP session will still be active. To continue the session, however, you need to have the same IP address when the link comes up again. Otherwise, though the session isn’t dead, you can’t reconnect to it.

Setting a default route

Very frequently, the PPP link is your only connection to the Internet. In this case, you should set the default route to go via the link. You can do this explicitly with the route add command, but both versions of PPP can do it for you.

When you set your default route depends on what kind of addressing you're using. If you're using static addressing, you can specify it as one of the configuration parameters. If you're using dynamic addressing, this isn’t possible: you don't know the address at that time. Both versions have a solution for this, which we'll look at when we get to them.


A PPP link over modem typically costs money. You will normally pay some or even all of the following charges:

  • Telephone call setup charges, a charge made once per call. Unlike the other charges, these make it advantageous to stay connected as long as possible.
  • Telephone call duration charges. In some countries, you pay per time unit (for example, per minute), or you pay a fixed sum for a variable unit of time.
  • ISP connect charges, also per time unit.
  • ISP data charges, per unit of data.

Typically, the main cost depends on the connection duration. To limit this cost, both PPP implementations supply methods to dial automatically and to disconnect when the line has been idle for a predetermined length of time.

The information you need to know

Whichever PPP implementation you decide upon, you need the following information:

  • Which physical device you will use for the connection. For modem, it’s normally a serial port like /dev/cuaaO. For PPPoE, it's an Ethernet adapter, for example xl0.
  • If it’s modem connection, whom are you going to call? Get the phone number complete with any necessary area codes, in exactly the format the modem needs to dial. If your modem is connected to a PABX, be sure to include the access code for an external line.
  • The user identification and password for connection to the ISP system.
  • The kind of authentication used (usually CHAP or PAP).

In addition, some ISPs may give you information about the IP addresses and network masks, especially if you have a static address. You should have collected all this information in the table on page 323.

Setting up user PPP

This chapter contains a lot of information about PPP setup. If you're in a hurry, and you have a "normal" PPP connection, the following steps may be enough to help you set it up. If it doesn’t work, just read on for the in-depth explanation.

  • Edit /etc/ppp/ppp.conf. Find these lines lines:
      (comments omitted)
    set phone PHONE_NUM      only for modem connections
    set auth name USER_NAME
    set auth key PASSWORD

    Replace the texts PHONE_NUM, USERNAME and PASSWORD with the information supplied by the ISP. If you’re using PPPoE, remove the set phone line.

  • Still in /etc/ppp/ppp.conf, check that the device is correct. The default is /dev/cuaal. If you're connecting to a different serial line, change the device name accordingly. If you're running PPPoE, say over the Ethernet interface xlO, change it to:
    set device PPPoE:xl0
  • Modify /etc/rc. con/First, check the PPP settings in /etc/defaults/rc.conf. Currently they are:
    #User ppp configuration. 
    ppp_enable="NO"        # Start user-ppp (or NO). 
    ppp_mode="auto"        # Choice of "auto", "ddial", "direct" or "dedicated". 
                          #For details see man page for ppp(8). Default is auto.
    ppp_nat="YES"          # Use PPP's internal network address translation or NO. 
    ppp_profile="papchap"  # Which profile to use from /etc/ppp/ppp.conf.
    ppp_user="root"        # Which user to run ppp as

    Don’t change this file: just add the following line to /etc/rc.conf:

    ppp_enable=YES  # Start user-ppp (or NO). 
  • If you have a permanent connection (in other words, you don't ever want to disconnect the line), you should also add the following line to /etc/rc.conf:
    ppp_mode=ddial  # Choice of "auto", "ddial", "direct" or "dedicated". 

    This tells PPP not to disconnect at all.

  • After this, PPP will start automatically on boot and will connect whenever necessary. If you are not planning to reboot, you can start PPP immediately with the following command:
    # /usr/sbin/ppp -quiet -auto papchap

If that works for you, you're done. Otherwise, read on.

Владимир Шишкин
Владимир Шишкин
Россия, Киров
Олег Страхов
Олег Страхов