Difference between revisions of "PPPoE"

From Ilianko
Line 85: Line 85:
 
</pre></code>
 
</pre></code>
  
 +
 +
 +
Включване рутиране. Активира се препращане на пакети. В /etc/sysctl.conf разкоментирайте реда.
 +
net.ipv4.ip_forward=1
 +
После изпълнете:
 +
sysctl -p
  
  
Line 91: Line 97:
  
 
<code><pre>
 
<code><pre>
 
 
#!/bin/bash
 
#!/bin/bash
# Starts the PPPoE server and turns on NAT
 
 
 
PROV=pppoe
 
 
#maximum number of addresses your server
 
#MAX=5
 
 
#lowest IP address your server is allowed
 
 
BASE=10.10.220.2
 
PLA=10.10.220.0/8
 
  
# NAT is the set of addresses which your server will
+
PROTOCOL=pppoe
# NAT behind it. Other addresses behind your server
+
MY_IP=10.10.10.1
NAT=10.10.220.0/8
 
MYIP=10.10.220.1
 
  
##########################################
+
#DHCP
# Here is where the script actually starts executing.
+
MAX_USERS=5
##########################################
+
NETWORK=10.10.10.0/24
 +
FIRST_ADDRESS=10.10.10.2
  
# Disable IP spoofing on the external interface.
+
#firewall
iptables -A INPUT -i eth0 -s $NAT -j DROP
 
  
#Enable NAT for the private addresses we hand out.
+
#iptables -A INPUT -i eth0 $NAT -j DROP
iptables -t nat -A POSTROUTING -s $NAT -j $NAT --to-source $MYIP
 
  
# Launch the server.
+
#NAT
pppoe-server pty -T 60 -I eth1 -L $MYIP -N $MAX -C $PROV -S $PROV -R $PLA
+
iptables -t nat -A POSTROUTING  -o eth0 -j MASQUERADE
  
echo "1" > "/proc/sys/net/ipv4/ip_forward"
+
pppoe-server pty -T 60 -I eth1 -L $MY_IP -N $MAX_USERS -C $PROTOCOL -S $PROTOCOL -R $NETWORK
 
</pre></code>
 
</pre></code>
  

Revision as of 17:37, 15 July 2013

PPPoE Server Setup: Operating System: Ubuntu Desktop(8.04)

Installation of Softwares

Server Side

Необходими пакети

  • Компилатор
apt-get install build-essential
  • ppp
apt-get install ppp
  • pppoe
apt-get install pppoe
wget http://www.roaringpenguin.com/files/download/rp-pppoe-3.11.tar.gz
tar -xf rp-pppoe-3.11.tar.gz
cd rp-pppoe-3.11
./go

go e бърз скрипт за конфигуриране. Въведете исканата информация. В края трябва да види:

  • "Congratulations, it should be all set up!"

Настройки

Разгледайте директория /etc/ppp

cd /etc/ppp
ls 
chap-secrets              ip-down.d    options          pppoe.conf-bak
chap-secrets-bak          ip-up        pap-secrets      pppoe_on_boot
firewall-masq             ip-up.d      pap-secrets-bak  pppoe-server-options
firewall-masq-3.10        ipv6-down    peers            pppoe-server-options-example
firewall-standalone       ipv6-down.d  plugins          pppoe-up
firewall-standalone-3.10  ipv6-up      pppoe.conf       resolv
ip-down                   ipv6-up.d    pppoe.conf-3.10

Файловете, които най много ни интересеуват са:

  • pppoe-server-options,
  • pppoe.conf,
  • options,
  • pap-secrets,
  • chap-secrets.

[PAP] e метода за удостоверяване по подразбиране, който ще остане. Ще се използват потребителите на операционната система.

Редактирайте файла pap-secrets:

nano pap-secrets
#
# /etc/ppp/pap-secrets
#

# INBOUND connections

# Every regular user can use PPP and has to use passwords from /etc/passwd
*       hostname        ""      *

# UserIDs that cannot use PPP at all. Check your /etc/passwd and add any
# other accounts that should not be able to use pppd!
guest   hostname        "*"     -
master  hostname        "*"     -
root    hostname        "*"     -
support hostname        "*"     -
stats   hostname        "*"     -
# OUTBOUND connections

# Here you should add your userid password to connect to your providers via
# PAP. The * means that the password is to be used for ANY host you connect
# to. Thus you do not have to worry about the foreign machine name. Just
# replace password with your password.
# If you have different providers with different passwords then you better
# remove the following line.
#       *       password

"test"  *       "test"


Включване рутиране. Активира се препращане на пакети. В /etc/sysctl.conf разкоментирайте реда.

net.ipv4.ip_forward=1

После изпълнете:

sysctl -p


Стартиране

скрипт за стартиране DHCP

#!/bin/bash

PROTOCOL=pppoe
MY_IP=10.10.10.1

#DHCP
MAX_USERS=5
NETWORK=10.10.10.0/24 
FIRST_ADDRESS=10.10.10.2

#firewall

#iptables -A INPUT -i eth0 $NAT -j DROP

#NAT
iptables -t nat -A POSTROUTING  -o eth0 -j MASQUERADE

pppoe-server pty -T 60 -I eth1 -L $MY_IP -N $MAX_USERS -C $PROTOCOL -S $PROTOCOL -R $NETWORK


За да стартирате сървъра изпълнете:

pppoe-start

За да го спрете"

pppoe-stop 

За да видите състоянието:

pppoe-status