# Not routing correctly / pppd problems

## LucaSpiller

Well I suppose this is all my fault. I ran etc-update without looking closely at what was being changed / taking backups. I let it replace the new files for /etc/ppp/ip-up and ip-down. Everything seemed to be working fine until I reconnected. Then no packets were being sent to via the pppd connection.   :Mad: 

I had a look around to see what could have caused this, no obvious files has been updated today. I then found a few howto's on disc for ppp connections. One of them had something about running route if you have problems to check your kernel ip routing table.

When I am not connected it gives me the following:

```
Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.0.0     *               255.255.255.0   U     0      0        0 eth0

loopback        fe04.homenetwor 255.0.0.0       UG    0      0        0 lo
```

And when I am connected:

```
Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

195.92.66.185   *               255.255.255.255 UH    0      0        0 ppp0

192.168.0.0     *               255.255.255.0   U     0      0        0 eth0

loopback        fe04.homenetwor 255.0.0.0       UG    0      0        0 lo

```

All the howto said was to run route to see what it gives you, I hadn't even heard of this before so more research was needed. I now believe that my problem is that I do not have a default route set, which sents everything out via the ppp interface. I tried running the problem which seemed to sort of fix my problem:

```
route add -net 0.0.0.0 netmask 0.0.0.0 ppp0
```

This also causes a new problem though, my connection seems reeeeaaaallllyyy slow. 

I am now out of ideas, so any help would be greatly appreciated. I have also pasted a copy of my ip-up and ip-down files, just incase they can help.

Thanks,

Luca Spiller

-----

/etc/ppp/ip-up

```
#!/bin/sh

# this is a script which is executed after connecting the ppp interface.

# look at man pppd for details

# the followings parameters are available:

# $1 = interface-name

# $2 = tty-device

# $3 = speed

# $4 = local-IP-address

# $5 = remote-IP-address

# $6 = ipparam

if [ "$USEPEERDNS" ]; then

        # add the server supplied DNS entries to /etc/resolv.conf

        # (taken from debian's 0000usepeerdns)

        # follow any symlink to find the real file

        REALRESOLVCONF=$(readlink --canonicalize /etc/resolv.conf)

        if [ "$REALRESOLVCONF" != "/etc/ppp/resolv.conf" ]; then

                # merge the new nameservers with the other options from the old configuration

                {

                        grep --invert-match '^nameserver[[:space:]]' $REALRESOLVCONF

                        cat /etc/ppp/resolv.conf

                } > $REALRESOLVCONF.tmp

                # backup the old configuration and install the new one

                cp -a $REALRESOLVCONF $REALRESOLVCONF.pppd-backup

                mv $REALRESOLVCONF.tmp $REALRESOLVCONF

                # correct permissions

                chmod 0644 /etc/resolv.conf

                chown root:root /etc/resolv.conf

        fi

fi

[ -f /etc/ppp/ip-up.local ] && . /etc/ppp/ip-up.local "$1" "$2" "$3" "$4" "$5" "$6"
```

/etc/ppp/ip-down

```
#!/bin/sh

# this is a script which is executed after disconnecting the ppp interface.

# look at man pppd for details

# the followings parameters are available:

# $1 = interface-name

# $2 = tty-device

# $3 = speed

# $4 = local-IP-address

# $5 = remote-IP-address

# $6 = ipparam

if [ "$USEPEERDNS" ]; then

        # taken from debian's 0000usepeerdns

        # follow any symlink to find the real file

        REALRESOLVCONF=$(readlink --canonicalize /etc/resolv.conf)

        if [ "$REALRESOLVCONF" != "/etc/ppp/resolv.conf" ]; then

                # if an old resolv.conf file exists, restore it

                if [ -e $REALRESOLVCONF.pppd-backup ]; then

                        mv $REALRESOLVCONF.pppd-backup $REALRESOLVCONF

                fi

        fi

fi

[ -f /etc/ppp/ip-down.local ] && . /etc/ppp/ip-down.local "$1" "$2" "$3" "$4" "$5" "$6"
```

----------

## yassen

what's in your /etc/conf.d/net/ppp0? I have this line (older version, but must be relevant):

```
DEFROUTE="yes"                  # Must pppd set the default route?
```

----------

## LucaSpiller

