Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
D-Link DSL-300T PPPoA vs Bridge mode (+ dnsmasq + dhcpd)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
MarkDavies
n00b
n00b


Joined: 10 Sep 2004
Posts: 19

PostPosted: Sun Apr 10, 2005 1:38 pm    Post subject: D-Link DSL-300T PPPoA vs Bridge mode (+ dnsmasq + dhcpd) Reply with quote

I recently moved house and switched from NTL 700k cable broadband to Bulldog's 4MB ADSL broadband :-)
I bought myself a DLINK DSL-300T ADSL/Ethernet modem. I thought the modem would help me migrate to ADSL without having to modify my firewall/gateway Gentoo box too much.
I plugged my gateway box into the DSL-300T and the DSL-300T into the phone socket, configured the DSL-300T to perform the relevant PPPoA connection. All seemed to go well, the modem connected to my ISP and issued my gateway machine with a new IP. I could browse the net, check my email. All was looking good. I started giFT and walked away.
When I came back I found my connection to the internet had gone. I restarted my gateway box's ethernet connection and the internet came back. A little while later the internet was gone again. The internet seemed to go up and down. It would stay up for a minute, then go down for a few minutes. Resetting the modem seemed to make the connection stay up for a bit longer,
sometimes even a good few hours if I wasn't running giFT.
I chatted to Bulldog's Tech Support guys and browsed a few forums. Bulldog did all they could their end. A few forums suggested not buying the DSL-300T because it was crap (that's about as technical as they got with the argument).
I spent about a week looking into the problem, tweaking my DHCP client settings, installing QoS scripts, logging into the DSL-300T (it runs linux) and playing with its settings. Nothing seemed to solve the problem. I had one last idea. The DSL-300T is doing all of the PPPoA stuff for me, I wonder what happens if I get my gateway box to do this bit. I installed rp-pppoe, switched the DSL-300T into bridge mode, ran adsl-setup the adsl-start. I was connected to the internet again, I ran giFT and walked away.
When I came back, the internet was still there and, from what I can see, it seems stable.

Below are a few steps/configuration files I used to set up my machine.
They're here as a reference for other DSL-300T users. Both configurations use dnsmasq and have a DHCP server running.
This is not meant to be a HOW TO, just a few bits and pieces of information that I've found useful.

Setup Notes for DSL-300T in PPPoA mode

Firstly configure your network. eth0 is connect to my modem and eth1 to my LAN.

Code:
#cat /etc/conf.d/net | grep -v -e '^\(#.*\)\? *$'
iface_eth0="dhcp"
dhcpcd_eth0="-n -R"
iface_eth1="192.168.0.254 broadcast 192.168.0.255 netmask 255.255.255.0"


Next, start the network and if it works, turn it on by default.

Code:
# /etc/init.d/net.eth0 start
# rc-update add net.eth0 default


Here is my dnsmasq configuration.

Code:
# cat /etc/dnsmasq.conf | grep -v -e '^\(#.*\)\? *$'
localmx
domain-needed
bogus-priv
resolv-file=/etc/resolv-eth0.conf
user=nobody
group=nobody
except-interface=eth0
dhcp-leasefile=/var/lib/dhcp/dhcpd.leases
log-queries


Code:
#cat /etc/resolv.conf
nameserver 127.0.0.1


Providing DNS entries to dnsmasq

The DNS entries that dnsmasq needs can be obtained from your DHCP client using a few simple scripts.

I've based my scripts on the one mentioned in this thread

Code:
# ls -l /var/lib/dhcpc/
total 16
lrwxrwxrwx  1 root root   18 Apr  7 21:49 dhcpcd-eth0.exe -> dhcpcd-generic.exe
-rw-r--r--  1 root root  369 Apr  5 19:19 dhcpcd-eth0.info
-rwxr-xr-x  1 root root 1464 Apr  7 21:57 dhcpcd-generic.exe
-rwxr-xr-x  1 root root  223 Apr  7 21:51 dhcpcd.exe


