[Lxc-users] Problem with network start on Arch Linux (with revised rc.conf)

Joerg Gollnick code4lxc+list at wurzelbenutzer.de
Mon Jul 11 21:24:44 UTC 2011


Hello John,
I removed the network setup completly in the container. (rc.conf DAEMONS)

In rc.conf I'm using following lines:
# Static IP example
interface=eth0
address=192.168.0.2
netmask=24
gateway=192.168.0.1

For initialization I patched the inittab
rc::sysinit:/etc/rc.sysinit.container

And finally removed most things from rc.sysinit to get rc.sysinit.container.

#!/bin/bash
#
# /etc/rc.sysinit.container
#

. /etc/rc.conf
. /etc/rc.d/functions

echo " "
printhl "Arch Linux\n"
printhl "${C_H2}http://www.archlinux.org"
printhl "Copyright 2002-2007 Judd Vinet"
printhl "Copyright 2007-2010 Aaron Griffin"
printhl "Distributed under the GNU General Public License (GPL)"
printsep

run_hook sysinit_start

# bring up the loopback interface
if [ -d /sys/class/net/lo ]; then
        stat_busy "Bringing up loopback interface"
        /sbin/ifconfig lo 127.0.0.1 up
        if [ $? -ne 0 ]; then
                stat_fail
        else
                stat_done
        fi
fi

RANDOM_SEED=/var/lib/misc/random-seed
if [ -f $RANDOM_SEED ]; then
        stat_busy "Initializing Random Seed"
        /bin/cat $RANDOM_SEED > /dev/urandom
        stat_done
fi

stat_busy "Removing Leftover Files"
/bin/rm -f /etc/nologin &>/dev/null
/bin/rm -f /etc/shutdownpid &>/dev/null
/bin/rm -f /var/lock/* &>/dev/null
/bin/rm -rf /tmp/* /tmp/.* &>/dev/null
/bin/rm -f /forcefsck &>/dev/null
(cd /var/run && /usr/bin/find . ! -type d -exec /bin/rm -f -- {} \; )
: >| /var/run/utmp
/bin/chmod 0664 /var/run/utmp
# Keep {x,k,g}dm happy with xorg
/bin/mkdir /tmp/.ICE-unix && /bin/chmod 1777 /tmp/.ICE-unix
/bin/mkdir /tmp/.X11-unix && /bin/chmod 1777 /tmp/.X11-unix
stat_done

#status "Updating Shared Library Links" /sbin/ldconfig

if [ "$HOSTNAME" != "" ]; then
        status "Setting Hostname: $HOSTNAME" /bin/hostname $HOSTNAME
fi
if [ -f /etc/localtime ]; then
        /bin/rm -f /etc/localtime
        /bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
fi

# Flush old locale settings
: >| /etc/profile.d/locale.sh
/bin/chmod 755 /etc/profile.d/locale.sh
# Set user defined locale
[ -z "$LOCALE" ] && LOCALE="en_US"
stat_busy "Setting Locale: $LOCALE"
echo "export LANG=$LOCALE" >>/etc/profile.d/locale.sh
stat_done

if echo "$LOCALE" | /bin/grep -qi utf ; then
        stat_busy "Setting Consoles to UTF-8 mode"
        # UTF-8 consoles are default since 2.6.24 kernel
        # this code is needed not only for older kernels,
        # but also when user has set vt.default_utf8=0 but LOCALE is *.UTF-8.
        for i in /dev/tty[0-9]*; do
                /usr/bin/kbd_mode -u < ${i}
                printf "\033%%G" > ${i}
        done
        # the $CONSOLE check helps us avoid this when running scripts from 
cron
        echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf 
"\033%%G"; fi' >>/etc/profile.d/locale.sh
        stat_done
        [ -n "$KEYMAP" ] && status "Loading Keyboard Map: $KEYMAP" 
/bin/loadkeys -q -u $KEYMAP
else
        stat_busy "Setting Consoles to legacy mode"
        # make non-UTF-8 consoles work on 2.6.24 and newer kernels
        for i in /dev/tty[0-9]*; do
                /usr/bin/kbd_mode -a < ${i}
                printf "\033%%@" > ${i}
        done
        # the $CONSOLE check helps us avoid this when running scripts from 
cron
        echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf 
"\033%%@"; fi' >>/etc/profile.d/locale.sh
        stat_done
        [ -n "$KEYMAP" ] && status "Loading Keyboard Map: $KEYMAP" 
/bin/loadkeys -q $KEYMAP
fi

# Set console font if required
set_consolefont

/bin/dmesg >| /var/log/dmesg.log

run_hook sysinit_end

# End of file
# vim: set ts=2 sw=2 noet:

Hope that helps, best regards Joerg

On Monday 11 July 2011 21:27:13 John wrote:
> On 29/06/11 10:29, lxc at jelmail.com wrote:
> > Hi list,
> > 
> > I've just updated my container config to use the new way of configuring
> > the network on Arch Linux. This does not use the net-tools (ifconfig)
> > package any more but instead uses ip.
> > 
> > The container rc.conf file contains the simple static network setup:
> > 
> > # Static IP example
> > interface=eth0
> > address=192.168.0.2
> > netmask=255.255.255.0
> > gateway=192.168.0.1
> > 
> > The problem I have is that when /etc/rc.d/network tries to add the ip
> > address to the network this fails with a "RTNETLINK answers: file
> > exists"
> > and bails out.
> > 
> > It would appear that the IP address is already added when the script
> > tries to do it. This causes it to fail and, therefore, not bother doing
> > anything else. This means the routes (default gatweay) don't get set up
> > so the network is left half-baked.
> > 
> > Trying to shut down the network (/etc/rc.d/network stop) then fails
> > because it can't delete the route that wasn't added (RTNETLINK answers:
> > file not found).
> > 
> > If I comment out the line from /etc/rc.d/network that adds the IP
> > address
> > (ip addr add...) everything then works fine when I start the container.
> > However, If I manually stop the network, and then manually start the
> > network it won't start because the IP address does not get added (due to
> > that line being commented out).
> > 
> > Very strange.
> > 
> > I wondered if the LXC environment is adding the IP address when the
> > container starts and if there is a way to stop this so it just lets the
> > container do it ?
> > 
> > I'm looking for some advice on how to get the network setup working
> > correctly on Arch Linux. I may need new init scripts (rc.sysinit,
> > rc.shutdown) also.
> > 
> > Thanks in advance,
> > John.
> 
> Hello, would anyone please be able to help with my query? I am stuck on
> this and would appreciate guidance...
> 
> ----------------------------------------------------------------------------
> -- All of the data generated in your IT infrastructure is seriously
> valuable. Why? It contains a definitive record of application performance,
> security threats, fraudulent activity, and more. Splunk takes this data and
> makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> Lxc-users mailing list
> Lxc-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-users




More information about the lxc-users mailing list