Defcon1-Header
Tool-BarfreeBSD ArticlesSearch Our SiteHOMEfreeBSD LinksContribute to FreeBSD HelpFreeBSD FilesFreeBSD Script Corner

How to install Bezeq's ADSL on your BSD box

Written by Jacob Shapiro
Any corrections/suggestions are welcome.

Step 1 - Connectivity
-------------------------------------------------------------------
The system works like this:
You have an ADSL modem which is connected to your computer via an ethernet card.
You have to be able to connect to you modem from your computer, prior to actually
setting up the dialing.
How do you configure this?
The IP of the modem will always be 10.0.0.138
The IP of the ethernet interface on your computer should be set to 10.200.1.1,
and the netmask would be 255.0.0.0
Supposingly your newly installed NIC is called dc0, you would configure it by doing
so:
# /sbin/ifconfig dc0 10.200.1.1 netmask 255.0.0.0
And then you will try to ping the modem from your computer to see there is connectivity.
You do so by executing the following command:
# ping 10.0.0.138
if ping works, then everything is set to start up setting the actual dialing.
---
NOTE: You probably want to permenantly set the settings for your NIC interface, so that
you don't have to set it up every time you boot up.
You would do this by editing the /etc/rc.conf file.
Again, supposingly your interface name is dc0, this is the line you add to the bottom of
the file:
ifconfig_dc0="inet 10.200.1.1 netmask 255.0.0.0 mtu 1498"
---


Step 2 - Installing PPTP and PPPD
----------------------------------------------------------------------
The next step, after we are sure we can "talk" with the modem, is to install the appropriate
software that will utilitize the dialing process.
We need two programs: PPTP and PPPD. As far as I know, PPPD should already come with your box,
but if it's not installed, try installing it from the ports or something.
After we know we have PPPD installed, we install the next program, PPTP.
This program doesn't come with FreeBSD out of the box (as far as I know), so we will install
it from the ports.
# cd /usr/ports/net/pptpclient; make;
Now, the problem is, in the ports, they use the userland-ppp for pptp instead of pppd.
It is possible (and maybe even better?) to use userland-ppp, but I've had some problems with it,
(perhaps mis-configuration). Anyhows, I'll guide you how to use pppd.
After the port has done compiling, we'll need to modify it's Makefile so it uses pppd instead of
userland-ppp.
# cd work/pptp-linux-1.0.3/
Now we need to edit the Makefile. Use your favorite editor.
# vim Makefile
In this file, we change the line:
CFLAGS += '-DPPPD_BINARY="/usr/sbin/ppp"' -DUSER_PPP
Into:
CFLAGS += '-DPPPD_BINARY="/usr/sbin/pppd"'
if it's already that way, then fine.
Then we do need to recompile:
# make clean; make;
And then we want to install the port:
# cd ../../; make install;
pptp should now be installed! If it isn't, it's probably my fault for not explaining correctly, but
try to get help on IRC or something.




Step 3 - Configuration
-----------------------------------------------------------------------
The configuration is done mostly for the pppd program, to know where to connect to, and with what
Username and password.
The configuration files directory is /etc/ppp:
# cd /etc/ppp;
Now we have two files that are relevant: pap-secrets and options
Put the following line in the /etc/ppp/pap-secrets file:
"<USERNAME>@I<ISP_NAME>" "10.0.0.138 RELAY_PPP1" "<PASSWORD>"
Now, when you fill in the values, be sure to include the quotes, but not the sharp parenthesis.
That is, if my username is jacob and my ISP is BestISP and my password is sex, the line would look like:
"jacob@IBestISP" "10.0.0.138 RELAY_PPP1" "sex"
Now that the pap-secrets file is ready, we edit the options file.
Put the following in /etc/ppp/options file:
name "<USERNAME>@I<ISP_NAME>"
noauth
noipdefault
defaultroute
debug
nopersist
Again, you do need to include quotes, but not sharp parenthesis. Just like in the pap-secrets file.
You might wanna tune some parameters for this file, look in 'man pppd' for more options, these are
the best that fit me.




