
Am 17.01.2014 14:02, schrieb Robert Schweikert:
Hi Marius, Hi!
As you know with newer incarnations of udev/systemd the network devices are enumerated differently, getting names such as enp5s0 or whatever.
This makes it difficult for appliances to setup a network configuration. For example previously when eth0 names were used we could simply add ifcfg-eth0 in /etc/sysconfig/network configure it for dhcp and no matter what the first device was it would be setup with dhcp and the network was up and running.
This obviously doesn't work anymore as we cannot predict the name of the first, or any interface for that matter.
Does wicked have a solution for this problem? i.e. is the some way to setup a rule that says "make one of the available interfaces run with dhcp"
What do you expect that wicked makes? :-) It does not write any configuration, but is simply using it. Wicked can match interfaces by pci-bus, mac address, ... [some code is there, but IMO not complete to catch all cases, e.g. s390] -- at least in its native mode, which we currently are *not* using. On SLES-10 we were using "ifcfg-eth-bus-pci-0000:00:19.0..." or "ifcfg- eth-id-$mac" as configuration names. Such ifcfg files are not supported. Further, this is IMO _not_ a solution but just moves the problem. Instead to detect the interface name, you have to detect the correct way to match an interface and create a config containing a the match [what is much more complex than to just find the name]. IMO there is no "golden solution". Basically you have the choice between 1) and 2) bellow. 1) Use systemd names, detect & create configs in the initial boot -- after systemd renamed it to its name. Just some dummy illustration, which I wrote here -- untested: #!/bin/bash get_netcard_ifnames() { while read ifname more ; do test "X echo "$ifname" done < <(hwinfo --netcard --short | grep -v "^network") } generate_net_config() { local ifname=$1 local mode=$2 local ipaddr=$3 local gwaddr=$4 { #echo "STARTMODE='hotplug'" echo "STARTMODE='auto'" case $mode in dhcp4|dhcp6|dhcp|static) echo "BOOTPROTO=$mode" ;; esac case $mode in static) test -n "$ipaddr" && echo "IPADDR='$ipaddr'" ;; test -n "$gwaddr" && { echo "default $gwaddr - -" \ > "/etc/sysconfig/network/ifroute-$ifname" } ;; esac } > "/etc/sysconfig/network/ifcfg-$ifname" } count=0 for ifname in `get_netcard_ifnames 2>/dev/null` ; do ### test is_ibft "$ifname" && continue # no config needed ### test is_usable_for_me "$ifname" || continue ((count++ == 0)) || break generate_net_config "$ifname" "${mode:-dhcp}" done 2) Don't use systemd names but "custom" name schema, which is also supported by systemd/udevd [except something changed here again] for compatibility / as fallback / when you don't like the names. Provide an udev rule renaming interfaces to e.g. "nic0", "nic1" Using "eth0" is not a good idea as _this_ is causing problems; renaming to "nic0" is not a problem -- systemd renames too. This is the SLES-11 way, the logic to write the rules were in udev-persistent-net-name generator and in yast2. Generation is AFAIK dropped from both as obsoleted. The rules [once written] are still supported. Problem: you have write rule / to provide logic to match the interface you want in an udev rule. 3) Reintroduce own matches by pci-bus, mac address, ... SLES-9 and SLES-10 were using it (getcfg); support has been dropped on SLES-11, obsoleted by udev rules. Problem: you have to provide logic matching the interface you want and a "translation tool" (getcfg on SLES-10) to translate a configuration to ifname and back (!!!). Problem: Patch every peace of software to use the "translation tool", that is wicked [it does not support such ifcfg files], firewall, dhcp and any other daemon using "bind-to-device" or needing the name for whatever. Gruesse / Regards, Marius Tomaschewski <mt@suse.de>, <mt@suse.com> -- SUSE LINUX Products GmbH, HRB 16746 (AG Nürnberg), GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, Maxfeldstraße 5, 90409 Nürnberg, Germany -- To unsubscribe, e-mail: wicked-devel+unsubscribe@opensuse.org To contact the owner, e-mail: wicked-devel+owner@opensuse.org