ADSL using /etc/network/interfaces
Posted: Mon Sep 03, 2007 11:47 pm
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:
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:
I'll explain the steps in detail:
"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.
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.
As mentioned above, our modem is called "stargate" (=10.0.0.138), so this line takes care of establishing our internet connection.
After the internet-interface (ppp0) has been brought up, it shall run the iptables script called "/etc/iptables.up.rules"
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:
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
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
Code: Select all
iface inet inet manual
Code: Select all
pre-up killall pptp || true
Code: Select all
pre-up pptp stargate
Code: Select all
post-up /etc/iptables.up.rules
Code: Select all
down killall pptp || true
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