Diald Howto
AndresSH@ctv.esv1.03, April 17, 2000
This document shows some typical scenarios for easy start using Diald. These scenarios include a connection from a standalone computer to an ISP using PPP over a modem without using pon/poff or ppp-on/ppp-off to a proxy/firewall server with different Internet connections through various ISPs.
This document shows some typical scenarios for easy start using Diald. These scenarios include a connection from a standalone computer to an ISP using PPP over a modem without using pon/poff or ppp-on/ppp-off to a proxy/firewall server with different Internet connections through various ISPs.
In the present document, the following scenarios will be treated:
*
*
*
In following versions of this document, other scenarios will be added, as multiple instances of Diald, ISDN lines and lines used to call and receive calls.
Before this document, a Diald-mini-Howto exist, wrote by Harish Pillay
h.pillay@ieee.org, that presented and example of connection to an ISP using a chat based authentication scheme (login and password previous to the pppd start, with no use of PAP or CHAP).
Example configuration files will be included in this document to serve as starting point to get Diald up. To obtain maximum performance and all programs attributes, it is necesary you read all documentation from the programs and reconfigure the example configuration files included here.
Finally, configuration files can be in different directories depending on what GNU/Linux distribution you are using. If you find a file commented here in other directory, please, write me.
Latest version of this document can be found in my web page
http://www.ctv.es/USERS/andressh/linux, in SMGL and HTML
formats. Other versions and formats can be found in Spanish in the Insflug
web site,
http://www.insflug.org/documentos/Diald-Como/, and in other
languages in the LDP - Linux Documentation Project,
http://www.linuxdoc.org.
I want to be grateful to the people that help me to get my first Diald up and running with their example files (somebody who's name i forgot, Mr Cornish Rex, Hoo Kok Mun and John Dalbec), to the people that have wrote me to send corrections and suggestions for this document (Tim Coleman, Jacob Joseph, Paul Schmidt and Jordi Mallach), to the future translators of this document to other languages, and, of course, to all the people that have developed and develops Diald for us.
This document was originally wrote in Spanish. The own author translated it, and some people made corrections.
This document is Copyright (c) 2000 Andres Seco, and it's free. You can distribute it under the terms of the
GNU General Public License, which you can get at
http://www.gnu.org/copyleft/gpl.html. You can get unofficial
translated issues somewhere in the Internet.
Information and other contents in this document are the best of our knowledge. However, we may have made errors. So you should determine if you want to follow the instructions given in this document.
Nobody is responsible for any damage to your computer and any other loss derived from the use of the information contained herein.
THE AUTHOR AND MAINTAINERS ARE NOT RESPONSIBLE FOR ANY DAMAGE INCURRED DUE TO ACTIONS TAKEN BASED ON INFORMATION CONTAINED IN THIS DOCUMENT.
Of course, i am open to all type of suggestions and corrections on the content of this document.
In a few words, Diald creates a new network interface and sets it as the default gateway. This interface is not real (in the original documentation it is called proxy interface). Diald monitors this interface, and, when packets arrive, makes a ppp connection, waits for it to be stablished and changes the default gateway to this new ppp interface (usually ppp0).
Diald monitors the interface to determine which packets have been received the interface and their types to decide if they are going to be considered to set the ppp connection up, maintain the link, drop it or do nothing, and how long the link should be help up after the packet is transmitted.
Finally, if there is no more traffic and the last packet up time is over, Diald will close the link.
You can control days and hours when the link can go up and when it cannot, so you can use the low cost hours/days or low trafic times.
This previous description is valid for Diald versions from 0.16.5 to latest (0.99.3 when this document was finished), but latest versions also include aditional attributes such as user enabled list, advanced accounting, better support for ISDN lines, better performance using an ethertap device as proxy (this is like a network interface that read/writes over a socket instead of a real network adapter) in place of slip, backup connections and other functions.
When you connect to an Internet Services Provider, it is usually necesary that you send an username and a password. This can be accomplished using several methods; the exact method that you use is determined by your provider.
Added to the three shown options, you can use a link without authentication, (generally when the remote end is also yours).
Actually, this is not an usual authentication method to access the Internet through an ISP.
Identification is made before pppd is started, and it is the dialer, usually chat, who sends the login name and the password. This data is sent in plaintext, so this method should not be considered secure.
An example script for chat where you can see how to specify username and password to be sent before running pppd would look something like this:
ABORT BUSY ABORT "NO CARRIER" ABORT VOICE ABORT "NO DIALTONE" ABORT "NO ANSWER" "" ATZ OK ATDT_!TelephoneNumber?_ CONNECT \d\c ogin Username assword Password
The last 2 lines define username and password, and when to send it (after receiving ogin and assword respectively. The chat script only needs to see parts of the words login and password and so we don't check the first letter of each. This is so that we don't need to worry about uppercase/lowercase characters.
Suppose that this script is called provider, and it is saved into the /etc/chatscripts directory. Then, you can run it with:
/usr/sbin/chat -v -f /etc/chatscripts/provider
If the provider you are using requires PAP as the authentication protocol, during the LCP negotiation in PPP this protocol will be asked to use this protocol. When the phone call is connected after using chat, pppd is started. In this scenario, pppd will send the username and the password, which it will look for in the /etc/ppp/pap-secrets file. This file must have read and write permissions only for root only, so that nobody else can read the passwords inside it.
PAP is not very secure, as the password is sent in plaintext, so can be read by somebody that monitors your transmission line.
Simple example of /etc/ppp/pap-secrets:
Username * Password
If the provider you are using requires CHAP as the authentication protocol, during the LCP negotiation in PPP this protocol will be asked to use this protocol. When the phone call is connected after using chat, pppd is started. In this scenario, pppd will send the username and the password, which it will look for in the /etc/ppp/chap-secrets file. This file must have read and write permissions only for root only, so that nobody else can read the passwords inside it.
CHAP is more secure than PAP, as the password is never sent through the transmission line in plaintext. The authentication server sends a random identifier (the challenge), that the client must encrypt with its password, and then send back to the server.
Simple example of /etc/ppp/chap-secrets:
Username * Password
Sometimes an ISP uses PAP and other times CHAP, so it is common to define your username and password in both files.
Everytime you connect to an ISP, it is necesary to have configured DNS name resolution, so your computer can find IP addresses associated to a computer name.
IP addresses of your DNS servers are placed into the /etc/resolv.conf file.
In a standalone computer connecting to Internet, this file usually contains the IP addresses of your ISP's DNS servers:
nameserver 111.222.333.444 nameserver 222.333.444.555
In a proxy/firewall computer, this file usually contains its own IP address (or the loopback address, 127.0.0.1), and this computer includes a DNS server that translates DNS names to IP addresses by querying external DNS servers.
nameserver 127.0.0.1
Installation of a local DNS server is out of the scope of this document.
There is a lot of documentation about this, but a good and quick approach
can be found in the DNS-Howto (
http://www.linuxdoc.org/HOWTO/DNS-HOWTO.html).
When configuring Diald to connect your computer to an ISP, the next steps will be necesary:
install the package that comes with your GNU/Linux distribution. *
*
includes an utility to configure a connection, the quickest way will be to
use it (pppconfig in Debian, kppp if you use KDE, etc). If you are having
problems connecting to an ISP, the PPP-Howto (
http://www.linuxdoc.org/HOWTO/PPP-HOWTO.html), Modem-Howto
(
http://www.linuxdoc.org/HOWTO/Modem-HOWTO.html) and
Serial-Howto (
http://www.linuxdoc.org/HOWTO/Serial-HOWTO.html) documents
can help you.
*
and /etc/ppp/chap-secrets files, as mentioned in previous sections. *
And finally, going into Diald:
(/etc/diald/diald.options for version 0.16.5 and /etc/diald/diald.conf for later versions). *
or better, leave that file as is, and modify a copy of it that you can call /etc/diald/personal.filter. *
(/etc/diald/diald.connect with execute permissions for root) and instruction file for chat (/etc/chatscripts/provider), that will be used by the previous script. *
(/etc/diald/ip-up and /etc/diald/ip-down) if you want to use it (both must have execute permissions for root). *
(/etc/diald/addroute and /etc/diald/delroute) if you want (both must have execute permissions for root). This step is not necesary if you only use a single Diald instance. *
(/etc/init.d/diald start in Debian, /etc/rc.d/init.d/diald start in !RedHat). Normally, Diald package installation process prepares the scripts to run Diald when the computer boot up in the /etc/rcX.d directories. *
If you make any change in the Diald config file when it is running, it is necesary to restart it (/etc/init.d/diald restart in Debian, /etc/rc.d/init.d/diald restart in !RedHat).
In this example file you must check for:
*
*
*
*
*
Options ip-up and ip-down. *
scripts. Options addroute and delroute. Generally it is not needed to modify this scripts, but if you use more than one instance of Diald or have a complex configuration, you need it. *
include. *
device /dev/ttyS0
accounting-log /var/log/diald.log
mode ppp
local 127.0.0.5
remote 127.0.0.4
netmask 255.255.255.0
dynamic
two-way
reroute
defaultroute
ip-up /etc/diald/ip-up
connect "/etc/diald/diald.connect"
modem crtscts speed 115200
connect-timeout 120 redial-timeout 60 start-pppd-timeout 120 died-retry-count 0 redial-backoff-start 4 redial-backoff-limit 300 dial-fail-limit 10
pppd-options noauth user usuario@isp
restrict 8:00:00 18:00:00 1-5 * * down restrict * * * * *
impulse 160,0,0
include /etc/diald/personal.filter
Manipulation of this file must be done very carefully. This file is used to decide when and why to start up the line, maintain it, bring down the line or ignore a packet, depending on the traffic type.
Generally, the Diald standar filter file is sufficient for most cases, but perhaps, it may be too restrictive or not restrictive enough in some situations. The personal.filter file that is shown has some corrections over the original from the 0.16 version.
In next versions of this document, other commented more restrictive examples will be included.
#
#
#
ignore icmp any
#
#
#
accept tcp 15 tcp.syn
ignore tcp tcp.dest=tcp.domain ignore tcp tcp.source=tcp.domain
accept tcp 5 ip.tot_len=40,tcp.syn
ignore tcp ip.tot_len=40,tcp.live
ignore tcp tcp.fin
accept tcp 120 tcp.dest=tcp.www accept tcp 120 tcp.source=tcp.www
accept tcp 120 tcp.dest=tcp.443 accept tcp 120 tcp.source=tcp.443
keepup tcp 5 !tcp.live ignore tcp !tcp.live
accept tcp 120 tcp.dest=tcp.ftp accept tcp 120 tcp.source=tcp.ftp
accept tcp 240 any
#
ignore udp udp.dest=udp.who ignore udp udp.source=udp.who
ignore udp udp.dest=udp.route ignore udp udp.source=udp.route
ignore udp udp.dest=udp.ntp ignore udp udp.source=udp.ntp ignore udp udp.dest=udp.timed ignore udp udp.source=udp.timed
ignore udp udp.dest=udp.domain,udp.source=udp.domain
accept udp 30 udp.dest=udp.domain accept udp 30 udp.source=udp.domain
ignore udp udp.source=udp.netbios-ns,udp.dest=udp.netbios-ns accept udp 30 udp.dest=udp.netbios-ns accept udp 30 udp.source=udp.netbios-ns
ignore udp tcp.dest=udp.route ignore udp tcp.source=udp.route
accept udp 120 any
accept any 30 any
/etc/diald/diald.connect file (it must have execute permission):
/usr/sbin/chat -f /etc/chatscripts/provider
/etc/chatscripts/provider file. In this example file you must check the destination phone number:
ABORT BUSY ABORT "NO CARRIER" ABORT VOICE ABORT "NO DIALTONE" ABORT "NO ANSWER" "" ATZ OK ATDT123456789 CONNECT \d\c
It must have execute permission.
This script can be used to many tasks (synchronize time, send the queued mail, get incoming mail, etc.).
In the example, a message is sent to root with data passed to the script (interface, subnet mask, local ip address, remote ip address and cost for routing):
iface=$1 netmask=$2 localip=$3 remoteip=$4 metric=$5
echo `date` $1 $2 $3 $4 $5 | mail -s "diald - conecting" root@localhost
Many times, one standalone computer does not only connect to just one network. It is common to connect to different networks or to the Internet using some different service providers. In this case, changing configuration files each time you want to connect to a different site can be annoying.
The solution i propose here consist in using different sets of configuration files for each different connection. You can find here some scripts to automate changing from one to another.
If your email client program uses a local Message Transfer Agent with a smtp relay host to send all messages, or if you use a email client program that sends the messages directly to your provider's smtp server, changing where you are connecting means you need to reconfigure this option for the smtp relay server. This is because the providers usually check if the receipt mailbox is local or to any domain directly maintained by this provider or if the origin ip address is from the range of ip addresses that this provider assigns, to avoid having an open relay server that can be used to send spam, anonymous message and so on.
In the following examples, you will find how to change this parameter in the Smail configuration files in a simple configuration where all external messages are sent to a smtp relay server. If you use another Message Transfer Agent (MTA) in your system, you can send me what you must change in your MTA to include it here. If you use an email client program that directly sends to the external smtp server (Kmail, Netscape, etc.) send me your changes too.
First of all, create a subdirectory of /etc/diald called providers where you store your scripts to automatically change from one to another provider and the subdirectories with the set of files to configure each of the providers connections.
With the next script this directory is created and filled with the current configuration files from Diald, chat, pppd and Smail, that will be treated as a template for the next configurations.
mkdir /etc/diald/providers mkdir /etc/diald/providers/setup cp /etc/ppp/pap-secrets /etc/diald/providers/setup cp /etc/ppp/chap-secrets /etc/diald/providers/setup cp /etc/resolv.conf /etc/diald/providers/setup cp /etc/diald/diald.options /etc/diald/providers/setup cp /etc/diald/standard.filter /etc/diald/providers/setup cp /etc/diald/personal.filter /etc/diald/providers/setup cp /etc/diald/diald.connect /etc/diald/providers/setup cp /etc/chatscripts/provider /etc/diald/providers/setup cp /etc/diald/ip-up /etc/diald/providers/setup cp /etc/diald/ip-down /etc/diald/providers/setup cp /etc/smail/routers /etc/diald/providers/setup
With the next script the template configuration will be copied to a new directory to prepare it for a new provider connection or a new net connection. This script (/etc/diald/providers/newdialdprovider) will need a parameter with the provider or net name.
mkdir /etc/diald/providers/$1 cp /etc/diald/providers/setup/* /etc/diald/providers/$1
Now, you will modify as you need the new files in /etc/diald/providers/provdidername, being providername the parameter passed to newdialdprovider.
At the end, with this script you will change all your configuration files related to Diald to connect to another provider or net. I use symbolic links to avoid using duplicate files. Using symbolic links, if you change any config file in its original location like /etc/resolv.conf, the change is really made in the /etc/diald/providers/providername/resolv.conf file.
/etc/init.d/diald stop
sleep 4 ln -sf /etc/diald/providers/$1/pap-secrets /etc/ppp ln -sf /etc/diald/providers/$1/chap-secrets /etc/ppp ln -sf /etc/diald/providers/$1/resolv.conf /etc ln -sf /etc/diald/providers/$1/diald.options /etc/diald ln -sf /etc/diald/providers/$1/standard.filter /etc/diald ln -sf /etc/diald/providers/$1/personal.filter /etc/diald ln -sf /etc/diald/providers/$1/diald.connect /etc/diald ln -sf /etc/diald/providers/$1/provider /etc/chatscripts ln -sf /etc/diald/providers/$1/ip-up /etc/diald ln -sf /etc/diald/providers/$1/ip-down /etc/diald ln -sf /etc/diald/providers/$1/routers /etc/smail /etc/init.d/diald start
Connecting a private net to the Internet with dedicated server which handles packet routing from the local network to the Internet along with proxy/caching services and security firewalling is a complex theme that is beyond the scope of this document. There are other Howto documents that handle these topics much more comprehensively. At the end of this document you can find a list of links and references to such documents.
Here, we are only configuring Diald supposing that the computer already uses IP-Masquerading, has a web proxy like Squid or similar working, an ISP connection correctly configured and that access security to TCP/UDP ports have been revised (/etc/inetd.conf file and others like securetty, host.allow, etc).
Basically, the only need is to reconfigure the rules for masquerading/filtering/accessing each time the set of interfaces change, that is, when the interface ppp0 is stablished and when it is deleted. A good location to do that are the ip-up and ip-down scripts from pppd.
With Debian, it is sufficient to install the ipmasq package answering that you want to change rules sinchronously with pppd when seting it up. Two scripts will be created inside /etc/ppp/ip-up.d and /etc/ppp/ip-down.d directories to call /sbin/ipmasq, a script that analizes existing interfaces and makes a simple configuration that is valid in many cases, but you can personalize it using rule files in /etc/ipmasq/rules.
The only correction after installing this package is to change when the startup script for ipmasq is run, deleting the symbolic link from /etc/rcS.d and creating a new one in /etc/rc2.d to run it after S20diald. Now, when ipmasq is executed to analyze interfaces sl0 already exist. S90ipmasq is a good name for this symbolic link to /etc/init.d/ipmasq.
Using Debian there is no need to worry about the kernel version, as the /sbin/ipmasq script uses ipfwadm or ipchains as needed.
This example is from Mr Cornish Rex, troll@tnet.com.au.
The following ip-masp and routing control commands are for use with version 2.2 kernels, using ipchains, but they are not valid for version 2.0 kernels.
We are going to supose that the ethernet interface has the 192.168.1.1 ip address with 16 bit netmask, that is, 255.255.0.0.
This is the /etc/ppp/ip-up file:
/sbin/ipchains -F input /sbin/ipchains -P input DENY /sbin/ipchains -A input -j ACCEPT -i eth0 -s 192.168.0.0/16 -d 0.0.0.0/0 /sbin/ipchains -A input -j DENY -p udp -i $1 -s 0.0.0.0/0 -d $4/32 0:52 -l /sbin/ipchains -A input -j DENY -p udp -i $1 -s 0.0.0.0/0 -d $4/32 54:1023 -l /sbin/ipchains -A input -j DENY -p tcp -i $1 -s 0.0.0.0/0 -d $4/32 0:112 -l /sbin/ipchains -A input -j DENY -p tcp -i $1 -s 0.0.0.0/0 -d $4/32 114:1023 -l /sbin/ipchains -A input -j DENY -p tcp -i $1 -s 0.0.0.0/0 -d $4/32 6000:6010 -l /sbin/ipchains -A input -j DENY -p icmp --icmp-type echo-request \
/sbin/ipchains -A input -j DENY -p icmp -f -i $1 -s 0.0.0.0/0 -l /sbin/ipchains -A input -j DENY -p udp -i $1 -s 0.0.0.0/0 -d $4/32 5555 -l /sbin/ipchains -A input -j DENY -p udp -i $1 -s 0.0.0.0/0 -d $4/32 8000 -l /sbin/ipchains -A input -j DENY -p tcp -i $1 -s 0.0.0.0/0 -d $4/32 8000 -l /sbin/ipchains -A input -j DENY -p udp -i $1 -s 0.0.0.0/0 -d $4/32 6667 -l /sbin/ipchains -A input -j DENY -p tcp -i $1 -s 0.0.0.0/0 -d $4/32 6667 -l /sbin/ipchains -A input -j DENY -p tcp -i $1 -s 0.0.0.0/0 -d $4/32 4557 -l /sbin/ipchains -A input -j DENY -p tcp -i $1 -s 0.0.0.0/0 -d $4/32 4559 -l /sbin/ipchains -A input -j DENY -p tcp -i $1 -s 0.0.0.0/0 -d $4/32 4001 -l /sbin/ipchains -A input -j DENY -p tcp -i $1 -s 0.0.0.0/0 -d $4/32 2005 -l /sbin/ipchains -A input -j DENY -p tcp -i $1 -s 0.0.0.0/0 -d $4/32 6711 -l /sbin/ipchains -A input -j DENY -i $1 -s 192.168.0.0/16 -d 0.0.0.0/0 -l /sbin/ipchains -A input -j ACCEPT -i $1 -s 0.0.0.0/0 -d $4/32 /sbin/ipchains -A input -j ACCEPT -i lo -s 0.0.0.0/0 -d 0.0.0.0/0 /sbin/ipchains -A input -j DENY -s 0.0.0.0/0 -d 0.0.0.0/0 -l /sbin/ipchains -F output /sbin/ipchains -P output DENY /sbin/ipchains -A output -j ACCEPT -i eth0 -s 0.0.0.0/0 -d 192.168.0.0/16 /sbin/ipchains -A output -j DENY -i $1 -s 192.168.0.0/16 -d 0.0.0.0/0 -l /sbin/ipchains -A output -j ACCEPT -i $1 -s $4/32 -d 0.0.0.0/0 /sbin/ipchains -A output -j ACCEPT -i lo -s 0.0.0.0/0 -d 0.0.0.0/0 /sbin/ipchains -A output -j DENY -s 0.0.0.0/0 -d 0.0.0.0/0 /sbin/ipchains -F forward /sbin/ipchains -P forward DENY /sbin/ipchains -M -S 120 120 120 /sbin/ipchains -A forward -j MASQ -s 192.168.1.0/24 /sbin/ipchains -A forward -j DENY -s 0.0.0.0/0 -d 0.0.0.0/0 exit 0
This is the /etc/ppp/ip-down file:
/sbin/ipchains -F input /sbin/ipchains -F output /sbin/ipchains -F forward /sbin/ipchains-restore < /etc/ppp/orig.chains
Last file in last script, orig.chains, is the following file (original status of ipchains):
:input ACCEPT :forward ACCEPT :output ACCEPT
This example is from Hoo Kok Mun, hkmun@pacific.net.sg.
This is the most simple example i have seen, but fully functional. From the beginning, this example configures masquerading, before the sl0 interface exists, and it does not change when the ppp0 interface appears. If you need advanced security considerations, it may be a little limited.
/sbin/ipfwadm -F -p deny /sbin/ipfwadm -F -a m -S 192.168.0.0/24 -D 0.0.0.0/0
As you can see, it is for version 2.0 kernels.
To write this document i have used the following diald versions:
*
document. *
And the following pppd versions:
*
Diald 0.16.5 version is perhaps the most extended, and the one that many Linux distributions include. It is suficient for many sites, and it is very reliable, but, of course, later versions have many interesting capabilites.
Original information from where this document has been obtained can be found in the man pages about diald, diald-examples, diald-control, diald-monitor, dctrl, pppd, chat, as well as from information in the /usr/doc directories and in web pages of this packages:
http://diald.sourceforge.net/
*
ftp://diald.sourceforge.net/pub/diald/
*
http://www.loonie.net/erics/diald.html
*
ftp://cs.anu.edu.au/pub/software/ppp/
*
http://rufus.w3.org/linux/RPM/
*
There is a mailing list for discussion about diald on David S. Miller's mailing list server at vger.rutgers.edu. To subscribe, send a message to
Majordomo@vger.rutgers.edu with the text subscribe linux-diald IN THE MESSAGE BODY.
An archive of the list can be found in
http://www.geocrawler.com.
There are also multiple RFC documents (Request For Comments) that define how the PPP encapsulated lines and its associated protocols (LCP, IPCP, PAP, CHAP, ...) must work. You can find these documents in the /usr/doc/doc-rfc directory and some World Wide Web sites, like
http://metalab.unc.edu and
http://nic.mil/RFC. You can ask for
information about RFCs in
RFC-INFO@ISI.EDU.
The following Howtos can help you:
http://www.linuxdoc.org/HOWTO/DNS-HOWTO.html
*
http://www.linuxdoc.org/HOWTO/Firewall-HOWTO.html
*
http://www.linuxdoc.org/HOWTO/IP-Masquerade-HOWTO.html
*
http://www.linuxdoc.org/HOWTO/IPCHAINS-HOWTO.html
*
http://www.linuxdoc.org/HOWTO/Modem-HOWTO.html
*
http://www.linuxdoc.org/HOWTO/NET3-4-HOWTO.html
*
http://www.linuxdoc.org/HOWTO/PPP-HOWTO.html
*
http://www.linuxdoc.org/HOWTO/Serial-HOWTO.html
*
No other page links to HowToDialdHOWTO yet.
lib/main.php:944: Notice: PageInfo: Cannot find action page