Step 4 - RC.D Scripts
-------------------------------------------------------------------------
We create some startup scripts for dialing and shutting down a connection so that we don't have to type
the full password everytime we want to execute one of these actions.
You can put these files wherever you want to (I suggest within a directoy that is in $PATH).
Now, I chose /sbin, and so I called my dialing file adsl-up. I put the following lines in the /sbin/adsl-up file:
#!/bin/sh
killall -9 pptp           # This kills all previous connections
killall -9 pppd           # This too
/sbin/ifconfig ppp0 down      # This makes sure the ppp0 interface is down
rm -rf /var/run/pptp        # We make sure pptp doesn't think it's already running
route delete default        # Delete the default route, if it already exists
/sbin/pptp 10.0.0.138 99999999 &  # Dial (If that's not where your pptp executable is, just
  #    change it to the correct path)
When ever you want to connect, Just execute this file (Make sure it's set +x, by doing chmod +x /sbin/adsl-up)
We also want to create a shut down script, we call it adsl-down, and put it in /sbin.
Put the following lines in the /sbin/adsl-down file:
#!/bin/sh
  # Just read the comments for the adsl-up file.
killall pppd
killall pptp
/sbin/ifconfig ppp0 down
rm -rf /var/run/pptp
Okay, we are pretty much all done by now.
You might wanna call these scripts from your /usr/local/etc/rc.d/ scripts or /etc/rc.local, or whatever.
Just make sure they are executed on startup, that is, if you want to dail as soon as you boot up.




Step 5 - Incase we get disconnected
-------------------------------------------------------------------------
It seems that ADSL connections are not that persistant. There's nothing you can do about it, but I have found
this neat feature of pppd, to execute a script upon disconnection (and also upon connection, if you have some
funky Dynamic DNS script you wanna call whenever you connect).
The files are located too in the /etc/ppp directory.
The script that is executed when the connection is established is /etc/ppp/ip-up and the script that is executed
when the connection is lost is /etc/ppp/ip-down.
So, in that sense, you can put:
#!/bin/sh
/sbin/adsl-up
In your /etc/ppp/ip-down file, and then you would get re-connected when ever you get disconnected (if the problem
is not physical, ofcourse).



Step 6 - Connection Attempt
--------------------------------------------------------------------------
You're probably wondering when we're gonna get connected to the internet.
Well, pretty soon.
First of all, if you havn't done so far, you should edit your /etc/resolv.conf to be able to query DNS queries.
(The explanation on how to do this is beyond the scope of this guide, but it's pretty easy, you just stick your
ISP's name server's in lines like this:
nameserver <ISP_DNS1_IP>
nameserver <ISP_DNS2_IP>
And that's pretty much all you need to know).
After we've got DNS set up correctly, we're gonna try to execute our connection script.
We will need to simultaneously look at the logs and execute the script to see what it outputs, so in one console
do:
# tail -f /var/log/all.log
And in the other, execute the dialing script:
# /sbin/adsl-up
And wait, it should probably take a couple of seconds. You will be getting about 2 messages from pptp telling you
about the connection attempt. Afterwards, you should see a connection confirmation in your log console, something
like this:
Apr 14 16:57:33 yashi pppd[38924]: local IP address 192.115.135.46
Apr 14 16:57:33 yashi pppd[38924]: remote IP address 192.115.135.1
If you see this, it means you are now connected. Just to make sure, try to ping your ISP or something, and see that
it works.
If you are connected, congratulations.
If not, screw you.

That is all, hope that was helpful.
Jacob Shapiro.

© 1997 - 20013 Defcon1, www.defcon1.org , Copyrights for all materials on this web site are held by the individual authors, artists, photographers or creators. Materials may not be reproduced or otherwise distributed without permission of www.defcon1.org and the content's original author.

Defcon1-Header2
Tool-Bar-2Defcon1  Webmail