So far we have installed Linux CentOS on a computer, created an access point for wireless users connection and configured Open vSwitch to connect wired LAN users. Now it is time to step forward and connect our Linux L3 switch to the Internet. To do this, we have to install and configure PPPoE.
PPPoE stands for Point-to-Point over Ethernet and it is a Layer2 network protocol that encapsulates PPP frames inside Ethernet frames. Our Linux L3 switch (router) represents PPPoE client and submits login credentials to PPPoE server. PPPoE server is located on ISP network and provides authentication service to the client.
1. Bring routed interface Ethernet3 to up state at boot time
We will use D-Link DGE-528T Gigabit Ethernet Adapter - that is presented as interface Ethernet 3 for WAN connection. Interface must be brought up at the boot time thus we have to change a parameter ONBOOT="no" to ONBOOT="yes" in /etc/sysconfig/network-scripts/ifcfg-eth3 configuration.
[root@swouter-x86 ~]# sed -i 's/ONBOOT="no"/ONBOOT="yes"/g' /etc/sysconfig/network-scripts/ifcfg-eth3
2. Load pppoe module to kernel
[root@swouter-x86 ~]# modprobe pppoe
In case of a pppoe module cannot be loaded to kernel check this link for reference, please.
3. Install ppp and configure login credentials
[root@swouter-x86 ~]# yum install ppp.i686
Login credentials are stored in a file /etc/ppp/chap-secrets. If we use pppd for more than one connection, it is necessary to introduce an unique ID along with login and password. The example below adds user brezular with his ID my_ID and password my_password to the file /etc/ppp/chap-secrets.
[root@swouter-x86 ~]# echo "brezular my_ID my_password" >> /etc/ppp/chap-secrets
4. Create configuration file my_ISP in /etc/ppp/peers/ directory
[root@swouter-x86 ~]# vi /etc/ppp/peers/my_ISP
plugin rp-pppoe.so
# Network interface via which we receive pppoe
eth3
# Username - same as in /etc/ppp/chap-secret
user brezular
# Use IP address from ISP provider
noipdefault
#Use provider's DNS server
usepeerdns
chmod 755 /etc/ppp/ip-up.local
#Fixed connection
persist
# The provider’s router will be used as a gateway
defaultroute
#Unique ID from chap-secrets
remotename my_ID
5. Start pppd
[root@swouter-x86 ~]# /usr/sbin/pppd call my_ISP
Dispaly content of the file /var/log/messages to look for log messages.
[root@swouter-x86 ~]# tail -n 14 /var/log/messages
Aug 23 01:08:38 swouter-x86 pppd[2148]: Plugin rp-pppoe.so loaded.
Aug 23 01:08:38 swouter-x86 pppd[2148]: RP-PPPoE plugin version 3.8p compiled against pppd 5
Aug 23 01:08:38 swouter-x86 pppd[2149]: pppd 2.4.5 started by root, uid 0
Aug 23 01:08:38 swouter-x86 pppd[2149]: PPP session is 12411
Aug 23 01:08:38 swouter-x86 pppd[2149]: Connected to 00:90:1a:42:14:05 via interface eth3
Aug 23 01:08:38 swouter-x86 pppd[2149]: Using interface ppp0
Aug 23 01:08:38 swouter-x86 pppd[2149]: Connect: ppp0 <--> eth3
Aug 23 01:08:38 swouter-x86 pppd[2149]: CHAP authentication succeeded: CHAP authentication 9
Aug 23 01:08:38 swouter-x86 pppd[2149]: CHAP authentication succeeded
Aug 23 01:08:38 swouter-x86 pppd[2149]: peer from calling number 00:90:1A:42:14:05 authorizd
Aug 23 01:08:38 swouter-x86 pppd[2149]: local IP address 91.127.65.93
Aug 23 01:08:38 swouter-x86 pppd[2149]: remote IP address 213.81.232.247
Aug 23 01:08:38 swouter-x86 pppd[2149]: primary DNS address 195.146.132.58
Aug 23 01:08:38 swouter-x86 pppd[2149]: secondary DNS address 195.146.128.62
Unique ID of PPP session is 12411 and peer's destination address is 00:90:1a:42:14:05 . IP address of ppp0 interface is 91.127.65.93 and IP address of PPPoE access concentrator is 213.81.232.247. CHAP authentication is successful. IP address of both primary and secondary DNS server will be stored in /var/run/ppp/resolv.conf.
6. DNS configuration - updating /etc/resolv.conf
Problem:
File /etc/resolv.conf is not updated when pppd is started. This can be solved by adding copy command to /etc/ppp/ip-up.local. The command copies a list of nameservers from /var/run/ppp/resolv.conf to /etc/resolv.conf. The script ip-up.local is called by ip-up script.
[root@swouter-x86 ~]# echo "cp /var/run/ppp/resolv.conf /etc/resolv.conf" > /etc/ppp/ip-up.local
[root@swouter-x86 ppp]# chmod 755 /etc/ppp/ip-up.local
7. Create init script to make pppd daemon to be started at boot time
[root@swouter-x86 ~]# vi /etc/init.d/pppd
#!/bin/sh
#
# start/stop the pppd
#
# chkconfig: 2345 11 86
# description: pppd daemon
# processname: pppd
# config: /etc/ppp/peers/my_ISP
# pidfile: /var/run/ppp0.pid
#
PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin
export PATH
# Source function library.
. /etc/rc.d/init.d/functions
stop()
{
echo -n "Stopping pppd daemon: "
killproc pppd
echo
rm -f /var/lock/subsys/pppd
}
start()
{
echo -n "Starting pppd daemon: "
daemon /usr/sbin/pppd call my_ISP
echo
touch /var/lock/subsys/
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status pppd
;;
restart)
stop
start
;;
*)
echo "Usage: pppd {start|stop|status|restart}"
exit 1
esac
exit 0
[root@swouter-x86 ~]# chmod 755 /etc/init.d/pppd
[root@swouter-x86 ~]# chkconfig --add pppd
END.
This is the list of articles I had used during writing the tutorial.
http://www.lampdocs.com/home-personal/pppoe-connection/
https://wiki.archlinux.org/index.php/PPPoE_Setup_with_pppd
http://www.brennan.id.au/05-Broadband_Connectivity.html
https://bugzilla.redhat.com/show_bug.cgi?id=517470