You are not logged in.

#1 2011-06-09 13:26:19

Kaldellin
Member
Registered: 2011-06-09
Posts: 2

Correct syntax for 2 interfaces in one netcfg profile?

Hi.
Apparently I can't define both eth0 and eth1 in just rc.conf anymore so I put them in two netcfg profiles. After little tinkering I got them to working fine, but I'd like to combine them in one profile. According netcfg manpage it is possible to define more than one connection in one profile but I cant find any info on what is the correct syntax for that, not in netcfg wikipage or manpage. Also all the examples only configure one connection.
Here are my profiles:

oma-dhcp:

CONNECTION='ethernet'
DESCRIPTION='A basic dhcp ethernet connection using iproute'
INTERFACE='eth0'
IP='dhcp'

oma-static:

CONNECTION='ethernet'
DESCRIPTION='A basic static ethernet connection using iproute'
INTERFACE='eth1'
IP='static'
ADDR='192.168.100.110'
#GATEWAY='192.168.100.1'
#DNS=('192.168.100.2')

As you can see, those aren't anything special. Any help would be apreciated.

Offline

#2 2011-06-10 16:32:38

Kaldellin
Member
Registered: 2011-06-09
Posts: 2

Re: Correct syntax for 2 interfaces in one netcfg profile?

Well it did occur to me how to do it one way from the wiki.

oma-dhcp:

CONNECTION='ethernet'
DESCRIPTION='A basic dhcp ethernet connection using iproute'
INTERFACE='eth0'
IP='dhcp'
PRE_UP="ip addr add 192.168.100.110/24 dev eth1; ip link set eth1 up"

But I would really like if there were cleaner way to do it. Won't mark solved because i still would like to get comments on this.

Offline

#3 2011-06-18 12:01:17

0mark
Member
From: earth
Registered: 2010-06-09
Posts: 162
Website

Re: Correct syntax for 2 interfaces in one netcfg profile?

I have a likely problem. According to the man page, it seems possible:

 It is also capable of starting/stopping many to one connections, that is,
multiple connections within the same profile, optionally with bonding.

But i did not found out how to do this yet.

*edit*

I have looked at the source, but did not get enlighted. So i tried to make a connection module for such cases (it starts a list of profiles in order, stops on errors and brings the already startet profiles down again):

#! /bin/bash

. /usr/lib/network/network

multiple_up() {
    load_profile "$1"
    UPPED=""
    for PROFILE in $MULTIPLE_LIST; do
       echo "Trying Profile $PROFILE..."
       (eval profile_up $PROFILE);
       if [[ $? -ne 0 ]]; then
          report_fail "$PROFILE failed, bringing all down..."
          MULTIPLE_LIST=$UPPED
          multiple_down
          exit 1
       fi
       UPPED="$UPPED $PROFILE"
    done
}

multiple_down() {
    load_profile "$1"
    ML_INVERS=""
    for PROFILE in $MULTIPLE_LIST; do
       if check_profile "$PROFILE"; then
          ML_INVERSE="$PROFILE $ML_INVERSE"
       fi
    done
    for PROFILE in $ML_INVERSE; do
       echo "Trying Profile $PROFILE..."
       (eval profile_down $PROFILE);
    done
}

multiple_$1 "$2"
exit $?
# vim: ft=sh ts=4 et sw=4:

Here is a example profile:

CONNECTION="multiple"
INTERFACE="ignore-multiple"
MULTIPLE_LIST="uhhwpa unvpn"

The Script has quite some problems. First, when using netcfg -a it fails.
And it has some strange behaviour:

root /etc/network.d # netcfg uhhvpn 
:: uhhvpn up                                                                                                                                                     [BUSY] 
Trying Profile uhhwpa...
:: uhhwpa up                                                                                                                                                     [BUSY] 
                                                                                                                                                                 [DONE] 
Trying Profile unvpn...
:: unvpn up                                                                                                                                                      [DONE] 
                                                                                                                                                                 [DONE]

The lines beginning with "::" are from the main network script, while the lines beginning with "Trying" are from my module. The first ones are appearing instantly and in the wrong order, while the scripts starts them one after another and the first profile stakes some time to start. The second ones appearing in the right order, and with delay it tooks the first profile to start. I do not understand that, but i think there might be some forking or stuff occuring.
Anyway, it works for me.

Last edited by 0mark (2011-06-18 13:18:24)


Ceterum autem censeo Systemdinem esse delendam

Offline

Board footer

Powered by FluxBB