It does contain that line, but I don't use that for ppp connections. That file contains all the default options, but I use an exotic way of connecting, I have a file that contains:

```
pppd ttyS0 connect '/usr/sbin/chat -v  -T<myphonenumb> -f /etc/ppp/chatscript' updetach debug name <myusername>
```

/etc/ppp/chatscript contains:

```
"" "ATZ"

#"OK" "ATL0"

#"OK" "ATM0"

SAY "Dialing modem...\n"

"OK" "ATDT \T"

ABORT BUSY

ABORT "NO CARRIER"

TIMEOUT 30

CONNECT \c
```

It may be wierd - but it did work. I am willing to try a better way if anyone has one, at once I was able to connect with just if-up ppp0 and if-down ppp0.

I am also having another (unrelated) problem with some of the recent kernels. For some reason I have to reset (turn it off for a few secs then on again) my modem before it will connect, even after a fresh boot - so far with all kernels I have tried (on Gentoo; only 2.6.x) it needs to be reset before I can connect after I have been connected before. With Mandrake and a 2.4.x kernel I haven't had this problem. It could be a kernel problem, or a Gentoo problem I am not really sure. I had this with an older (2.6) kernel, then it went away, but it is now back with 2.6.9-gentoo-r6.

----------

## yassen

Well, that explains a lot. You do NOT use "/etc/init.d/net.ppp0 start|stop", right?

Try reading "man pppd". Seems that what you need is the "defaultroute" option for pppd.

EDIT: putting this and any other options you might need into /etc/ppp/options seems a good idea to save yourself the trouble to mangle the ppp command line you already have.

----------

## LucaSpiller

All hail saviour yassen, well sort of.

The routing may be fixed but I have another problem now - the recieve light on my modem is constantly on, but I am only recieving about 0.8kb/s.  :Mad: 

"route", after a while, gives:

```
Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

aardvark.lns.wa *               255.255.255.255 UH    0      0        0 ppp0

192.168.0.0     *               255.255.255.0   U     0      0        0 eth0

loopback        fe04.homenetwor 255.0.0.0       UG    0      0        0 lo

default         aardvark.lns.wa 0.0.0.0         UG    0      0        0 ppp0
```

Any ideas?

-----