dhcpcd.exe just works out the interface that dhcpcd has obtained information about (i.e. eth0, eth1, etc.) and calls the dhcpcd-<interface>.exe script if it exists. You could just replace the dhcpcd.exe with dhcpcd-generic.exe script if you want. I've split the scripts up so that custom ones can easily be written. You can symbilically link to the dhcpcd-generic.exe script for each interface that dhcpcd listens on.

dhcpcd-generic.exe script works out the interface that dhcpcd has obtained information about (i.e. eth0, eth1, etc.), grabs the DNS entries supplied and creates a /etc/resolv-<interface>.conf file. If a /etc/resolv-<interface>-extra.conf file exists then its contents are appended to the newly created /etc/resolv-<interface>.conf file.

Code:
# ls -l /etc/resolv*
-rw-r--r--  1 root root  51 Mar 17 23:06 /etc/resolv-eth0-extra.conf
-rw-r--r--  1 root root 142 Apr  7 21:58 /etc/resolv-eth0.conf
-rw-r--r--  1 root root  21 Apr  9 12:49 /etc/resolv.conf


Code:
# cat /etc/resolv.conf
nameserver 127.0.0.1


Code:
# cat /etc/resolv-eth0-extra.conf
nameserver 212.158.192.3
nameserver 212.158.192.2


Code:
# cat /etc/resolv-eth0.conf
# Autogenerated by ./dhcpcd-eth0.exe on Thu Apr 7 21:58:12 GMT 2005
nameserver 83.146.21.6
nameserver 212.158.192.3
nameserver 212.158.192.2


You will need to modify the dnsmasq configuration to use the /etc/resolv-<interface>.conf file.

OK, here are the two scripts....

Code:
#cat /var/lib/dhcpc/dhcpcd.exe
#!/bin/sh
DIR=`dirname $0`
EXE=`basename $0`
IF=`echo $1 | sed  -e 's/^.*-\([0-9a-z]*\)\..*$/\1/g'`

if [ -e "$DIR/dhcpcd-$IF.exe" ];
then
    logger -t \($EXE\) Running $DIR/dhcpcd-$IF.exe
    $DIR/dhcpcd-$IF.exe "$@"
fi


Code:
# cat /var/lib/dhcpc/dhcpcd-generic.exe
#!/bin/sh
echo "(dhcpcd)  Interface $2, see $1" | logger
#
# man 8 dhcpcd states parameter
# - 1 is <HostInfoFilePath>
# - 2 is <up|down|new>
# - 3 is -d if debug
#
IF=`echo $1 | sed  -e 's/^.*-\([0-9a-z]*\)\..*$/\1/g'`
RES=/etc/resolv-$IF.conf # destination file
TMP=/tmp/resolv-$IF.conf.$$ # temporary file
EXTRA=/etc/resolv-$IF-extra.conf # extra DNS entries

case $2 in
  up|new) # We want to check for dns changes when
          # starting up or renewing the lease
    if [ -e "$1" ] # File exists ?
    then
      . "$1"       # source it
    fi
    if [ "$DNS" != "" ] # Variable DNS declared?
    then
      [ -e $TMP ] && rm $TMP    # remove it if it exists
      echo \# Autogenerated by $0 on `date` >>$TMP
      for i in `echo $DNS | sed 's/,/ /g'` # process dns server addresses
      do
        echo nameserver $i >>$TMP          # create the resolv.conf line
        echo "(dhcpcd)  nameserver = $i" | logger
      done
      if [ -e "$EXTRA" ]  # if extra DNS file exists
      then
        echo "(dhcpcd)  Adding entries in $EXTRA" | logger
        cat $EXTRA >>$TMP
      fi
      # if destination file does not exist or
      # destination file differs
      if [ ! -e $RES ] || \
         [ `diff $TMP $RES | wc -l` -ne 0 ]
      then
        mv $TMP $RES # replace destination with the new one
      else
        rm $TMP      # clean temporary file
      fi
    fi
    ;;
  down)
    echo >$RES          # blank the resolv.conf file
    ;;
  *)
    ;;
esac




Setup Notes for DSL-300T in Bridge mode

Configure your network.

Code:
# cat /etc/conf.d/net | grep -v -e '^\(#.*\)\? *$'
ifconfig_eth0="up"
iface_eth1="192.168.0.254 broadcast 192.168.0.255 netmask 255.255.255.0"


