VSNL Connection HOWTO
=====================

Following these instructions should let you get connected to your VSNL
TCP/IP account. 

Tested in Patna with Redhat 5.2 and 6.1. Some of these steps
will work on RedHat Linux only (Step 3 , for ex). The methods in
the Appendix may work on other distros. 

Please read the following HOWTO carefully and modify the lines where
needed. Be careful when working as root. Take care to make backup copies
of any file before editing/changing it , so you can at least restore it
back to the previous state in case something does not work.

There are many approaches to connect your machine to the net using
ppp. You can use Xisp (from X windows) or kppp (if you are using KDE)
and so on , but using this method , you never need to use X at all.
Also , you can invoke and shutdown your ppp from a cron or shell
script if you need that.

You can use the info in this howto to similarly configure kppp
or dip or xisp or whatever. Some of the steps are indeed unchanged.
The appendix has some info how to do this.

The LINESPEED used to connect to the modem has been assumed to
be 115200 bps. If your system is older ,you may need to use a 
slower speed such as 38400 or 19200.

============================================================================
1) Login as root.
2) Use modemtool to set /dev/modem to the right port for your modem.
   If your modem gives you a NO-DIALTONE error , you will  need to set 
   ATX1 on your modem using minicom and write this using AT&W.
3) Edit the /etc/resolv.conf file to have the following information.
   Set the nameserver entries as needed (get the info from the local 
   vsnl/dot office).  The examples given should work for most cases.

/etc/resolv.conf
----------------
search vsnl.net.in 
nameserver 202.54.30.1
nameserver 202.54.1.30

4) Edit the following files to have the lines as below. 
   Be sure to make these modifications  as per your requirements.
   a) In chat-ppp0 , make sure you use the actual username and passwd 
   instead of the dummy xyz and secret used. 
   b) Set tel number as needed (172222 in this ex).
   c) If your telephone exchange does not support tone dialling (also called
   DTMF or fast dialling), in the chat-ppp0 file , you can change 
   ATDT to ATDP.
   d) If you have an older machine, it may not support a speed of 115.2 kbps.
   In that case , you will have to change the LINESPEED line to be 19200
   or whatever works on your machine.
   e) In certain VSNL/DOT setups, it is not needed to have the lines
           '>' 'ppp'
           'TIMEOUT' '5'
   in the chat-ppp0 file. Some places require a space between 
   'name' or 'ord' and the following  ':'
   You will need to dial up from minicom and check what are needed
   and tailor the following files accordingly. THIS IS VERY IMPORTANT
   as the chat script will fail if you do not have the right 
   'expect' and 'send' sequences.

   Here are the files.

/etc/sysconfig/network-scripts/chat-ppp0
----------------------------------------
'ABORT' 'BUSY'
'ABORT' 'ERROR'
'ABORT' 'NO CARRIER'
'ABORT' 'NO DIALTONE'
'ABORT' 'Invalid Login'
'ABORT' 'Login incorrect'
'' 'ATZ'
'OK' 'ATDT172222'
'CONNECT' ''
'name:' 'xyz@dummy.vsnl.net.in'
'ord:' 'secret'
'>' 'ppp'
'TIMEOUT' '5'

/etc/sysconfig/network-scripts/ifcfg-ppp0
-----------------------------------------
PERSIST=yes
DEFROUTE=yes
ONBOOT=no
INITSTRING=ATZ
MODEMPORT=/dev/modem
LINESPEED=115200
ESCAPECHARS=no
DEFABORT=yes
HARDFLOWCTL=yes
DEVICE=ppp0
PPPOPTIONS=
DEBUG=no
PAPNAME=
REMIP=
IPADDR=
BOOTPROTO=none
MTU=
MRU=
DISCONNECTTIMEOUT=
RETRYTIMEOUT=10
USERCTL=yes

Now set the modes for the files using the commands

   chmod 0600 /etc/sysconfig/network-scripts/chat-ppp0
   chmod 0644 /etc/sysconfig/network-scripts/ifcfg-ppp0
   
You can start ppp by running
       /usr/sbin/usernetctl ppp0 up
and stop it with
       /usr/sbin/usernetctl ppp0 down

If you are still unable to get connected , in the network menu in the
Redhat control panel , check 'debug connection' for the ppp0 interface
and try to connect again. You should see error messages in /var/log/messages.
After rectifying the cause and testing it out , uncheck 'debug connection'.

One usual reason that the modem lights flicker a bit and then nothing
happens is if your modem is unable to recognise the dial tone.
As mentioned in step 1 , you will need to set ATX1 in this case.

Instead of using the commands above, you can also activate the ppp 
interface from RedHat's control panel by clicking on the activate button.
Or by selecting Start->Programs->Networking->Usernet

5) For outbound mail , you will need to setup Sendmail which is more 
complex. But this should work for most people.
It is always better to save your current sendmail config file with the
following command  

     cp /etc/sendmail.cf /etc/sendmail.cf.org

Then edit the /etc/sendmail.cf file (with vi , perhaps) and look for
lines whose first few characters are the same as the lines below and
replace them with the following lines.

DS dummy.vsnl.net.in
DM dummy.vsnl.net.in
O HoldExpensive=True
O Timeout.queuewarn=2d
Msmtp,                P=[IPC], F=mDFMuXe, S=11/31, R=21, E=\r\n, L=990,
Mesmtp,               P=[IPC], F=mDFMuXae, S=11/31, R=21, E=\r\n, L=990,
Msmtp8,               P=[IPC], F=mDFMuX8e, S=11/31, R=21, E=\r\n, L=990.
Mrelay,               P=[IPC], F=mDFMuXa8e, S=11/31, R=61, E=\r\n, L=2040,

