Wednesday, March 16, 2011

Linux PPPoE Configuration

In this tutorial I'm going to show you how to install and configure PPPoE connection on Linux. First you have to install the required package. You need to be root to do so.

The following procedure does not work on Ubuntu. Depending on your distro enter the following command.


For Fedora
[root@localhost ~]# yum install rp-pppoe
For OpenSuse
[root@localhost ~]# zypper install rp-pppoe

Or you can download the rpm file depending on your distribution & version and install it using the rpm command as follows
[root@localhost ~]# rpm -Uvh

For any other distro you may use the tar.gz file from here. Decompress it and read the README file for installation instructions.

To check if you have PPPoE server in your network enter the following command.
[root@localhost ~]# pppoe-discovery
For me it shows the following output.
Access-Concentrator: Sarder
       Service-Name: smilebd
--------------------------------------------------
AC-Ethernet-Address: 00:50:8b:0c:df:c6

You can also run the following command.
[root@localhost ~]# pppoe-sniff
The output should be like below. Don't worry if it does not show anything.
Sniffing for PADR.  Start your connection on another machine...


Excellent!  Sniffed a likely-looking PADR.
Wonderful!  Sniffed a likely-looking session packet.


Great!  It looks like a standard PPPoE service.
You should not need anything special in the configuration file.


To start configuring your PPPoE connection run the following command.
[root@localhost ~]# pppoe-setup

It will ask for your login name. Type the name that your ISP provide to you. Then hit enter on your keyboard.

LOGIN NAME


Enter your Login Name (default root): rasel@smile.com.bd

Then it will ask for your interface. Type the correct the correct interface. If you are not sure then just hit enter.

INTERFACE


Enter the Ethernet interface connected to the PPPoE modem
For Solaris, this is likely to be something like /dev/hme0.
For Linux, it will be ethX, where 'X' is a number.
(default eth0):

If you want to connect to the internet without interruption after you log in then hit enter or else type 'yes'.

Do you want the link to come up on demand, or stay up continuously?
If you want it to come up on demand, enter the idle time in seconds
after which the link should be dropped.  If you want the link to
stay up permanently, enter 'no' (two letters, lower-case.)
NOTE: Demand-activated links do not interact well with dynamic IP
addresses.  You may have some problems with demand-activated links.
Enter the demand value (default no): 

In most cases the ISP provides DNS addresses after you log on. For that case just type 'server' here.

DNS


Please enter the IP address of your ISP's primary DNS server.
If your ISP claims that 'the server will provide dynamic DNS addresses',
enter 'server' (all lower-case) here.
If you just press enter, I will assume you know what you are
doing and not modify your DNS setup.
Enter the DNS information here: server

Now the settings asks for your login password. Type the password twice here as shown below.

PASSWORD


Please enter your Password: 
Please re-enter your Password: 

The following user control section asks you if you want all users to be able to connect to the internet. If so just hit enter or else type no.

USERCTRL


Please enter 'yes' (three letters, lower-case.) if you want to allow
normal user to start or stop DSL connection (default yes): 

The next firewall section asks you if you want to activate firewall for this connection. Type 0, 1 or 2 as shown below and hit enter. In my case I typed 0.

FIREWALLING


Please choose the firewall rules to use.  Note that these rules are
very basic.  You are strongly encouraged to use a more sophisticated
firewall setup; however, these will provide basic security.  If you
are running any servers on your machine, you must choose 'NONE' and
set up firewalling yourself.  Otherwise, the firewall rules will deny
access to all standard servers like Web, e-mail, ftp, etc.  If you
are using SSH, the rules will block outgoing SSH connections which
allocate a privileged source port.


The firewall choices are:
0 - NONE: This script will not set any firewall rules.  You are responsible
          for ensuring the security of your machine.  You are STRONGLY
          recommended to use some kind of firewall rules.
1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation
2 - MASQUERADE: Appropriate for a machine acting as an Internet gateway
                for a LAN
Choose a type of firewall (0-2): 0

If you want this connection to start every time your computer starts up then type yes and press enter. Otherwise type no.

Start this connection at boot time


Do you want to start this connection at boot time?
Please enter no or yes (default no):

It will show you the summary of your configuration and then asks you if you want to accept to re-configure. If everything is ok then type y and press enter.

** Summary of what you entered **


Ethernet Interface: eth0
User name:          rasel@smile.com.bd
Activate-on-demand: No
DNS addresses:      Supplied by ISP's server
Firewalling:        NONE
User Control:       yes
Accept these settings and adjust configuration files (y/n)? y
Adjusting /etc/sysconfig/network-scripts/ifcfg-ppp0
Adjusting /etc/ppp/chap-secrets and /etc/ppp/pap-secrets
  (But first backing it up to /etc/ppp/chap-secrets.bak)
  (But first backing it up to /etc/ppp/pap-secrets.bak)

At the last part it will show you the command of how to connect to and disconnect from the internet

Congratulations, it should be all set up!


Type '/sbin/ifup ppp0' to bring up your xDSL link and '/sbin/ifdown ppp0'
to bring it down.
Type '/sbin/pppoe-status /etc/sysconfig/network-scripts/ifcfg-ppp0'
to see the link status.

You can use either 'ifup ppp0' or 'pppoe-start' command to connect to the internet.

To check if you are really connected to the internet type the command
[root@localhost ~]# ifconfig

And it will show you a new interface ppp0 along with your regular interfaces (ethX, localhost). This is a virtual interface. All your traffic will pass through the physical interface (NIC) via this interface. When you disconnect from your internet connection ppp0 will be erased.

To disconnect from the internet type either 'ifdown ppp0' or 'pppoe-stop' from the command line.

After connecting to the internet you can type the following command anytime to check the status of your internet connection.
[root@localhost ~]# pppoe-status
pppoe-status: Link is up and running on interface ppp0
17: ppp0: mtu 1492 qdisc pfifo_fast state UNKNOWN qlen 3
    link/ppp 
    inet 113.11.98.245 peer 113.11.98.1/32 scope global ppp0

[root@localhost ~]# pppstats 
      IN   PACK VJCOMP  VJUNC  VJERR  |      OUT   PACK VJCOMP  VJUNC NON-VJ
    1128     10      0      0      0  |      658     10      0      0     10

If you have any problem connecting to the internet check your log file. To do so type the following command as root and look for hints for which the problem arises.

[root@localhost ~]# tail -f /var/log/messages
If you failed to find anything then call your ISP.


Troubleshooting

It may happen sometimes that you may mistakenly start the pppoe service more than once. In this case you may experience internet interruption. In this case when you type ifconfig command from the console you will see more than one pppoe interface (ppp0, ppp1 etc.). Stopping the pppoe service by typing pppoe-stop or ifdown ppp0 will not work. You have to kill the service by typing
[root@localhost ~]# killall pppd
You may have to type the command several times to kill the service. When you see the following output, stop executing the command and start the service again. Check the ppp interface by typing ifconfig. If it does not show ppp0 then you may have to restart your computer.

No comments:

Post a Comment