Setup your ADSL connection, test it works and turn it on by default.

Code:
# emerge rp-pppoe
# adsl-setup
# adsl-start
# rc-update add rp-pppoe default


/etc/ppp/pppoe.conf will be updated by adsl-setup, mine looks like this. You will need to manually modify this file if you use my ip-up and ip-down scripts (see below).

Code:
# cat /etc/ppp/pppoe.conf | grep -v -e '^\(#.*\)\? *$'
ETH='eth0'
USER='xxxx-your username-xxxxxx'
DEMAND=no
DNSTYPE=NOCHANGE
PEERDNS=no
DNS1=
DNS2=
DEFAULTROUTE=yes
CONNECT_TIMEOUT=30
CONNECT_POLL=2
ACNAME=
SERVICENAME=
PING="."
PIDFILE="/var/run/$CF_BASE-adsl.pid"
SYNCHRONOUS=no
CLAMPMSS=1412
LCP_INTERVAL=20
LCP_FAILURE=3
PPPOE_TIMEOUT=80
FIREWALL=NONE
LINUX_PLUGIN=
PPPOE_EXTRA=""
PPPD_EXTRA="usepeerdns ipparam nopeerdns"


Here is my dnsmasq configuration. The only part to have really changed is the resolv-file entry.

Code:
# cat /etc/dnsmasq.conf | grep -v -e '^\(#.*\)\? *$'
localmx
domain-needed
bogus-priv
resolv-file=/etc/ppp/resolv.conf
user=nobody
group=nobody
except-interface=eth0
dhcp-leasefile=/var/lib/dhcp/dhcpd.leases
log-queries


Code:
#cat /etc/resolv.conf
nameserver 127.0.0.1


Providing DNS entries to dnsmasq

The DNS entries that dnsmasq needs are automatically added to /etc/ppp/resolv.conf and /etc/resolv.conf. I've tried to figure out how to stop /etc/resolv.conf from being modified and am currently using the solution below. You can read a bit more on this problem in this thread.

Modify the ip-up and ip-down scripts in /etc/ppp

Code:
# cat /etc/ppp/ip-up
#!/bin/sh

# this is a script which is executed after connecting the ppp interface.
# look at man pppd for details

# the followings parameters are available:
# $1 = interface-name
# $2 = tty-device
# $3 = speed
# $4 = local-IP-address
# $5 = remote-IP-address
# $6 = ipparam

# Added to stop /etc/resolv.conf from being modified
if [ "$6" = "nopeerdns" ]; then
        USEPEERDNS=""
fi

if [ "$USEPEERDNS" ]; then

        # add the server supplied DNS entries to /etc/resolv.conf
        # (taken from debian's 0000usepeerdns)

        # follow any symlink to find the real file
        REALRESOLVCONF=$(readlink --canonicalize /etc/resolv.conf)

        if [ "$REALRESOLVCONF" != "/etc/ppp/resolv.conf" ]; then

                # merge the new nameservers with the other options from the old configuration
                {
                        grep --invert-match '^nameserver[[:space:]]' $REALRESOLVCONF
                        cat /etc/ppp/resolv.conf
                } > $REALRESOLVCONF.tmp

                # backup the old configuration and install the new one
                cp -a $REALRESOLVCONF $REALRESOLVCONF.pppd-backup
                mv $REALRESOLVCONF.tmp $REALRESOLVCONF

                # correct permissions
                chmod 0644 /etc/resolv.conf
                chown root:root /etc/resolv.conf

        fi

fi


Code:
 # cat /etc/ppp/ip-down
#!/bin/sh

# this is a script which is executed after disconnecting the ppp interface.
# look at man pppd for details

# the followings parameters are available:
# $1 = interface-name
# $2 = tty-device
# $3 = speed
# $4 = local-IP-address
# $5 = remote-IP-address
# $6 = ipparam

# Added to stop /etc/resolv.conf from being modified
if [ "$6" = "nopeerdns" ]; then
        USEPEERDNS=""
fi