Now any mails sent from your machine will be queued on your machine.
You can send mails even when the ppp connection is not on. When you
are connected , you can send all the queued mails using the command
'/usr/sbin/sendmail -q'
In netscape , set the SMTP host (for outbound mail) to localhost so even
mails sent from netscape will be queued.

6) To fetch incoming mail , in your home directory , create a file 
called .fetchmailrc and add the following to it

set daemon 300
poll dummy.vsnl.net.in proto pop3 user xyz pass yourpasswd

Use the relevant vsnl host instead of the dummy used above as
well as your username and password..
Save it and run 'chmod 0400 .fetchmailrc'
When you are connected, you can run the command 'fetchmail' 
which will use the POP3 protocol to fetch all the mail from
your vsnl host to your account on your machine. It will poll for new
mail every 300 secs (5 mins) for new mail. You can then use
any standard email program such as pine, elm or netscape to view your mail.


7) To automate the process of fetching and sending mail immediately
upon getting connected , create the following file

/etc/ppp/ip-up.local
--------------------
#!/bin/bash

fetchmail&
/usr/sbin/sendmail -q &
wait

Make sure you make this file owned by root and give it execute
permissions using 'chmod +x /etc/ppp/ip-up.local'

You will , of course, need to have a .fetchmailrc in the root's 
home directory (as in step 8) , which contains

poll dummy.vsnl.net.in proto pop3 user xyz pass yourpasswd is user xyz here


=============================================================================
Appendix
========
For your convenience , here are alternate ways of achieving Step 3 
above (to connect to vsnl). Other steps remain the same.

Using DIP
=========

> From: "Y.V.Deval" 

> Attached please find a script that dials and gets you on the air.
>
> If you use dip in test mode (-t) you can get the name of the host
> computer of your ISP for the particular number that you are dialing.
> Even help desk should be able to give the information.
>
> Independent script will be required for each number of vsnl. I have
> named them vsnl1.dip through vsnl5.dip and put all of them in /etc/ppp.
>
> Just change to /etc/ppp and issue command /sbin/dip (name of your
> script); and you are on air without any further typing.
>
> Vijay

/etc/ppp/vsnl.dip
-----------------

main:
  port cua1
  speed 115200

  get $rmtip nnn.nnn.nnn.nnn    #number of your ISP provider
  
  print DIP script for HOSTNAME  server by Vincent Chen 08/12/1994
  print Modified by Y.V.Deval to suit vsnl protocol.
  print -------------------------------------------------------
  print .............. AutoDial procedure started .............
  print ................ Press Ctrl-C to abort ................

dialsvr:
  send +++\r
  wait OK 3
  send ATH0\r
  wait OK 3
  print ................... Trying 758401 ...................
  send ATDT758401\r
  if $errlvl != 0 goto error
  wait BUSY 7
  if $errlvl == 0 goto next
  wait CONNECT 25
  if $errlvl != 0 goto next
  goto login

next:
  send +++\r
  wait OK 3
  send ATH0\r
  wait OK 3
  print ................... Trying (TEL.NO.OF YOUR ISP) .......
  send ATDT758401\r
  if $errlvl != 0 goto error
  wait BUSY 3
  if $errlvl == 0 goto dialsvr
  wait CONNECT 25 
  if $errlvl != 0 goto dialsvr
  goto login

login:
wait Username 3
send YOUR_USERNAME\r
wait Password 3
send YOUR_PASSWORD\r
wait HOSTNAME OF YOUR ISP> 3
send ppp\r
  # Catch the key word to confirm that IP string will show up shortly.
  # Here we're waiting for a string: "Your IP address is"
  wait Your\sIP\saddress\sis 9 
  if $errlvl != 0 goto error1
  #
  # Get our dynamic IP from strings that sent by server
  #
  get $locip remote 5
#  get $remote remote 5 
  wait Username 3
  send YOUR_USERNAME\r
  wait Password 3
  send YOUR_PASSWORD\r

done:
  default
  parity n
  databits 8
  print Entering PPP mode.
  print Dynamic IP assigned by host is $locip
#  print Remote host connected is $remote
mode PPP
shell /etc/ppp/start.dip
# shell pine  #this did bring up pine.
#shell ping 202.54.1.30
 # goto exit2

error1:
  print PPP1 connection failed.
  goto exit

modemerr:
  print Modem initializing failed.
  goto exit

error:
        print ppp connection failed
        goto exit

exit:
        exit


Using kppp (KDE's PPP program)
==============================

This is as simple as it gets! Assuming you have kde already installed
and running , simply create the following file with the info below
and change the mode to 0600 (chmod 0600 ~/.kde/share/config/kppprc),
fire up kppp and click on the Connect button. 
Check that the /etc/ppp/options file is empty (should definitely not contain
the lock option in it).
Be sure to use the correct user name and host instead of xyz and dummy
respectively in this example. And the phone number , of course.
Tested with KDE 1.1
If note (e) from Step 4 above applies to you , you will need
to subsitute the following two lines instead of the ones in
the example.
       ScriptArguments=name :,,ord :,,~,
       ScriptCommands=Expect,ID,Expect,Password,Expect,


~/.kde/share/config/kppprc
--------------------------
# KDE Config File
[Account0]
TotalBytes=0
ExDNSDisabled=0
AutoName=0
ScriptArguments=name:,,ord:,,>,ppp,~,
AccountingEnabled=0
Phonenumber=172222
IPAddr=0.0.0.0
TotalCosts=
Domai