
The following is an Article I wrote for the NLUUG e-zine. The original
URL of it is 'http://e-zine.nluug.nl/hold.html?cid=82'.

 - Clifford



  How to configure ROCK Linux as ISDN Router                  Clifford Wolf
  ------------------------------------------                     02/24/2000


 - Preface

This article describes how to configure a ROCK Linux System as an ISDN
Dial-on-Demand Router. Most procedures and techniques described in this
article are, however, not ROCK Linux specific and can be of interest
to users of all Linux distributions available.

This article is mostly a summary of the Linux ISDN Documentation from
the isdn4linux project, the ipppd man pages and my personal experiences.

A full documentation of isdn4linux can be found in the isdn4linux FAQ at 
"http://www.isdn4linux.de/leafsite/faq.html". I am only going to give you
a quick overview of the ISDN configuration here. If you plan to work a
lot with isdn4linux you should also read the FAQ.


 - Needed Hardware and Software

You need an ISDN card. The ISDN devices which are supposed to be connected
to a RS232 interface emulate a serial modem and are not covered by this
article. A list of supported hardware can be found in the documentation
of the kernel drivers: /usr/src/linux/Documentation/isdn/*

You need the isdn4k-utils package and a kernel with support for your ISDN
adapter. The ISDN drivers can be built as modules or compiled static into
the kernel. 

 - Kernel Drivers

Enable the ISDN driver of your choice in the kernel configuration. If you need
to pass options like IRQs and IOs to the driver it is always better to use
modules instead of linking the drivers statically into the kernel.

The HiSax driver has extra drivers for the ISDN Protocol type. E.g. if
using a Teles 16.0 card on an EURO ISDN Line, its not enough to enable
the "Teles 16.0/8.0" driver - you also need to enable the support for
the "EURO/DSS1" in the kernel configuration.

If you build the driver as a module you need to insert it before working with
the ISDN device. E.g. to load the driver for my Teles card:

   modprobe hisax id=HiSax type=3 protocol=2 irq=9 io=0xd80

A successful insertion of the module should result is some log
messages in "/var/log/messages". A detailed description of the module
options can be found in "/usr/src/linux/Documentation/isdn/*".

Don't forget to run 'depmod -a' before using 'modprobe'.


 - Configuring the ISDN Device

Next we need to configure the ISDN Devices. This can be done with the
command 'isdnctrl'. Here is an example config script:

  isdnctrl addif ippp0          # Create the logical interface
  isdnctrl eaz ippp0 11223      # Set the EAZ or MSN
  isdnctrl l2_prot ippp0 hdlc   # Can be HDLC or x75
  isdnctrl l3_prot ippp0 trans  # layer-3 protocol is always 'trans'
  isdnctrl encap ippp0 syncppp  # Synchronous PPP over ISDN
  isdnctrl secure ippp0 on      # No incoming calls
  isdnctrl huptimeout ippp0 600 # Hang up after 600 secs line inactivity
  isdnctrl dialmax ippp0 5      # Number of dial attempts
  isdnctrl dialmode ippp0 auto  # Automatically dial on demand

  isdnctrl addphone ippp0 out 144556   # Number of the ISP

In most cases it's enough the change the number of the ISP and the EAZ/MSN.
The EAZ is a one-digit device id (German 1TR6 protocol only). The MSN is
the local phone number (Euro-ISDN E-DSS1 only).

Next we need to configure our ISDN device with ifconfig. For now we simply
assign a dummy IP address to it. It will be overridden anyway as soon we get
an IP Address from the ISP:

  ifconfig ippp0 192.168.111.33 pointopoint 192.168.111.33 up

To shut down the logical interface, it is enough to use "ifconfig ippp0 down"
and "isdnctrl delif ippp0".


 - Running route and ipppd

First we need to set a default route to the ippp0 device. Take care that
no other default route is configured already (normally a default route
to some gateway host on the LAN is set - simply remove the commands for
setting this default route in /etc/conf/network).

  route add default ippp0

Now we can launch ipppd. The ipppd program needs a lot of options. We don't
pass the options directly to the daemon - instead we write it into a file
and pass the filename to it. The file is called /etc/ppp/ioptions (probably
you need to create the /etc/ppp dir first) and should have the following
content:

  user "bob"           # The Username for authentication

  ipcp-accept-local    # We get the IP config from the ISP
  ipcp-accept-remote
  noipdefault

  -vj -vjccomp -ac     # disable all header-compression
  -pc -bsdcomp

  mru 1524 mtu 1500    # max receive and transmit unit

  defaultroute         # let the daemon handle the default route

We also need to configure the users password. That can be done in the
file /etc/ppp/pap-secrets:

  # username    server/isp      password
  "bob"         *               "123456789"

If your ISP requires CHAP authentication instead of PAP authentication
the file must be named /etc/ppp/chap-secrets.

Now we can launch ipppd:

  ipppd /dev/isdn/ippp0 file /etc/ppp/ioptions

As soon as the first packet reaches the ippp0 device the daemon calls
the provider and establishes the SyncPPP connection. After some time of
line inactivity (no traffic) the daemon hangs up.

The only problem remaining is that after the hang up the default route
disappears. So we need to set it again. This can be done automatically
from the script /etc/ppp/ip-down which is started by ipppd after every
hang up:

  #!/bin/sh
  /sbin/route add default ippp0

Don't forget to set the execute bit with "chmod +x /etc/ppp/ip-down". As
you can see, I wrote "/sbin/route" instead of "route". That's needed because
ipppd sets its own PATH variable which does not have /sbin in it. The script
output will be forwarded to /dev/null - so also your error messages will be
lost. That's why I prefer this version:

  #!/bin/sh
  export PATH='/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin'
  { echo "(Re-)creating the default route to ippp0"
  route add default ippp0 2>&1 ; } | logger -t ip-down

To shut down ipppd just use the command "killall ipppd".


 - Example configuration

Here is a simple example configuration. The User "bob" with the password
"bobspass" has a workstation with a connection to a LAN (eth0) and an ISDN
dial-on-demand connection to his ISP. The number of the ISP is 01445566. The
LAN uses the IP Network 192.168.22.0/24, bobs workstation has the IP Address
192.168.22.1. The workstation is a masquerading router for the entire LAN.
The ISDN Hardware is a Teles 16.0 non-pnp card and the driver is build as
module. The MSN is 42788 (we are in a country with Euro-ISDN E-DSS1).

-- /etc/conf/network --

start_net() {
        echo "Setting up loopback interface (lo)."
        ifconfig lo 127.0.0.1 netmask 255.0.0.0 up

        echo "Setting up LAN interface (eth0)."
        ifconfig eth0 192.168.22.1 netmask 255.255.255.0 up
        
        echo "Loading ISDN driver."
        modprobe hisax id=HiSax type=3 protocol=2 irq=9 io=0xd80

        echo "Setting up ISDN interface (ippp0)."

        isdnctrl addif ippp0          # Create the logical interface
        isdnctrl eaz ippp0 42788      # Set the EAZ or MSN
        isdnctrl l2_prot ippp0 hdlc   # Can be HDLC or x75
        isdnctrl l3_prot ippp0 trans  # layer-3 protocol is always 'trans'
        isdnctrl encap ippp0 syncppp  # Synchronous PPP over ISDN
        isdnctrl secure ippp0 on      # No incoming calls
        isdnctrl huptimeout ippp0 600 # Hang up after 600 secs line inactivity
        isdnctrl dialmax ippp0 5      # Number of dial attempts
        isdnctrl dialmode ippp0 auto  # Automatically dial on demand

        isdnctrl addphone ippp0 out 01445566  # Number of the ISP

        ifconfig ippp0 192.168.111.33 pointopoint 192.168.111.33 up

        echo "Running ipppd."
        route add default ippp0
        ipppd /dev/isdn/ippp0 file /etc/ppp/ioptions

        echo "Setting up masquerading."
        ipchains -A forward -j MASQ
        echo 1 > /proc/sys/net/ipv4/ip_forward
}

stop_net() {
        echo "Shutting down masquerading."
        ipchains -D forward -j MASQ
        echo 0 > /proc/sys/net/ipv4/ip_forward

        echo "Stopping ipppd."
        killall ipppd

        echo "Shutting down ISDN interface (ippp0)."
        ifconfig ippp0 down ; isdnctrl delif ippp0

        echo "Unloading ISDN driver."
        modprobe -r hisax

        echo "Shutting down LAN interface (eth0)."
        ifconfig eth0 down
        
        echo "Shutting down loopback interface (lo)."
        ifconfig lo down
}

-- /etc/ppp/ioptions --

user "bob"           # The Username for authentication

ipcp-accept-local    # We get the IP config from the ISP
ipcp-accept-remote
noipdefault

-vj -vjccomp -ac     # disable all header-compression
-pc -bsdcomp

mru 1524 mtu 1500    # max receive and transmit unit

defaultroute         # let the daemon handle the default route

-- /etc/ppp/pap-secrets --

# username    server/isp      password
"bob"         *               "bobspass"

-- /etc/ppp/ip-down --

#!/bin/sh
export PATH='/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin'
{ echo "(Re-)creating the default route to ippp0"
route add default ippp0 2>&1 ; } | logger -t ip-down


 - See Also

The man pages to the commands 'isdnctrl' and 'ipppd'.

The ISDN-4-Linux Homepage: http://www.isdn4linux.de/

The PPP Howto: http://www.interweft.com.au/other/ppp-howto/ppp-howto.html

The ROCK Linux Homepage: http://www.rocklinux.org/
