Make vlan optional

This commit is contained in:
Kroese 2023-05-07 13:10:53 +02:00 committed by GitHub
parent f4a2a77314
commit 659b59e9b1

View File

@ -29,9 +29,11 @@ configureDHCP() {
{ ip link add link "${VM_NET_DEV}" "${VM_NET_VLAN}" type macvlan mode bridge 2> /dev/null ; rc=$?; } || : { ip link add link "${VM_NET_DEV}" "${VM_NET_VLAN}" type macvlan mode bridge 2> /dev/null ; rc=$?; } || :
if (( rc != 0 )); then if (( rc != 0 )); then
echo -n "ERROR: Capability NET_ADMIN has not been set ($rc/1). Please add the "
echo "following docker setting to your container: --cap-add NET_ADMIN" && exit 15 { ip link add link "${VM_NET_DEV}" "${VM_NET_VLAN}" type macvlan mode bridge ; } || :
fi echo -n "INFO: Could not create macvlan, skipping..."
else
ip address add "${IP}" dev "${VM_NET_VLAN}" ip address add "${IP}" dev "${VM_NET_VLAN}"
ip link set dev "${VM_NET_VLAN}" up ip link set dev "${VM_NET_VLAN}" up
@ -42,6 +44,8 @@ configureDHCP() {
ip route add "${NETWORK}" dev "${VM_NET_VLAN}" metric 0 ip route add "${NETWORK}" dev "${VM_NET_VLAN}" metric 0
ip route add default via "${GATEWAY}" ip route add default via "${GATEWAY}"
fi
{ ip link add link "${VM_NET_DEV}" name "${VM_NET_TAP}" address "${VM_NET_MAC}" type macvtap mode bridge 2> /dev/null ; rc=$?; } || : { ip link add link "${VM_NET_DEV}" name "${VM_NET_TAP}" address "${VM_NET_MAC}" type macvtap mode bridge 2> /dev/null ; rc=$?; } || :
if (( rc != 0 )); then if (( rc != 0 )); then