Well I have tried kppp and it seems to work fine - I will see if I can figure out what this does and turn it into a console based thing (shouldn't be too hard).

Also I have figured out the command to reset my modem, "ATM1L3".   :Very Happy:  So it wasn't a kernel problem after all.   :Wink: 

----------

## yassen

Your routing table is correct, AFAICT.

The speed problem might be due to a low serial port baud rate -- something like 9600 bps (the default). In my /etc/conf.d/net.ppp0 I have 

```
LINESPEED="115200"              # Speed pppd should try to connect at
```

So use the pppd baud rate <speed> option ('man pppd') to e.g. 57600 or 115200 and you should be fine.

(BTW, why don't you go back to the standard way ppp is handled in Gentoo?)

Cheers,

yassen

----------

## LucaSpiller

I don't thing it is a problem with the serial port speed, but I will try it when I have a chance just incase.

Gentoo has a standard way of handling ppp?   :Shocked:   :Rolling Eyes: 

----------

## yassen

I am pretty sure that this is the baud rate that limits your connection. Your modem supports  a LOT more than 0.8 KB/s, your provider SURELY suppprts a lot more than as well. So the rate limit is between the PC and modem.

According to 'man pppd' your startup line shpuld look something like 

```
pppd  ttyS0 115200 connect '/usr/sbin/chat -v  -T<myphonenumb> -f /etc/ppp/chatscript' updetach debug name <myusername>
```

 *Quote:*   

> Gentoo has a standard way of handling ppp?

 

Sure, as any other net interface, you have:

(1) /etc/conf.d/net.ppp0 where you make (tune, to be exact) basic port & modem setups

(2) /etc/init.d/net.ppp0 to start and stop the ppp interface.

This handles 95% of all trouble for you. Here's  my /etc/conf.d/net.ppp0:

```
PEER="BTC"                      # Define peer (aka ISP)

DEBUG="no"                      # Turn on debugging

PERSIST="no"                    # Redial after being dropped

ONDEMAND="yes"                  # Only bring the interface up on demand?

MODEMPORT="/dev/ttyS0"          # TTY device modem is connected to

LINESPEED="115200"              # Speed pppd should try to connect at

INITSTRING=""                   # Extra init string for the modem

DEFROUTE="yes"                  # Must pppd set the default route?

HARDFLOWCTL="yes"               # Use hardware flow control?

ESCAPECHARS="yes"               # Use escape caracters ?

PPPOPTIONS=""                   # Extra options for pppd

USERNAME="impuls"               # The PAP/CHAP username

PASSWORD="infotel"              # Your password/secret.  Ugly I know, but i

NUMBER="0134200"                # The telephone number of your ISP

REMIP=""                        # The ip of the remote box if it should be set

NETMASK=""                      # Netmask

IPADDR=""                       # Our IP if we have a static one

MRU="1536"                      # Sets the MRU

MTU="1536"                      # Sets the MTU

RETRYTIMEOUT="6"                # Retry timeout for when ONDEMAND="yes" or

IDLETIMEOUT="30"                # Idle timeout for when ONDEMAND="yes"

PEERDNS="yes"                   # Should pppd set the peer dns?

AUTOCFGFILES="yes"              # By default this scripts will generate

TEMPLATEDIR=/etc/ppp

```

This handles it all for me, incl. baud rates, chat & authentication, routing, etc.

Cheers,

yassen

----------

## LucaSpiller

Ok I have some free time today so I decided to have a go at getting this working.

Mine is simular to yours but doesn't work.  :Mad: 

```
# /etc/conf.d/net.ppp0:

# $Header: /var/cvsroot/gentoo-x86/net-dialup/ppp/files/2.4.2/confd.ppp0,v 1.2 2004/07/18 03:50:48 dragonheart Exp $

# Config file for /etc/init.d/net.ppp0

PEER="Freeserve"                   # Define peer (aka ISP)

DEBUG="no"                      # Turn on debugging

PERSIST="no"                    # Redial after being dropped

ONDEMAND="no"                   # Only bring the interface up on demand?

MODEMPORT="/dev/ttyS0"          # TTY device modem is connected to

LINESPEED="57600"              # Speed pppd should try to connect at

INITSTRING=""                   # Extra init string for the modem

DEFROUTE="yes"                  # Must pppd set the default route?

HARDFLOWCTL="yes"               # Use hardware flow control?

ESCAPECHARS="yes"               # Use escape caracters ?

PPPOPTIONS=""                   # Extra options for pppd

USERNAME="<my username>"                 # The PAP/CHAP username

PASSWORD="<my pass>"               # Your password/secret.  Ugly I know, but i

                                # will work on something more secure later

                                # on.  700 permission on /etc/init.d/net.ppp0

                                # should be enouth for now.

NUMBER="<my number>"                # The telephone number of your ISP

                                # leave blank for leased-line operation.

REMIP=""                        # The ip of the remote box if it should be set

NETMASK=""                      # Netmask

IPADDR=""                       # Our IP if we have a static one

MRU="1536"                       # Sets the MRU

MTU="1536"                       # Sets the MTU

RETRYTIMEOUT="60"               # Retry timeout for when ONDEMAND="yes" or

                                # PERSIST="yes"

IDLETIMEOUT="600"               # Idle timeout for when ONDEMAND="yes"

PEERDNS="no"                    # Should pppd set the peer dns?

AUTOCFGFILES="yes"              # By default this scripts will generate

                                # /etc/ppp/chat-isp, /etc/ppp/chap-secrets,

                                # /etc/ppp/pap-secrets and /etc/ppp/peers/isp

                                # automatically.  Set to "no" if you experience

                                # problems, or need specialized scripts.  You

                                # will have to create these files by hand then.

AUTOCHATSCRIPT="yes"            # By default this script iwll generate

                                # /etc/ppp/chat-${PEER} automatically. Set to "no"

                                # if you experience problems, or need specialized

                                # scripts. You will have to create these files by

                                # hand then.

# Directory where the templates is stored

TEMPLATEDIR=/etc/ppp
```

```
fe04 root # /etc/init.d/net.ppp0 start

 * Bringing ppp0 up...

SIOCDELRT: No such process                                                [ ok ]
```

And then nothing happens, apart from I get returned to a command prompt - any ideas?

----------

## yassen

How about using the speed option as given in my previous post? Have you tried that and if yes did that solve the speed problem?

----------

