This is a compilation of 2 discussions on these forums:
Thanks to @asl and @jstammi for doing great work on this topic!
-
add a file for your dummy interface in /etc/sysconfig/network-scripts/ let’s call it ifcfg-dummy0
-
the kernel module dummy (which is need for dummy devices) is not loaded per default, so we need to add this during server start. Ceate a file dummy.conf inside /etc/modules-load.d. This file includes the word dummy only!
If you reboot the server now, you will see the result with e.g. ifconfig and you are able to ping yourself:
-
You will recognize, that your new interafce dummy0 is still missing in WEB-GUI. Thanks to @jstammi I found the solution here: https://community.nethserver.org/t/virtual-network-interface-for-virtual-machines/7728
I had to patch my /usr/libexec/nethserver/nic-info file. After my next server reboot the NIC is present in the dashboard and I could set up the correct green and red roles under Network. The final result:
The DIFF file reads like:
57,59c57,64
< if ! [ -e /sys/class/net/${card}/device ]; then
< continue
< fi
---
> # NO IDEA, WHY, but with passing the dummy interfaces only, they cannot be
> # configured but deleted only. Letting pass the 2nd virtual nic things
> # can be configured again ... strange, very strange.
> # if ! [ -e /sys/class/net/${card}/device ]; then
> # if [ -z "$(ip link show ${card} type dummy)" ] ; then
> # continue
> # fi
> # fi
79,80c84,89
< driver=`basename $(ls -l /sys/class/net/$card/device/driver | awk '{print$NF}' )`
< type=`basename $(ls -l /sys/class/net/$card/device/subsystem | awk '{print$NF}' )`
---
> if [ -r /sys/class/net/$card/device/driver ] ; then
> driver=`basename $(ls -l /sys/class/net/$card/device/driver | awk '{print$NF}' )`
> fi
> if [ -r /sys/class/net/$card/device/subsystem ] ; then
> type=`basename $(ls -l /sys/class/net/$card/device/subsystem | awk '{print$NF}' )`
> fi
The full modified /usr/libexec/nethserver/nic-info script reads like:
#!/bin/bash
#
# Copyright (C) 2015 Nethesis S.r.l.
# http://www.nethesis.it - nethserver@nethesis.it
#
# This script is part of NethServer.
#
# NethServer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# NethServer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NethServer. If not, see COPYING.
#
if [ "x${1}" == "x" ]; then
cards=($(ls -A -1 /sys/class/net))
else
cards=($1)
fi
for card in ${cards[@]}; do
hwaddr=
type=
model=
driver=
speed=
link=
# Error on non-existing devices
if ! [ -e "/sys/class/net/${card}" ]; then
echo "[ERROR] nic-info: interface ${card} does not exist" 1>&2
exit 1
fi
# Skip non-link elements:
if ! [ -L "/sys/class/net/${card}" ]; then
continue;
fi
# Skip non-Ethernet physical devices (type=1)
if [ "$(cat /sys/class/net/${card}/type)" != "1" ]; then
continue
fi
#
# FIXME: Skip virtual devices
# "device" links may not work in future kernel versions
#
if ! [ -e /sys/class/net/${card}/device ]; then
continue
fi
# Skip bridge and tun/tap
if [ -e /sys/class/net/${card}/brforward ] || [ -e /sys/class/net/${card}/tun_flags ]; then
continue
fi
if [ -d /sys/class/net/${card}/master ] && [ ! -d /sys/class/net/${card}/brport ]; then
link=`/bin/readlink /sys/class/net/${card}/master`
bond=`basename $link`
hwaddr=`/usr/libexec/nethserver/bond-slave-mac ${bond} ${card}`
else
hwaddr=`cat /sys/class/net/${card}/address`
fi
# Skip if mac is not valid (00:00... or FF:FF...)
if [ "${hwaddr}" == "00:00:00:00:00:00" ] || [ "${hwaddr}" == "ff:ff:ff:ff:ff:ff" ]; then
continue
fi
driver=`basename $(ls -l /sys/class/net/$card/device/driver | awk '{print$NF}' )`
type=`basename $(ls -l /sys/class/net/$card/device/subsystem | awk '{print$NF}' )`
# Default if not avaiable in /sys/class/net
if [ "a$type" == "a" ]; then
type="???"
fi
if [ "a$driver" == "a" ]; then
driver="Unknown Network Interface ($card)"
fi
model=$type
# Get more details for pci and usb devices
if [ "$type" == "pci" ]; then
model=`/sbin/lspci -s $(basename $(ls -l /sys/class/net/$card/device | awk '{print$NF}' )) | cut -d':' -f3 | cut -c 2-`
fi
if [ "$type" == "usb" ]; then
bus=`grep DEVICE= /sys/class/net/$card/device/uevent | cut -d"/" -f5`
dev=`grep DEVICE= /sys/class/net/$card/device/uevent | cut -d"/" -f6`
# work around the base8 convert
let bus=`echo 1$bus`-1000
let dev=`echo 1$dev`-1000
model=`/bin/lsusb -s $bus:$dev | cut -d':' -f3 | cut -c 6-`
fi
link=$(cat /sys/class/net/$card/carrier 2>/dev/null)
if [ $? != 0 ]; then
/sbin/ip link set $card up 2>/dev/null
link=$(cat /sys/class/net/$card/carrier 2>/dev/null)
speed=$(cat /sys/class/net/$card/speed 2>/dev/null)
/sbin/ip link set $card down 2>/dev/null
else
speed=$(cat /sys/class/net/$card/speed 2>/dev/null)
fi
echo $card,${hwaddr//,/ },${type//,/ },${model//,/ },${driver//,/ },$speed,$link
done
Keep in mind that the MACADDRESS of the new dummy interface is changing every time you reboot. I didn’t notice any problems with that on my VPS with Samba4 AD account provider installed.