Compare commits

..

7 Commits

@ -29,20 +29,19 @@ List of tested platforms only:
| Platform | Versions | | Platform | Versions |
|---------------------------------|------------------------------------------| |---------------------------------|------------------------------------------|
| AlmaLinux | 8, 9 | | AlmaLinux | 8, 9 |
| Alpine Linux | 3.13, 3.14, 3.15 | | Alpine Linux | 3.15, 3.16, 3.17 |
| ALT Linux | 9, 10, Sisyphus | | ALT Linux | 9, 10, Sisyphus |
| Amazon Linux | 2 | | Amazon Linux | 2 |
| CentOS | 7, 8 Stream | | CentOS | 7, 8 Stream |
| Debian | 10, 11, 12 | | Debian | 10, 11, 12 |
| Devuan | 2 | | Devuan | 3,4 |
| Fedora | 34, 35 | | Fedora | 36, 37 |
| FreeBSD | 12, 13 | | FreeBSD | 12, 13 |
| MSVSphere | 8, 9 |
| openSUSE | 15 | | openSUSE | 15 |
| Oracle Linux | 7, 8 | | Oracle Linux | 7, 8, 9 |
| Red Hat Enterprise Linux | 7, 8, 9 | | Red Hat Enterprise Linux | 7, 8, 9 |
| Rocky Linux | 8 | | Rocky Linux | 8,9 |
| Ubuntu | 16.04, 18.04, 20.04, 21.10, 22.04 | | Ubuntu | 18.04, 20.04, 22.04 |
| Ubuntu Minimal | 20.04, 22.04 | | Ubuntu Minimal | 20.04, 22.04 |
(the packages might work on other versions or flavours, but those aren't tested) (the packages might work on other versions or flavours, but those aren't tested)
@ -78,20 +77,20 @@ Following IPv6 configuration methods are supported via NIC attribute `IP6_METHOD
Selectable configuration types and IP configuration methods are **supported only on the following platforms**: Selectable configuration types and IP configuration methods are **supported only on the following platforms**:
| Platform | Network Type (`NETCFG_TYPE`) | | Platform | Network Type (`NETCFG_TYPE`) |
|-----------------------------------------------------------------|-------------------------------------------| |---------------------------------------------------------------|-------------------------------------------|
| Alpine Linux 3.14+ | `interfaces` | | Alpine Linux 3.15+ | `interfaces` |
| ALT Linux p10, Sisyphus | `networkd`, `nm` | | ALT Linux p10, Sisyphus | `networkd`, `nm` |
| Amazon Linux 2 | `scripts` | | Amazon Linux 2 | `scripts` |
| Debian 10+ | `interfaces`, `netplan`, `nm`, `networkd` | | Debian 10+ | `interfaces`, `netplan`, `nm`, `networkd` |
| Devuan 2 | `interfaces` | | Devuan 3 | `interfaces` |
| Fedora 34+ | `scripts`, `nm`, `networkd` | | Fedora 36+ | `scripts`, `nm`, `networkd` |
| FreeBSD 12+ | `bsd` | | FreeBSD 12+ | `bsd` |
| openSUSE 15 | `scripts` | | openSUSE 15 | `scripts` |
| RHEL-like 7 (CentOS, Oracle Linux) | `scripts` | | RHEL-like 7 (CentOS, Oracle Linux) | `scripts` |
| RHEL-like 8 (CentOS, Oracle/Rocky/AlmaLinux/MSVSphere) | `scripts`, `nm`, `networkd` | | RHEL-like 8 (CentOS, Oracle/Rocky/AlmaLinux) | `scripts`, `nm`, `networkd` |
| RHEL-like 9 (CentOS Stream 9, Oracle/Rocky/AlmaLinux/MSVSphere) | `nm`, `networkd` | | RHEL-like 9 (CentOS Stream 9, Oracle/Rocky/AlmaLinux) | `nm`, `networkd` |
| Ubuntu 18.04, 20.04, 21.10, 22.04 | `interfaces`, `netplan`, `nm`, `networkd` | | Ubuntu 18.04, 20.04, 22.04 | `interfaces`, `netplan`, `nm`, `networkd` |
(other than listed platforms are not supported for using `NETCFG_TYPE` nor `METHOD`/`IP6_METHOD`!): (other than listed platforms are not supported for using `NETCFG_TYPE` nor `METHOD`/`IP6_METHOD`!):

@ -41,7 +41,7 @@ fi
### ###
VERSION=${VERSION:-6.6.0} VERSION=${VERSION:-6.6.1}
RELEASE=${RELEASE:-1} RELEASE=${RELEASE:-1}
MAINTAINER=${MAINTAINER:-OpenNebula Systems <contact@opennebula.io>} MAINTAINER=${MAINTAINER:-OpenNebula Systems <contact@opennebula.io>}
LICENSE=${LICENSE:-Apache 2.0} LICENSE=${LICENSE:-Apache 2.0}

@ -39,7 +39,7 @@ if [ -z "${NETCFG_TYPE}" ] ; then
debian|devuan|ubuntu) debian|devuan|ubuntu)
NETCFG_TYPE='interfaces netplan nm networkd' NETCFG_TYPE='interfaces netplan nm networkd'
;; ;;
fedora|centos|rhel|almalinux|ol|rocky|msvsphere) fedora|centos|rhel|almalinux|ol|rocky)
NETCFG_TYPE='scripts nm networkd' NETCFG_TYPE='scripts nm networkd'
;; ;;
opensuse*|sles|sled) opensuse*|sles|sled)

@ -571,3 +571,35 @@ gen_resolvconf()
sed -i "/^NETCONFIG_DNS_STATIC_SEARCHLIST=/ s/=.*$/=\"${all_search_domains}\"/" /etc/sysconfig/network/config sed -i "/^NETCONFIG_DNS_STATIC_SEARCHLIST=/ s/=.*$/=\"${all_search_domains}\"/" /etc/sysconfig/network/config
fi fi
} }
# Space separate source, destination and output interface of a route
get_route_info() {
route=$1
# Remove whitespaces beginning and end
route=$(echo "$route" | sed 's/^[[:space:]]*//')
route=$(echo "$route" | sed 's/[[:space:]]*$//')
# Parse traffic source, destination and outgoing interface
dst=$(echo "$route" | cut -d ' ' -f 1)
if [[ "$route" == *"via"* ]]; then
gw=${route##*" via "}
gw=${gw%" dev"*}
else
gw=''
fi
if [[ "$route" == *"dev"* ]]; then
iface=${route##*" dev "}
else
iface=''
fi
echo "$dst $gw $iface"
}
# 0 if https://en.wikipedia.org/wiki/Link-local_address
is_link_local() {
[[ $1 == "169.254."* ]]
}

@ -117,8 +117,59 @@ gen_iface_conf()
### ###
routes_conf_path="/etc/rc.conf.d/routing"
if [ -n "${gateway}" ]; then if [ -n "${gateway}" ]; then
echo "defaultrouter=\"${gateway}\"" >> /etc/rc.conf.d/routing echo "defaultrouter=\"${gateway}\"" >> $routes_conf_path
fi
# Add static routes
# static_routes="lan mumoffice foo"
# route_lan="-net 192.168.1.0/24 192.168.1.254"
# route_mumoffice="-net 10.0.0.0/8 10.30.110.5"
# route_foo="-host 169.254.1.1 -iface lo0"
route_names=""
if [ -n "${ROUTES}" ]; then
IFS=',' read -r -a routes <<< "$ROUTES"
routes_conf=()
for index in "${!routes[@]}"
do
route_name="lan${index}"
route_names="${route_names}${route_name} "
IFS=' ' read -r -a route_info <<< "$(get_route_info "${routes[index]}")"
dst=${route_info[0]}
gw=${route_info[1]}
iface=${route_info[2]}
route_conf="${route_name}=\"-net${dst} ${gw}\""
[ -n "${iface}" ] && route_conf=" ${route_conf} -iface ${dev}"
routes_conf+=(route_conf)
done
echo -e "static_routes=\"${route_names}\"\n" >> $routes_conf_path
for route_conf in "${routes_conf[@]}"
do
echo -e "$route_conf\n" >> $routes_conf_path
done
fi
# Add ONEGATE Proxy static route
if is_link_local "${ONEGATE_ENDPOINT}"; then
route_name="onegateproxy"
sed -i "s/${route_names}/${route_names} ${route_name}/g" "$routes_conf_path"
# ip route replace 169.254.16.9/32 via eth0
route_conf="route_${route_name}=\"-host ${ONEGATE_ENDPOINT} -iface ${dev}\""
echo -e "$route_conf\n" >> $routes_conf_path
fi fi
} }

@ -158,6 +158,27 @@ EOT
fi fi
fi fi
# Add static routes
if [ -n "${ROUTES}" ]; then
IFS=',' read -r -a routes <<< "$ROUTES"
for route in "${routes[@]}"
do
# Apply every route except the ones specified for other devices
if [[ "$route" == *"${dev}"* ]] || [[ "$dev" == "eth0" && "$route" != *"dev"* ]]; then
echo " up ip route add $route"
fi
done
fi
# Add ONEGATE Proxy static route
if is_link_local "${ONEGATE_ENDPOINT}"; then
# ip route replace 169.254.16.9/32 via eth0
echo " up ip route replace ${ONEGATE_ENDPOINT}/32 via ${dev}"
fi
if [ -n "$mtu" ]; then if [ -n "$mtu" ]; then
echo " mtu ${mtu}" echo " mtu ${mtu}"
fi fi

@ -135,6 +135,8 @@ gen_routes()
via: ${gateway} via: ${gateway}
EOT EOT
# Force default Linux IPv4 metric (man 8 route) to override # Force default Linux IPv4 metric (man 8 route) to override
# automatic metrics calculation done by NetworkManager and unify # automatic metrics calculation done by NetworkManager and unify
# behavior among different renderers. # behavior among different renderers.
@ -145,6 +147,40 @@ EOT
fi fi
fi fi
# Add static routes
if [ -n "${ROUTES}" ]; then
IFS=',' read -r -a routes <<< "$ROUTES"
for route in "${routes[@]}"
do
# Apply every route except the ones specified for other devices
if [[ "$route" == *"${dev}"* ]] || [[ "$dev" == "eth0" && "$route" != *"dev"* ]]; then
IFS=' ' read -r -a route_info <<< "$(get_route_info "$route")"
dst=${route_info[0]}
gw=${route_info[1]}
cat <<EOT
- to: "${dst}"
via: "${gw}"
EOT
fi
done
fi
# Add ONEGATE Proxy static route
if is_link_local "${ONEGATE_ENDPOINT}"; then
# ip route replace 169.254.16.9/32 via eth0
echo " up ip route replace ${ONEGATE_ENDPOINT}/32 via ${dev}"
cat <<EOT
- to: "${ONEGATE_ENDPOINT}"
scope: link
EOT
fi
if [ -n "${ip6_gateway}" ] && { [ -z "${ip6_method}" ] || [ "${ip6_method}" = 'static' ]; }; then if [ -n "${ip6_gateway}" ] && { [ -z "${ip6_method}" ] || [ "${ip6_method}" = 'static' ]; }; then
cat <<EOT cat <<EOT
- to: "::/0" - to: "::/0"

@ -120,6 +120,42 @@ EOT
fi fi
echo "" echo ""
# Add static routes
if [ -n "${ROUTES}" ]; then
cat <<EOT
[Route]
EOT
IFS=',' read -r -a routes <<< "$ROUTES"
for route in "${routes[@]}"
do
# Apply every route except the ones specified for other devices
if [[ "$route" == *"${dev}"* ]] || [[ "$dev" == "eth0" && "$route" != *"dev"* ]]; then
IFS=' ' read -r -a route_info <<< "$(get_route_info "$route")"
dst=${route_info[0]}
gw=${route_info[1]}
echo "Gateway=$gw"
echo "Destination=$dst"
fi
done
echo ""
fi
# Add ONEGATE Proxy static route
if is_link_local "${ONEGATE_ENDPOINT}"; then
cat <<EOT
[Route]
EOT
# ip route replace 169.254.16.9/32 via eth0
echo " up ip route replace ${ONEGATE_ENDPOINT}/32 via ${dev}"
echo "Destination=${ONEGATE_ENDPOINT}"
echo "Scope=link"
fi
} }
gen_dhcp_conf() gen_dhcp_conf()

@ -119,6 +119,33 @@ gen_iface_conf()
nmcli con mod "${dev}" ipv4.gateway "" nmcli con mod "${dev}" ipv4.gateway ""
fi fi
# Add static routes
if [ -n "${ROUTES}" ]; then
IFS=',' read -r -a routes <<< "$ROUTES"
for route in "${routes[@]}"
do
IFS=' ' read -r -a route_info <<< "$(get_route_info "$route")"
dst=${route_info[0]}
gw=${route_info[1]}
# Apply every route except the ones specified for other devices
if [[ "$route" == *"${dev}"* ]] || [[ "$dev" == "eth0" && "$route" != *"dev"* ]]; then
nmcli con mod "$dev" ipv4.routes "$dst" "$gw"
fi
done
fi
# Add ONEGATE Proxy static route
if is_link_local "${ONEGATE_ENDPOINT}"; then
# ip route replace 169.254.16.9/32 via eth0
echo " up ip route replace ${ONEGATE_ENDPOINT}/32 via ${dev}"
nmcli con mod "$dev" ipv4.routes "$dst" type=local
fi
if [ -n "$metric" ]; then if [ -n "$metric" ]; then
nmcli con mod "${dev}" ipv4.route-metric "${metric}" nmcli con mod "${dev}" ipv4.route-metric "${metric}"
else else

@ -124,6 +124,31 @@ EOT
fi fi
fi fi
# Add static routes
if [ -n "${ROUTES}" ]; then
IFS=',' read -r -a routes <<< "$ROUTES"
for route in "${routes[@]}"
do
# The route is targeted to the $dev iface
if [[ "$route" == *"${dev}"* ]]; then
echo "$route" >> "${config_path}/route-${dev}"
# The route with no target iface will be set to eth0
elif [[ "$dev" == "eth0" && "$route" != *"dev"* ]]; then
echo "$route" >> "${config_path}/route-eth0"
fi
done
fi
# Add ONEGATE Proxy static route
if is_link_local "${ONEGATE_ENDPOINT}"; then
# ip route replace 169.254.16.9/32 via eth0
route="${ONEGATE_ENDPOINT}/32 via ${dev}"
echo "$route" >> "${config_path}/route-${dev}"
fi
if [ -n "${mtu}" ]; then if [ -n "${mtu}" ]; then
echo "MTU=${mtu}" echo "MTU=${mtu}"
fi fi

@ -513,7 +513,7 @@ syscheck()
debian|ubuntu|devuan) debian|ubuntu|devuan)
return 0 return 0
;; ;;
fedora|centos|rhel|almalinux|ol|rocky|amzn|msvsphere) fedora|centos|rhel|almalinux|ol|rocky|amzn)
return 0 return 0
;; ;;
opensuse*|sles|sled) opensuse*|sles|sled)
@ -553,7 +553,7 @@ enter_single_mode()
return 0 return 0
fi fi
;; ;;
debian|ubuntu|devuan|fedora|centos|rhel|almalinux|ol|rocky|msvsphere|altlinux|opensuse*) debian|ubuntu|devuan|fedora|centos|rhel|almalinux|ol|rocky|altlinux|opensuse*)
_runlevel=$(runlevel | cut -d" " -f2) _runlevel=$(runlevel | cut -d" " -f2)
case "$_runlevel" in case "$_runlevel" in
1|S) 1|S)
@ -589,7 +589,7 @@ enter_single_mode()
msg "Entering single user mode..." msg "Entering single user mode..."
rc single rc single
;; ;;
debian|ubuntu|devuan|fedora|centos|rhel|almalinux|ol|rocky|msvsphere|altlinux|opensuse*) debian|ubuntu|devuan|fedora|centos|rhel|almalinux|ol|rocky|altlinux|opensuse*)
ask_to_enter_single_user_mode ask_to_enter_single_user_mode
msg "Entering single user mode..." msg "Entering single user mode..."
telinit 1 telinit 1

Loading…
Cancel
Save