diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 0000000..5f42303 --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,6 @@ +{ + "name": "dsm", + "service": "dsm", + "forwardPorts": ["5000"], + "dockerComposeFile": "compose.yml" +} diff --git a/src/network.sh b/src/network.sh index a0a8ead..1d3e85c 100644 --- a/src/network.sh +++ b/src/network.sh @@ -170,7 +170,7 @@ getHostPorts() { configureUser() { - NET_OPTS="-netdev user,id=hostnet0,host=${VM_NET_IP%.*}.1,net=${VM_NET_IP%.*}.0/24,dhcpstart=$VM_NET_IP,hostname=$VM_NET_HOST" + NET_OPTS="-netdev user,id=hostnet0,host=${VM_NET_IP%.*}.2,net=${VM_NET_IP%.*}.0/24,dhcpstart=$VM_NET_IP,hostname=$VM_NET_HOST" local forward forward=$(getUserPorts "$USER_PORTS") @@ -365,9 +365,15 @@ getInfo() { 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 + error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 26 fi + BASE_IP="${VM_NET_IP%.*}." + + if [ "${VM_NET_IP/$BASE_IP/}" -lt "3" ]; then + error "Invalid VM_NET_IP, must end in a higher number than .3" && exit 27 + fi + if [ -z "$MTU" ]; then MTU=$(cat "/sys/class/net/$VM_NET_DEV/mtu") fi @@ -436,7 +442,10 @@ if [[ "$DEBUG" == [Yy1]* ]]; then line="Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC MTU: $mtu" [[ "$MTU" != "0" ]] && [[ "$MTU" != "$mtu" ]] && line+=" ($MTU)" info "$line" - [ -f /etc/resolv.conf ] && grep '^nameserver*' /etc/resolv.conf + if [ -f /etc/resolv.conf ]; then + nameservers=$(grep '^nameserver*' /etc/resolv.conf | head -c -1 | sed 's/nameserver //g;' | sed -z 's/\n/, /g') + [ -n "$nameservers" ] && info "Nameservers: $nameservers" + fi echo fi