ADSL using /etc/network/interfaces

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
^rooker
Site Admin
Posts: 1481
Joined: Fri Aug 29, 2003 8:39 pm

ADSL using /etc/network/interfaces

Post by ^rooker »

I wanted to use standard tools to get das-werkstatt's internet connection (ADSL) up automatically during boot.

The solution I've found might either be an interesting hack or a really beautiful way of doing it. Nothing in between, I guess.

1) Set up stuff in /etc/ppp to be able to connect to your ISP by calling "pptp modem-ip" (usually 10.0.0.138). Here I'm calling it "stargate", because I've put it in /etc/hosts.

2) Let's assume the physical interface to the ADSL modem is eth0 with 10.0.0.140 (pretty default).

3) Add eth0 to /etc/network/interfaces:

Code: Select all

auto eth0
iface eth0 inet static
                address 10.0.0.140
                netmask 255.255.255.0
                network 10.0.0.0
                broadcast 10.0.0.255
                up ifup intarweb
                down ifdown intarweb
The up/down lines make sure that our virtual interface "intarweb" is brought up (or taken down) as soon as our physical interface to the modem is available.

4) Now here comes the trick:

Code: Select all

iface intarweb inet manual
                pre-up killall pptp || true
                pre-up pptp stargate
                post-up /etc/iptables.up.rules
                down killall pptp || true
I'll explain the steps in detail:

Code: Select all

iface inet inet manual
"manual" is necessary, because we neither know the IP nor do we get it by our own DHCP. It's set by pptp - so we don't want "ifup" to assign any address at all.

Code: Select all

pre-up killall pptp || true
This line makes sure that no previously called pptp is still running. If it was, we'd end up having ppp1 (or pppx) instead of ppp0.

Code: Select all

pre-up pptp stargate
As mentioned above, our modem is called "stargate" (=10.0.0.138), so this line takes care of establishing our internet connection.

Code: Select all

post-up /etc/iptables.up.rules
After the internet-interface (ppp0) has been brought up, it shall run the iptables script called "/etc/iptables.up.rules"

Code: Select all

down killall pptp || true
When the "intarweb" interface is brought down, let's make sure that the pptp demon goes with it.


Note: You could add another line for flushing the iptables rules when bringing down the "intarweb" interface, by adding:

Code: Select all

down /etc/iptables.down.rules
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply