Tips & Tricks

FIXME Page needs to be translated! –

Inhaltsverzeichnis

Renaming network interfaces?

FIXME deprecated

To rename use the program nameif [Debian: net-tools package]. It will read the file /etc/mactab
and rename the device according the name assigned by MAC Address. Let's have a look at a sample
/etc/mactab.

# ifname MAC_Address
eth0  01:23:4A:BC:DE:FF
wlan0 10:32:A4:CB:ED:0F

When executing nameif the device with MAC 10:32:A4:CB:ED:0F will be recognized as wlan0 and not
as eth1, eth2,… or what ever.

At next I decided to rename my devices when firing up the network scripts, e.g. when the loopback device
gets initialized. To do so, create a script with a convincing name, e.g.: etc/network/if-up.d/nameif

#!/bin/bash

nameif
chmod ugo+x /etc/network/if-up.d/nameif

The next time you run
/sbin/ifup
all your interfaces, unless they aren't used at this time >will be renamed.

New Way using udev

By editing your /etc/udev/rules.d/10-local.rules you can also name your network devices by adding following rule:

SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:12:34:ab:cd:5e", NAME="mydev0"

back to top


Checking if networkcable is plugged?

With the tool ethtool [Debian: ethtool package] you can get certain information about your interface among others if it is plugged or not (active link). Here is a short example to return a simple yes or no.

 ethtool eth0 | sed -ne "s#\Link detected:\ \(.*\)#\1#p"
back to top


Wie debugge ncurses Programme?

FIXME Wenn man versucht Programme zu debuggen, die die ncurses verwenden, stößt man auf das Problem, dass die Debugger die Ausgabe, beziehungsweise die Eingabe nicht korrekt bis gar nicht verarbeiten können. Um diese Programme zu debuggen muss der Aus-/Eingabe-Fluss auf ein anderes Terminal umgeleitet werden. Der gdb bietet für solche Zwecke den Befehl:

tty
Als Parameter muss die Schnittstelle angeben werden. Wir greifen hier auf ein Pseudoterminal (pts) zurück. Man startet also sein lieblings Terminalemulationsprogramm (xterm, aterm, eterm,…), oder meldet sich an einem weiteren Terminal an (um zum Beispiel eine Anwendungen auf einem Headless-Server zu debuggen, oder weil man gerne unter der Konsole arbeitet). Mit folgendem Befehl erhalten wir unser pts:
$ tty
/dev/pts/1
Das Terminal wird offen gelassen und wir wechseln nun zu unserem Terminal mit dem gdb. Entweder man startet den gdb ohne parameter und fürt dann in der gdb konsole
tty /dev/pts/1
aus, oder startet den gdb gleich per
$ gdb -tty=/dev/pts/1 [program to debug]
Führt man nun das Programm im Debugger aus, kann man im Terminal auf das wir die Ein-/Ausgabe umgeleitet haben das Programm bedienen.
Nach Oben

tag.linux.scripts.tips

Discussion

Enter your comment
If you can't read the letters on the image, download this .wav file to get them read to you.
 
 
linux/tips.txt · Last modified: 2008/06/30 09:58 by jpk
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Driven by DokuWiki
[unknown button type]