tools/deployment/libvirt/setup_network.sh
Felipe de Jesus Ruiz Garcia 6e0fbcfd89 Update network command setup_network.sh
ifconfig and brctl are deprecated commands.
They are replaced with ip command.

Story: 2004646
Task: 28598

Change-Id: I4a9b63f5437fc9372a169216ee62f239bce55b3c
Signed-off-by: Felipe de Jesus Ruiz Garcia <felipe_57@live.com.mx>
Signed-off-by: Felipe de Jesus Ruiz Garcia <felipe.de.jesus.ruiz.garcia@intel.com>
2018-12-20 02:46:04 -05:00

40 lines
942 B
Bash
Executable File

#!/usr/bin/env bash
usage() {
echo "$0 [-h]"
echo ""
echo "Options:"
# echo " -i: StarlingX ISO image"
echo ""
}
while getopts "i:" o; do
case "${o}" in
*)
usage
exit 1
;;
esac
done
shift $((OPTIND-1))
BRIDGE_INTERFACE=${BRIDGE_INTERFACE:-stxbr}
EXTERNAL_NETWORK=${EXTERNAL_NETWORK:-10.10.10.0/24}
EXTERNAL_IP=${EXTERNAL_IP:-10.10.10.1/24}
if [[ -r /sys/class/net/${BRIDGE_INTERFACE}1 ]]; then
echo "${BRIDGE_INTERFACE}1 exists, cowardly refusing to overwrite it, exiting..."
exit 1
fi
for i in {1..4}; do
sudo ip link add ${BRIDGE_INTERFACE}$i type bridge
done
sudo ip addr add $EXTERNAL_IP dev ${BRIDGE_INTERFACE}1
sudo ip link set ${BRIDGE_INTERFACE}1 up
sudo ip link set ${BRIDGE_INTERFACE}2 up
sudo ip link set ${BRIDGE_INTERFACE}3 up
sudo ip link set ${BRIDGE_INTERFACE}4 up
sudo iptables -t nat -A POSTROUTING -s $EXTERNAL_NETWORK -j MASQUERADE