Linux 15.028 Themen, 107.037 Beiträge

Debian /etc/network/interfaces korrekt einrichten

michi_p / 9 Antworten / Baumansicht Nickles

Hallo,

ich weiß, das folgende Problem wurde schon hundertfach behandelt, aber die meine "99" Vorgänger will es in meinem System nicht funktionieren.

Also Debian auf Thinkpad R60

Ich hätte gerne, daß das Notebook automatisch erkennt in welchem Netz es sich befindet und dieses sofort aktiviert.
Zur Zeit muß ich immer mühsam die eth devices neu starten... :(

Habe zu Hause ein WLAN, DHCP-Server, Name "home", managed, WEP und Password gesetzt.
Außerdem noch ein Ethernet an diesem DHCP Server.

Auf der Arbeit gibt es ebenfalls WLAN und Ethernet. DHCP.

Habe schon viel probiert aber es läuft nicht wie es soll...

Wo ist möglicherweise der Fehler?

vg Micha

Meine bisherige "interfaces"-Datei:

##########################

iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0


# Ethernet
mapping eth0
script grep

iface work inet dhcp

iface home inet dhcp



# WLAN
mapping eth2
script grep

iface wwork inet dhcp
wireless-mode managed
wireless-essid WORK

iface whome inet dhcp
wireless-mode managed
wireless-security wep
wireless-essid HOME
wireless-key s:#PW sollte hexadezimal sein#

allow-hotplug eth0
allow-hotplug eth2

auto lo
auto eth0
auto eth2

##########################

bei Antwort benachrichtigen
KarstenW michi_p „Debian /etc/network/interfaces korrekt einrichten“
Optionen

Den Fehler finde ich nicht. Ich habe auch keine Erfahrung mit Notebooks. Aber es gibt diese Möglichkeit das Netzwerk automatisch konfigurieren zu lassen , wenn man mit einem Notebook in verschiedenen Netzen unterwegs ist.

Du kannst das Paket "guessnet" unter Debian etch 4.0 installieren. guessnet verwendet unter anderen das ARP Protokoll um herauszufinden , ob ein Host im Netzwerk erreichbar ist.
Dann gibt es noch das Paket "ifplugd" welches man zusätzlich zu guessnet installieren kann, um die Konfiguration der Netzwerkschnittstellen weiter zu automatisieren.
Wenn du in verschiedenen Funknetzen unterwegs bist, dann hilft auch das Paket "waproamd".

Ich lese das alles aus dem Debian Handbuch von Martin F. Kraft. "Das Debian System".
Ich kann dir nur empfehlen mal in dieses Handbuch zu schauen und auf Seiten 352-366 nachzulesen.

http://www.amazon.de/Das-Debian-System-Konzepte-Methoden/dp/3937514171/ref=pd_bbs_sr_1/303-3205199-6161035?ie=UTF8&s=books&qid=1184096873&sr=8-1

Ich denke nur mit der Konfigurationsdatei /etc/network/interfaces wirst du es nicht schaffen die Konfiguration der Netzwerkschnittstellen zu automatisieren.
Da mußt du noch die Pakete guessnet, ifplugd und eventuell waproamd installieren.
Am besten mit synaptic.

PS:

aus synaptic kopiert:

guessnet:


Guess which LAN a network device is connected to
Guessnet is a non-aggressive network detection tool to use when moving
a machine among networks which don't necessarily provide DHCP.

Guessnet takes in input a list of candidate network profiles,
each of which includes a test description; then it runs all
the tests in parallel and prints the name of the profile whose
test was the first one to succeed.

Available tests are:
* ARP probes to check for known hosts in the network
* link beat check, to check if the interface is connected to anything
* Wireless lan checks, to look for access points found by waproamd
* PPPOE check to see if there is a concentrator accessible via PPPOE
* Checks provided by custom arbitrary scripts.

Guessnet can be used in either native mode or "ifupdown mode".
In the latter case guessnet integrates nicely with ifupdown
as a "mapping script".


ifplugd:

A configuration daemon for ethernet devices
ifplugd is a daemon which will automatically configure your
ethernet device when a cable is plugged in and automatically
unconfigure it if the cable is pulled. This is useful on laptops with
onboard network adapters, since it will only configure the interface
when a cable is really connected.

Some features:
* May beep when the cable is unplugged, plugged, the interface
configuration succeeded or failed.
* Syslog support
* small
* Multiple ethernet interface support
* Support for wireless networking. Whenever an association to an AP
is detected the network is configured. Have a look on waproamd
if you need a facility to configure WEP keys before AP
associations succeed.
* Compatibility mode for network devices which do not support cable
detection


waproamd:

WLAN roaming daemon
waproamd is a Linux WLAN roaming daemon for IEEE 802.11
cards supported by a driver with wireless extension API. It may be
used for configuring WEP keys according to the WLANs available, and
automatically configures the network interface when an access point is
found.

This version does not need ifplugd any more to configure the network
card.




Debian GNU/Linux https://www.debian.org/index.de.html
bei Antwort benachrichtigen
KarstenW michi_p „Debian /etc/network/interfaces korrekt einrichten“
Optionen

Ich habe mal im Internet gegoogelt und dies gefunden (leider nicht in deutsch):

http://guessnet.alioth.debian.org/FAQ.html

Dieses Howto ist besser (und in deutsch):


http://www.matthias-deege.de/howto/guessnet_ubuntu.html#toc3






Debian GNU/Linux https://www.debian.org/index.de.html
bei Antwort benachrichtigen
slap882 michi_p „Debian /etc/network/interfaces korrekt einrichten“
Optionen

Hi,

Benutzt Du Gnome als Desktop? Dann müsste normalerweise auch folgendes funktionieren:

Das Netzwerk-Manager-Applet 0.6.4 in der Programmstartleiste aktivieren (rechte Maustaste). Dort kannst Du verschiedene Profile anlegen, oder zu jeder Netzwerkschnittstelle den Roaming-Modus aktivieren. Dann sollte die letzte WLAN-Verbindung sich im Zweifelsfall ebenso automagisch aktivieren wie die LAN-Verbindung.

Viele Grüße

Sven

bei Antwort benachrichtigen
KarstenW michi_p „Debian /etc/network/interfaces korrekt einrichten“
Optionen

Hier ist ein sehr guter Artikel aus dem Linux User:

Automatische Netzwerkkonfiguration unter Debian

http://www.linux-user.de/ausgabe/2005/07/046-ifplugd/index.html?print=y

Debian GNU/Linux https://www.debian.org/index.de.html
bei Antwort benachrichtigen
KarstenW michi_p „Debian /etc/network/interfaces korrekt einrichten“
Optionen

Ich habe mal zu Testzwecken eine WLAN Karte mit Atheros Chipsatz in meinen Desktoprechner eingebaut und außerdem ist noch ein normale Netzwerkkarte konfiguriert.
Ich habe Debian 4.0 und ifplugd und guessnet installiert.
Das ist meine /etc/network/interfaces Datei

cat /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth2
iface eth2 inet static
address 192.168.0.9
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 192.168.0.1
dns-search local

allow-hotplug ath0
iface ath0 inet static
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
address 192.168.0.20
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
dns-nameservers 192.168.0.1
dns-search local

Die Daten die momentan in der wpa_supplicant Datei stehen kann man auch direkt in die interfaces eintragen.

Man braucht nur guessnet und den ifplugd zu installieren.
Den ifplugd muß man noch mit "dpkg-reconfigure ifplugd" konfigurieren.
Da muß man nur die Netzwerkschnittstellen angeben, die überwacht werden sollen.
Sobald ich das Netzwerkkabel von eth2 abziehe , fährt der ifplugd eth2 mit ifdown herunter und die Netzwerkkommunikation läuft über ath0.
Wird das Netzwerkkabel wieder angesteckt, dann wird eth2 wieder mit ifup aktiviert und die Netzwerkpakete laufen wieder über eth2.
So ähnlich müßte es auch bei dir funktionieren.
Wichtig ist eigentlich nur den ifplugd zu installieren und die Gerätedateien anzugeben die überwacht werden sollen.





Debian GNU/Linux https://www.debian.org/index.de.html
bei Antwort benachrichtigen
michi_p KarstenW „Ich habe mal zu Testzwecken eine WLAN Karte mit Atheros Chipsatz in meinen...“
Optionen

hi,

das sieht interessant aus!
Werde das mal versuchen, bislang hat noch nichts richtig funktioniert.
Was steht denn bei Dir noch in der wpa_supplicant.conf?
Kannst Du die auch mal posten?

vg
micha

bei Antwort benachrichtigen
KarstenW michi_p „hi, das sieht interessant aus! Werde das mal versuchen, bislang hat noch nichts...“
Optionen

cat /etc/wpa_supplicant/wpa_supplicant.conf
# WPA-PSK/TKIP

ctrl_interface=/var/run/wpa_supplicant

network={
ssid="Netzwerkname"
key_mgmt=WPA-PSK
proto=WPA
pairwise=TKIP
group=TKIP
psk="sehr_geheimes_Passwort"
}

Das war ein Beispiel, welches unter /usr/share/doc/wpasupplicant/examples installiert wurde.

PS: guessnet braucht man wenn man die jeweilige Netzwerkschnittstelle in verschiedenen Netzwerken einsetzen will.
Da gibt es auch ein Beispiel, welches unter /usr/share/doc/guessnet/examples installiert wird:

cat /usr/share/doc/guessnet/examples/interfaces


auto lo eth0

iface lo inet loopback

mapping eth0
script guessnet-ifupdown
# List of stanzas guessnet should scan for
# If none is specified, scans for all stanzas
#map home work
map default: dhcp
map timeout: 3
map verbose: true

# Home network configuration
iface home inet static
address 192.168.1.2
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-search home.loc
dns-nameservers 192.168.1.1
# Check for one of these hosts:
test1-peer address 192.168.1.1 mac 00:01:02:03:04:05
test2-peer address 192.168.1.3 mac 00:01:02:03:04:06

# Work network configuration
iface work inet static
address 10.1.1.42
netmask 255.255.255.0
broadcast 10.1.1.255
gateway 10.1.1.1
dns-search work.loc
dns-nameservers 10.1.1.1
# the other guessnet scan:
test-command /usr/local/bin/check_work

# Second job network configuration
iface work2 inet static
address 192.168.2.23
netmask 255.255.255.0
broadcast 192.168.2.255
gateway 192.168.2.1
dns-search work2.loc
dns-nameservers 192.168.2.1
# Specify a source address in case the peer doesn't reply to
# ARP packets coming from 0.0.0.0
test-peer address 192.168.2.1 mac 00:01:02:03:04:05 source 192.168.2.23

# PPPOE network configuration
iface pppoe inet ppp
test pppoe
# It could also be:
#test-pppoe please

# I'd really appreciate a 'disabled' method for iface (#275326)
iface interface inet manual
test missing-cable
pre-up echo No link present.
pre-up false

# guessnet default
iface none inet dhcp

Und wie schon gesagt den ifplugd installieren und mit "dpkg-reconfigure ifplugd" die Netzwerkschnittstellen angeben, die überwacht werden sollen (auch die WLAN Schnittstellen !!).





Debian GNU/Linux https://www.debian.org/index.de.html
bei Antwort benachrichtigen
michi_p KarstenW „cat /etc/wpa_supplicant/wpa_supplicant.conf WPA-PSK/TKIP ctrl_interface...“
Optionen

Hi,

das scheint endlich zu funktionieren!
Allerdings habe ich jetzt erst mal die auto-detection des heim-netzes testen können. Will also nicht zu früh jubeln.

Wenn ich bei der Ethernet-Karte das Kabel ziehe wird das erkannt, und beim wiederverbinden ebenfalls. Ausgezeichnet soweit.

Wenn ich die WLAN Karte allerdings deaktiviere, hardware-mäßig, mit dem Switch am Gehäuse des Notebooks, höre ich kein Signal (bei Ethernet beeps es...). Auch beim wieder einschalten erhalte ich keine Verbindung mehr.

Es bleibt dann nur
modprobe -r ipw3945
modprobe ipw3945
ifup eth2

Merkwürdig dabei auch: Die wireless Verbindung zum Router wird nur hergestellt, wenn Ethernet angeschlossen ist. ??

Sollte alles funktionieren (*hoff*) habe ich noch eine Frage: Wie kann ich denn die Priorität auf Ethernet setzen falls beides verfügbar ist?

vg
micha

PS: Meine aktuelle /etc/network/interfaces

#######################
# activate ifplugd
# and don't forget to let the concerning devices be watched by dpkg-reconfigure ifplugd
# this file is built up on /usr/share/doc/guessnet/examples/interfaces
# wireless detection doesn't work properly
# modprobe -r ipw3945, then reload modprobe ipw3945 and ifup eth2 does it :(

auto lo
auto eth0
auto eth2

iface lo inet loopback

mapping eth0
script guessnet-ifupdown
map default: home
map timeout: 3
map verbose: true

# Home network configuration
iface home inet dhcp
address 192.168.1.1

# Work network configuration
iface work inet dhcp
address 137.138.16.6

# I'd really appreciate a 'disabled' method for iface (#275326)
iface interface inet manual
test missing-cable
pre-up echo No link present.
pre-up false

# guessnet default
iface none inet dhcp



# ########## attempt for wireless ... the never-ending story #########

mapping eth2
script guessnet-ifupdown
map default: whome
map timeout: 3
map verbose: true

# Home network configuration
iface wwork inet dhcp
#wireless-mode managed
wireless-essid cern

iface whome inet dhcp
wireless-essid whome
wireless-key "sagichnicht"

# I'd really appreciate a 'disabled' method for iface (#275326)
iface winterface inet manual
test missing-cable
pre-up echo No wlink present.
pre-up false

# guessnet default
iface wnone inet dhcp
####################

bei Antwort benachrichtigen
KarstenW michi_p „Hi, das scheint endlich zu funktionieren! Allerdings habe ich jetzt erst mal die...“
Optionen

Ließ doch mal das Howto durch:

http://www.linux-user.de/ausgabe/2005/07/046-ifplugd/index.html?print=y

"Netzwerkschnittstellen, die ifplugd verwalten soll, dürfen beim Booten nicht automatisch konfiguriert werden. Entfernen Sie deshalb für jedes betroffene Interface eine eventuell vorhandene Anweisung auto Schnittstellen-Name, zum Beispiel auto eth0, Lassen Sie dabei jedoch die automatische Konfiguration der loopback-Schnittstelle auto lo unangetastet."

auto eth0
auto eth2

würde ich entfernen

"Neben kabelgebundenen Netzwerkadaptern unterstützt ifplugd auch WLAN-Karten. Sobald sich die WLAN-Karte mit einem Zugangspunkt (Access Point) verbindet, veranlasst ifplugd die Konfiguration der Netzwerk-Schnittstelle."

Ich wüßte nicht wie man dann die kabelgebundene Netzwerkverbindung auf Default setzen soll. Bei meiner Testkonfiguration ist es so, das sobald ich das Netzwerkkabel einstecke. alle Datenpakete über Ethernet gesendet werden und nicht über Wireless. Wenn ich dann das Netzwerkkabel abziehe ist Wireless wieder aktiviert.
Wenn ich das Netzwerkkabel wieder anstecke ist Ethernet wieder aktiv.

Ich denke mal das es mit der Reihenfolge der Einträge in der Interfaces-Datei zu tun hat. Bei mir ist Ethernet vor Wireless eingetragen.
Ich habe aber wahrscheinlich auch einen Fehler gemacht.
Ich denke das die Zeilen

allow-hotplug eth2
allow-hotplug ath0

aus der Interfaces raus müssen, da ja ifplugd die Netzwerkinterfaces aktivieren soll.

PS:
Ich habe hier noch was gefunden:

http://0pointer.de/lennart/projects/ifplugd/#documentation

"Troubleshooting

When you are using the hotplug subsystem (Debian package hotplug) you may notice that the network device is configured even when it is not listed on an auto line in /etc/network/interface. This may be due to hotplug being configured to ifup the network interface when it becomes available. This was the default behavior in the Debian hotplug package prior to release 0.0.20030117-1, for example. To prevent this you should either upgrade your hotplug package or comment out the ifup call in /etc/hotplug/net.agent."

Das hotplug System wurde bei Debian etch 4.0 durch udev ersetzt. Ich weiß nun leider nicht wie man erreichen kann, das die Netzwerkinterfaces NICHT beim Booten des Rechner konfigurert werden.
Vielleicht hilft doch schon das Entfernen von auto eth0 und auto eth2 aus der interfaces Datei.



PPS:
Das Buch von Martin F.Kraft ist sehr gut geschrieben . Es ist das beste Handbuch, welches es momentan zu Debian gibt. Die automatische Konfiguration mit ifplugd und guessnet ist aber auch nur sehr allgemein erklärt.








Debian GNU/Linux https://www.debian.org/index.de.html
bei Antwort benachrichtigen