Skip to content

Commit

Permalink
feat: Check network interface
Browse files Browse the repository at this point in the history
* feat: Check network interface
  • Loading branch information
kroese authored Dec 28, 2023
1 parent 8860126 commit 218cd8d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ configureDHCP() {
return 0
}

configureDNS () {
configureDNS() {

# dnsmasq configuration:
DNSMASQ_OPTS="$DNSMASQ_OPTS --dhcp-range=$VM_NET_IP,$VM_NET_IP --dhcp-host=$VM_NET_MAC,,$VM_NET_IP,$VM_NET_HOST,infinite --dhcp-option=option:netmask,255.255.255.0"
Expand All @@ -91,7 +91,7 @@ configureDNS () {
return 0
}

configureNAT () {
configureNAT() {

# Create a bridge with a static IP for the VM guest

Expand Down Expand Up @@ -162,7 +162,7 @@ configureNAT () {
return 0
}

closeNetwork () {
closeNetwork() {

exec 30<&- || true
exec 40<&- || true
Expand Down Expand Up @@ -211,6 +211,11 @@ fi
update-alternatives --set iptables /usr/sbin/iptables-legacy > /dev/null
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy > /dev/null

if [ ! -d "/sys/class/net/$VM_NET_DEV" ]; then
error "Network interface $VM_NET_DEV does not exist inside the container!"
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 27
fi

VM_NET_MAC="${VM_NET_MAC//-/:}"
GATEWAY=$(ip r | grep default | awk '{print $3}')
IP=$(ip address show dev "$VM_NET_DEV" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/)
Expand Down

0 comments on commit 218cd8d

Please sign in to comment.