if [ "$USEPEERDNS" ]; then

        # taken from debian's 0000usepeerdns
        # follow any symlink to find the real file
        REALRESOLVCONF=$(readlink --canonicalize /etc/resolv.conf)

        if [ "$REALRESOLVCONF" != "/etc/ppp/resolv.conf" ]; then

                # if an old resolv.conf file exists, restore it
                if [ -e $REALRESOLVCONF.pppd-backup ]; then
                        mv $REALRESOLVCONF.pppd-backup $REALRESOLVCONF
                fi

        fi

fi

# Recreate the default route so autodial works
[ -s /etc/conf.d/net ] && . /etc/conf.d/net
if [ -n "${gateway}" ] && [ "${gateway%/*}" = "$1" ]; then
        /sbin/route add default dev ${gateway%/*}
fi

[ -f /etc/ppp/ip-down.local ] && . /etc/ppp/ip-down.local "$@"


I've modified the following entries in /etc/ppp/pppoe.conf

DNSTYPE=NOCHANGE
PEERDNS=no
PPPD_EXTRA="usepeerdns ipparam nopeerdns"


I hope that all helps. If you spot a mistake please notify me. Thanks.
Back to top
View user's profile Send private message
confusion
Tux's lil' helper
Tux's lil' helper


Joined: 24 Mar 2004
Posts: 132

PostPosted: Mon May 30, 2005 8:59 pm    Post subject: Reply with quote

Unbelievable. I've been experiencing exactly the same problem (but on 2mb instead of 4mb), and I came across this post by mistake! I'll have a play with the modem later and let you know if it works.

Thanks once again,

-John
Back to top
View user's profile Send private message
confusion
Tux's lil' helper
Tux's lil' helper


Joined: 24 Mar 2004
Posts: 132

PostPosted: Tue May 31, 2005 9:11 pm    Post subject: Reply with quote

The connection seems to be running perfectly now, thanks once again!

-John
Back to top
View user's profile Send private message
tane_stelzer
Apprentice
Apprentice


Joined: 30 Dec 2005
Posts: 263
Location: Edinburgh, Scotland and Kempen, Germany

PostPosted: Sat Jun 03, 2006 3:39 pm    Post subject: Reply with quote

Ok i seem to have a simliar problem. I have a DSL-300T and it does go up and down with my internet just as described in ur post. Now i connect my 300T to a router and some machines which conncect to the router dont use linux· Have u got any suggestions for this tiny wee problem. I am a complete newb when it comes to networking.
Thanks a lot
Tane
_________________
Quick Quide to Linux Commands!
MINI HOWTO Get Planeshift working
Back to top
View user's profile Send private message
MarkDavies
n00b
n00b


Joined: 10 Sep 2004
Posts: 19

PostPosted: Mon Jun 05, 2006 8:59 am    Post subject: Reply with quote

tane_stelzer wrote:
Ok i seem to have a simliar problem. I have a DSL-300T and it does go up and down with my internet just as described in ur post. Now i connect my 300T to a router and some machines which conncect to the router dont use linux· Have u got any suggestions for this tiny wee problem. I am a complete newb when it comes to networking.
Thanks a lot
Tane


There are two things you can do.

1. Reflash your DSL-300T with OpwnWRT (http://openwrt.org), AND/OR
2. Use one of your linux boxes as a firewall/gateway/router.


[DSL-300T] ------- [Linux Box] ------- [router] --------- [other machines]

The DSL-300T can be run in bridged mode.


I'm using option 2. My linux box handles all of the network stuff, firewall, DNS server, transparent web proxy/caching, etc.

There is quite a bit of info on the forums about setting up a firewall machine
Back to top
View user's profile Send private message
tane_stelzer
Apprentice
Apprentice


Joined: 30 Dec 2005
Posts: 263
Location: Edinburgh, Scotland and Kempen, Germany

PostPosted: Mon Jun 05, 2006 1:39 pm    Post subject: Reply with quote

OK i had a look at Open WRT and it looks like a lot of work. Mz linux box is a laptop. So i dont think option 2 is not possible right? also that would mean that it would have to be on 24/7 which is not really a good thing either. hmm. I will have a look at OpwnWRT
THanks for the reply
Tane
_________________
Quick Quide to Linux Commands!
MINI HOWTO Get Planeshift working
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum