This is the old SliTaz forum - Please use the main forum.slitaz.org

eth0 , eth1 , liveusb and udev persistent rules
  • erniaernia March 2010
    Moving (and saving rootfs) my liveusb key from a machine to another i found myself with eth* numbers different from 0, which is not good because the network script (if i got it right) configures eth0 and not other card.
    As a workaround i'm using a script that save rootfs deleting /etc/udev/rules.d/70-persistent-net.rules before to save rootfs. If somebody else should be interested...
  • erniaernia March 2010
    another workaround i've found without deleting udev rules is to edit /etc/init.d/network.sh and putting inside it, after that /etc/network.conf or the alternative file has been sourced, the following lines:
    # if there is (at least) an eth* network card then get the number of the first one,
    # use it in this script and change interface in lxpanel network applet too
    #pay attention, this could drive crazy someone who is tryng to understand
    #why eth* number is not the one in /etc/network.conf
    if grep -q eth /proc/net/dev ; then
    INTERFACE=`cat /proc/net/dev | grep eth | cut -d : -f 1 | cut -d \ -f 3 | sed -n '1p'`
    sed -i "s/iface=eth[0-9][0-9]*/iface=$INTERFACE/" /etc/lxpanel/default/panels/panel
    fi

    it seems to work, i booted in different pc and i got network working at boot-up
    just for sharing
  • erniaernia March 2010
    if you have some customization in your lxpanel then you will have a /home/$USER/.config/lxpanel/default/panels/panel , so i've amended my changes to /etc/init.d/network.sh to
    # if there is (at least) an eth* network card then get the number of the first one,
    # use it in this script and change interface in lxpanel network applet too
    #pay attention, this could drive crazy someone who is tryng to understand
    #why eth* number is not the one in /etc/network.conf
    if grep -q eth /proc/net/dev ; then
    INTERFACE=`cat /proc/net/dev | grep eth | cut -d : -f 1 | cut -d \ -f 3 | sed -n '1p'`
    sed -i "s/iface=eth[0-9][0-9]*/iface=$INTERFACE/" /etc/lxpanel/default/panels/panel
    for i in `ls /home`; do
    if [ -e /home/$i/.config/lxpanel/default/panels/panel ]; then
    sed -i "s/iface=eth[0-9][0-9]*/iface=$INTERFACE/" /home/$i/.config/lxpanel/default/panels/panel ]
    fi
    done
    fi
  • ms3811ms3811 September 2010
    ernia, not sure if I am doing something wrong (more likely the case), but I added the code above to the start section in network.sh and noticed the following on network.sh restart:

    1. for some reason $INTERFACE always returns eth0, even if the active connection is eth1.
    2. if I hard code eth1 (in place of $INTERFACE above), then iface=eth0 is replaced with iface=eth1 in /home/$i/.config/lxpanel/default/panels/panel, however, lxpanel does not update the setting. It still shows whatever it had originally.

    What am I doing wrong?

    Ps: there appears to be an extra ']' in the if block above.
  • ms3811ms3811 September 2010
    I'm guessing the script above simply updates lxpanel with the first 'eth' it finds, which if it is the case, may not work in situations where eth0 may be up but not connected while eth1 is the one actually active.
  • erniaernia October 2010
    if you paste my code after this if
     if [ -z "$2" ]; then
    . /etc/network.conf
    else
    . $2
    fi
    and before this row
    ifconfig $INTERFACE up
    , it will detect the first usable eth* , it will update lxpanel and take up the detected interface which obviously becomes the one actually active.
    if you paste the code in the start section before the if the INTERFACE variable value will be overridden from the value in /etc/network.conf (or in the alternative config file in $2) which will be sourced from the if.
  • ms3811ms3811 October 2010
    @ernia, I modified network.sh as you suggested and it seems to be working fine. I rebooted the system and it automatically switched to the active interface.

    Thanks for taking the time to explain.
  • erniaernia October 2010
    sorry about the delay, yesterday it was the first time i came back to the forum from april :-)
  • ms3811ms3811 October 2010
    hope that was because you were chilling out with a big keg of beer in Ibiza!
  • Nevermind04Nevermind04 October 2010
    Thank you so much for taking the time to post this for everyone!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

SliTaz Social