Saturday, August 18, 2012

ppp does not replace default route on ubuntu 12.04

A modem dial up get connected but cannot ping because no ppp in Kernel ip route table.  Bug #608372 ppp does not replace default route when ppp connected should replace the Ethernet route by /etc/ppp/resolv.conf see https://bugs.launchpad.net/ubuntu/+source/ppp/+bug/608372
and https://bugzilla.redhat.com/show_bug.cgi?id=517470
route -n (should have ppp connect but it
> does not have)
> Kernel IP routing table
> Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
> 0.0.0.0         10.xxx.xx.x     0.0.0.0         UG    0      0        0 eth0
> 0.0.0.0         10.yyy.yyy.y    0.0.0.0         UG    100    0        0 eth0
> 10.xxx.xxx.x    0.0.0.0         255.255.255.0   U     0      0        0 eth0
> 10.xxx.xx.x     0.0.0.0         255.255.254.0   U     0      0        0 eth0
> 169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0

                                                                                     need        0 ppp0  
the modem is connected
ppp0      Link encap:Point-to-Point Protocol
          inet addr:25.48.43.139  P-t-P:25.48.43.139  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:378 errors:0 dropped:0 overruns:0 frame:0
          TX packets:381 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:31400 (31.4 KB)  TX bytes:31551 (31.5 KB)


after the fix:
tovantran@Satellite:/etc/ppp$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 ppp0   <-------------------------- correct now
10.xxx.xx.x     0.0.0.0         255.255.254.0   U     0      0        0 eth0
tovantran@Satellite:/etc/ppp$ netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         0.0.0.0         0.0.0.0         U         0 0          0 ppp0
10.xxx.xx.x     0.0.0.0         255.255.254.0   U         0 0          0 eth0
 


http://www.linuxquestions.org/questions/linux-networking-3/pppd-nameserver-etc-resolv-conf-159496/
Which says to edit two files in /etc/ppp called ip-up.local and ip-down.local
I did not have these files, so I created them ( and, incidentally chmod 755 them! )

FYI the files are:

if-up.local

#!/bin/bash
# copied from http://www.ussg.iu.edu/hypermail/lin...02.1/0146.html
if [ -n "$USEPEERDNS" -a -f /etc/ppp/resolv.conf ]; then
rm -f /etc/ppp/resolv.prev
if [ -f /etc/resolv.conf ]; then
cp /etc/resolv.conf /etc/ppp/resolv.prev
grep search /etc/ppp/resolv.prev > /etc/resolv.conf
grep nameserver /etc/ppp/resolv.prev >> /etc/resolv.conf
cat /etc/ppp/resolv.conf >> /etc/resolv.conf
else
cp /etc/ppp/resolv.conf /etc
fi
chmod 644 /etc/resolv.conf
fi
if-down.local
#!/bin/bash
# copied from http://www.ussg.iu.edu/hypermail/lin...02.1/0146.html
if [ -n "$USEPEERDNS" -a -f /etc/ppp/resolv.conf ]; then
if [ -f /etc/ppp/resolv.prev ]; then
cp -f /etc/ppp/resolv.prev /etc/resolv.conf
else
rm -f /etc/resolv.conf
fi
chmod 644 /etc/resolv.conf
fi  

To add route into the table
$ sudo route add default gw 64.71.255.198
IP 64.71.255.198 is DNS recommend because it would not change the local/remote IP will change at each time it gets connected because it is dynamic IP, ISP provides modem IP when connected to their server.
/etc$ cat /var/log/syslog | tail
Aug 20 10:37:08 Satellite pppd[17009]: local  IP address 25.48.xx.xxx
Aug 20 10:37:08 Satellite pppd[17009]: remote IP address 25.48.xx.xxx
Aug 20 10:37:08 Satellite pppd[17009]: primary   DNS address 64.71.xxx.xxx
Aug 20 10:37:08 Satellite pppd[17009]: secondary DNS address 64.71.xxx.xxx
Aug 20 10:40:37 Satellite pppd[17009]: Terminating on signal 15
Aug 20 10:40:37 Satellite pppd[17009]: Connect time 3.5 minutes.
Aug 20 10:40:37 Satellite pppd[17009]: Sent 52600 bytes, received 156140 bytes.
Aug 20 10:40:37 Satellite pppd[17009]: restoring old default route to eth0 [yy.yyy.50.1]
Aug 20 10:40:37 Satellite pppd[17009]: Connection terminated.
Aug 20 10:40:37 Satellite avahi-daemon[784]: Withdrawing workstation service for ppp0.

No comments:

Post a Comment