Skip to content

Commit

Permalink
Add script to setup external bridge
Browse files Browse the repository at this point in the history
This script can be used to setup an external bridge
and add physical NIC to it so that one can expose
OSv IP on LAN.

This script would normally be executed before
scripts/run.py or scripts/firecracker.py which would
then receive name of the bridge (ie virbr1) as a -b
parameter.

Signed-off-by: Waldemar Kozaczuk <[email protected]>
  • Loading branch information
wkozaczuk committed Mar 25, 2019
1 parent 8cd7d8a commit e36de53
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions scripts/setup-external-bridge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# This script setup a bridge that binds physical NIC
# to it and allows exposing OSv guest IP on external network

if [[ $(whoami) != "root" ]]; then
echo "This script needs to be run as root!"
exit -1
fi

NIC_NAME=$1
if [[ "$NIC_NAME" == "" ]]; then
echo "Usage: ./scripts/setup-external-bridge.sh <NIC_NAME> <BRIDGE_NAME> (optional)"
exit -1
fi

BRIDGE_NAME=$2
if [[ "$BRIDGE_NAME" == "" ]]; then
BRIDGE_NAME="virbr1"
fi

ip addr flush dev $NIC_NAME # Clear IP address on physical ethernet device
brctl addbr $BRIDGE_NAME # Create bridge
brctl addif $BRIDGE_NAME $NIC_NAME # Add physical ethernet device to bridge
sysctl -q -w net.ipv6.conf.$BRIDGE_NAME.disable_ipv6=1
dhclient -v $BRIDGE_NAME # Grab IP addres from DHCP server
echo "Setup bridge: $BRIDGE_NAME"

0 comments on commit e36de53

Please sign in to comment.