Tuesday, March 20, 2012

Installing PPPOE client in Linux

This is a HOW-TO for installing PPPOE client in linux.

First of all, some description about what is PPPOE (Point to Point Protocol Over Ethernet).
Well PPPOE is used to connect to a network with a username and password, and then receive from the network PPPOE server the connection settings. In all cases this is done by creating a virtual adapter with the new setting.

If in Windows this appears as a new connection in linux appears as a new NIC (Network Interface Card) connection, most of the times with the name pppX, where X is the number of the adapter (ppp0, ppp1, ppp2 .....).

This actually allows you to use more that one username and password and more that one PPPOE server, although this is a rare encounter.

The main use for this type of adapter is in router installations, where you want your linux to act as a network router and/or firewall, but you can also use this for desktop installations where the ISP (Internet Service Provider) forces a PPPOE server as login.

Now let's continue with the business part of the tutorial, how to install the PPPOE client, how to configure it and how to use it.

For installation and configuration I suggest to use "root" account if you don't want to setup a "special" permision account. Here I'm using "pppoe" user for traking purposes in linux utilities (top, ps).

I use a CentOS 6.2 (x64 bit) installation, but this should apply to any Red-Hat spin. Also tested on the CentOS 5.7 Final (x32 bit) and worked like a charm. I will not output the entire process as you only need to hit "Y" at one time.


[pppoe@linux ppp]# yum install ppp rp-pppoe
*

*
*
*
*
Installed: rp-pppoe.x86_64 0:3.10-8.el6                                                                                                                                                                   

Dependency Installed: ppp.x86_64 0:2.4.5-5.el6

Complete!
[
pppoe@linux ppp]#

 

So if everything went just as well on your part this should be the final result that you would see. Bear in mind that in some cases you could see additional packages installed for dependencies, so the total number of bytes and transactions can differ.

Also as you can see here the installation is done from an outside (internet) mirror, so I do have a connection established. In the case that you don't already have a connection established, you may want to install this from the DVD.

Now that everything is in place let's configure the service.

[pppoe@linux ~]# cd /etc/ppp/
[pppoe@linux ppp]# ls -la
total 44
-rw-------. 1 root root   78 Aug 23  2010 chap-secrets
-rwxr-xr-x. 1 root root  386 Oct  7 17:01 ip-down
-rwxr-xr-x. 1 root root 3262 Oct  7 17:01 ip-down.ipv6to4
-rwxr-xr-x. 1 root root  430 Oct  7 17:01 ip-up
-rwxr-xr-x. 1 root root 6517 Oct  7 17:01 ip-up.ipv6to4
-rwxr-xr-x. 1 root root 1687 Oct  7 17:01 ipv6-down
-rwxr-xr-x. 1 root root 3196 Oct  7 17:01 ipv6-up
-rw-r--r--. 1 root root    5 Aug 23  2010 options
-rw-------. 1 root root   77 Aug 23  2010 pap-secrets
drwxr-xr-x. 2 root root 4096 Mar  7 10:35 peers


Now as you can see above there are two secrets files present in this directory. 
The chap-secrets which looks like this:

[pppoe@linux ppp]# cat chap-secrets
# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
[
pppoe@linux ppp]#  

and the pap-secrets which looks like this:

[pppoe@linux ppp]# cat pap-secrets
# Secrets for authentication using PAP
# client        server  secret                  IP addresses
[
pppoe@linux ppp]# 

Besides the difference in protocols (CHAP and PAP) the files are the same.
Configuring them is about adding a simple line in vi or nano or whatever editor you like.

[pppoe@linux ppp]# cat chap-secrets
# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
 
"Username"    *       "Password"
[pppoe@linux ppp]#  

[pppoe@linux ppp]# cat pap-secrets
# Secrets for authentication using PAP
# client        server  secret                  IP addresses
"Username"    *       "Password"
[pppoe@linux ppp]#  

After this you only need to start the client and connect to the provider. In general the client is able to discover the ip address of the ISP where the PPPOE Server resides, and connect with it.

[pppoe@linux ppp]# adsl-start

After starting the client there are two ways in testing if the connection has been done (of course if no other errors or messages have been received).

[pppoe@linux ppp]# adsl-status
adsl-status: Link is up and running on interface ppp0
5: ppp0: mtu 1492 qdisc pfifo_fast qlen 3
    link/ppp
    inet xxx.xxx.xxx.xxx peer xxx.xxx.xxx.xxx/32 scope global ppp0

The xxx.xxx.xxx.xxx represent two ip addresses, the first one for you adapter and the second one for the server. The /32 at the end of the second one is the network mask.

Another way is to issue the ifconfig command:

[pppoe@linux ppp]# ifconfig
ppp0      Link encap:Point-to-Point Protocol 
          inet addr:xxx.xxx.xxx.xxx  P-t-P:xxx.xxx.xxx.xxx  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:219440 errors:0 dropped:0 overruns:0 frame:0
          TX packets:205248 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:130989809 (124.9 MiB)  TX bytes:29667884 (28.2 MiB)

As in the above example the xxx.xxx.xxx.xxx contain the two ip's.
For restarting the PPPOE client you just need to issue adsl-stop and then adsl-start again.

If youre logedin the console or you use a shell (terminal):

[pppoe@linux ppp]# adsl-stop 
[pppoe@linux ppp]# adsl-start

OR (especially you are remote ssh on the same pppX interface)

[pppoe@linux ppp]# adsl-stop; adsl-start 


And voila. Hope this tutorial helps you.

No comments:

Post a Comment