You are not logged in.

#1 2006-03-11 14:51:50

kajaman
Member
From: Poland
Registered: 2006-03-11
Posts: 7
Website

Network profiles - need some changes (?)

Ok, so I got bored with manual changing my network configuration every time I switch from university->home->my parent's home->something else, and I started to play with network profiles. While I love the idea of choosing profile at boot (dialog), I found it not flexible enough for me.

The thing is that I would like to configure all my network interfaces in one file from /etc/network-profiles directory, but it seems impossible. As for now, I made some modifications to /etc/rc.d/network script:

case "$1" in
    start)
        if ! ck_daemon network; then
            echo "Network is already running.  Try 'network restart'"
            exit
        fi

        # See if we're using network profiles
        if [ "$NET" ]; then
            # This env var is passed from the kernel boot line
            if [ "$NET" = "menu" ]; then
                /usr/bin/netcfg --menu --timeout 5
            else
                /usr/bin/netcfg $NET
            fi
        elif [ "$NET_PROFILES" ]; then
# ORYGINAL CODE:
#            if [ "$NET_PROFILES" = "menu" ]; then
#                /usr/bin/netcfg --menu --timeout 5
#            else
                for prof in ${NET_PROFILES[@]}; do
                    if [ "$prof" = "${prof#!}" ]; then
# MY ADDITIONS:
                                    if [ "$prof" = "menu" ]; then
                                                    /usr/bin/netcfg --menu --timeout 5
                                    else
                                                    /usr/bin/netcfg -c $prof
                                    fi
                    fi
                done
#            fi
        fi

This enables me to set up NET_PROFILES = (menu menu) in /etc/rc.conf and with that little hack choose two network profiles to activate at boot.

But I would like to ask if there is any better solution or if there is someone currently working on Arch's init scripts to solve that kind of problems and to make Arch init scripts more flexible? smile


Hubert Lepicki

Offline

#2 2006-04-13 14:19:28

VLegacy
Member
Registered: 2005-01-29
Posts: 43

Re: Network profiles - need some changes (?)

I think you can configure multiple network interfaces from one /etc/network-profiles/ file by listing them like so:

#
# Network Profile
#

DESCRIPTION="Example Network Profile"

# Network Settings
INTERFACE=eth0
INTERFACE=eth1
HOSTNAME=myhost

# Interface Settings (use IFOPTS="dhcp" for DHCP)
IFOPTS="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
IFOPTS="eth1 dhcp"
GATEWAY=192.168.0.1

# DNS Settings (optional)
DOMAIN=localdomain
DNS1=192.168.0.1
DNS2=

# Wireless Settings (optional)
#ESSID=default
#KEY=
#IWOPTS="mode managed essid $ESSID channel 6 key restricted $KEY"

#WIFI_INTERFACE=wlan0   # use this if you have a special wireless interface
                        # that is linked to the real $INTERFACE

#WIFI_WAIT=5            # seconds to wait for the wireless card to
                        # associate before bringing the interface up

#USEWPA="yes"           # start wpa_supplicant with the profile
#WPAOPTS=""             # use "" for normal operation or specify additional
                        # options (eg, "-D ipw")
                        # see /etc/wpa_supplicant.conf for configuration

Of course, you would need to change all the details, but hopefully what I'm getting at is clear. For the example profile, I just took the template and added additional INTERFACE and IFOPTS lines, and prefixed the quoted value of each IFOPTS line with the interface name it configured. Theoretically, eth0 would be a normal lan connection with a static IP and eth1 a dhcp configured wireless interface, but it really doesn't matter - I just wanted to put in one of each for thoroughness' sake.

Hopefully I'm not way off base with this.

Offline

Board footer

Powered by FluxBB