Pppoe Dial-up Internet access realized by embedded linux
one。 Cross-compiled kernel
In make menuconfig-> Device Drivers-> Network device support-> PPP (point-to-point protocol), select all ppp options. Exit, save the configuration, modify Makefile and re-execute make zImage. Download the zImage under arch/mips/boot/ to the development board to restart the system.
two。 Cross-compile pppoe server
Download ppp-2.4.5.tar.gz and rp-pppoe-3.10.tar.gz in the / opt directory.
Tar-zxvf ppp-2.4.5.tar.gz
Cd ppp-2.4.5
[root@root ppp-2.4.5] #. / configure CC=mipsel-linux-gcc AR=mipsel-linux-ar BANLIB=mipsel-linux-ranlib-host=mipsel
Configuring for Linux
Creating Makefiles.
Makefile Please enter your PPPoE password:-- enter Netcom user password
> > Choose a type of firewall (0-2):-- enter 0 (0 means no firewall)
> > Accept these settings and adjust configuration files (YBO)?-- input y
After performing the pppoe-start. If you use pppoe-start to start the connection at this time, in most cases you will get a prompt from timeout, so what should we do? You need to create a pts folder under the dev directory, go to pts, and create nodes mknod 0 c 1360; mknod 1 c 136 1. Each link needs to be set up, which is troublesome, so write these instructions into the startup script. Believe that in this case, you will usually get a connected! The prompt indicates that ADSL has dialed successfully. You can see through baidu under ping.
five。 Modify script
To facilitate the use of pppoe-setup, write a script pppoe.sh to pass parameters and write parameters to the specified file, for example:
[root@root scripts] #. / pppoe.sh pppoe-name eth3 pppoe-passwd
#! / bin/sh
U = "$1"
E = "$2"
PWD1= "$3"
PPPD= "/ usr/sbin/pppd"
CONFIG= "/ etc/ppp/pppoe.conf"
If [!-r "$CONFIG"]; then
Echo "Oh, dear, I don't see the file'$CONFIG' anywhere. Please"
Echo "re-install the PPPoE client."
Exit 1
Fi
# Must have pppd
If [!-x $PPPD]; then
Echo "Oops, I can't execute the program'$PPPD'. You"
Echo "must install the PPP software suite, version 2.3.10 or later."
Exit 1
Fi
Sed-I "s/USER=.*/USER=$U/" $CONFIG
Sed-I "s/ETH=.*/ETH=$E/" $CONFIG
Sed-I "s/FIREWALL=.*/FIREWALL=NONE/" $CONFIG
Sed-I "s/DNSTYPE=.*/DNSTYPE=SERVER/" $CONFIG
Sed-I "s/PIDFILE=.*/PIDFILE=/var/run/pppoe-$E.pid/" $CONFIG
Sed-I "s/DEMAND=.*/DEMAND=no/" $CONFIG
Sed-I "splash DNS1marker. Hammer DNS1 ="/" $CONFIG
Sed-I "splash DNS2 CONFIG. Hammer DNS2 ="/" $DNS2
Sed-I "s/PEERDNS=.*/PEERDNS=yes/" $CONFIG
Cp $CONFIG $CONFIG-bak
If [- r / etc/ppp/pap-secrets]; then
Cp / etc/ppp/pap-secrets / etc/ppp/pap-secrets-bak
Else
Cp / dev/null / etc/ppp/pap-secrets-bak
Fi
If [- r / etc/ppp/chap-secrets]; then
Cp / etc/ppp/chap-secrets / etc/ppp/chap-secrets-bak
Else
Cp / dev/null / etc/ppp/chap-secrets-bak
Fi
Egrep-v "^ $U | ^\" $U\ "/ etc/ppp/pap-secrets-bak > / etc/ppp/pap-secrets
Echo "\" $U\ "*\" $PWD1\ "> > / etc/ppp/pap-secrets
Egrep-v "^ $U | ^\" $U\ "/ etc/ppp/chap-secrets-bak > / etc/ppp/chap-secrets
Echo "\" $U\ "*\" $PWD1\ "> > / etc/ppp/chap-secrets
[root@root scripts] # / usr/sbin/pppoe-connect / etc/ppp/pppoe.conf
Using interface ppp0
Connect: ppp0 / dev/pts/13
Warning-secret file / etc/ppp/chap-secrets has world and/or group access
CHAP authentication succeeded: Access granted
CHAP authentication succeeded
Local IP address 192.168.2.2
Remote IP address 192.168.2.1
Primary DNS address 8.8.8.8
Secondary DNS address 4.4.4.4
[root@root scripts] # / usr/sbin/pppoe-status
Pppoe-status: Link is up and running on interface ppp0
Ppp0 Link encap:Point-to-Point Protocol
Inet addr:192.168.2.2 P-t-P:192.168.2.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
Collisions:0 txqueuelen:3
RX bytes:61 (61.0B) TX bytes:1447 (1.4 KiB)
[root@root scripts] # route-n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 ppp0