feat: Automaticly match MTU size
This commit is contained in:
parent
de2a97fcbd
commit
94466f1ac8
1 changed files with 7 additions and 2 deletions
|
@ -4,6 +4,7 @@ set -Eeuo pipefail
|
||||||
# Docker environment variables
|
# Docker environment variables
|
||||||
|
|
||||||
: "${MAC:=""}"
|
: "${MAC:=""}"
|
||||||
|
: "${MTU:=""}"
|
||||||
: "${DHCP:="N"}"
|
: "${DHCP:="N"}"
|
||||||
: "${NETWORK:="Y"}"
|
: "${NETWORK:="Y"}"
|
||||||
: "${USER_PORTS:=""}"
|
: "${USER_PORTS:=""}"
|
||||||
|
@ -349,6 +350,10 @@ getInfo() {
|
||||||
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 27
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$MTU" ]; then
|
||||||
|
MTU=$(cat "/sys/class/net/$VM_NET_DEV/mtu")
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$MAC" ]; then
|
if [ -z "$MAC" ]; then
|
||||||
local file="$STORAGE/$PROCESS.mac"
|
local file="$STORAGE/$PROCESS.mac"
|
||||||
[ -s "$file" ] && MAC=$(<"$file")
|
[ -s "$file" ] && MAC=$(<"$file")
|
||||||
|
@ -390,7 +395,7 @@ getInfo
|
||||||
html "Initializing network..."
|
html "Initializing network..."
|
||||||
|
|
||||||
if [[ "$DEBUG" == [Yy1]* ]]; then
|
if [[ "$DEBUG" == [Yy1]* ]]; then
|
||||||
info "Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC"
|
info "Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC MTU: $MTU"
|
||||||
[ -f /etc/resolv.conf ] && grep '^nameserver*' /etc/resolv.conf
|
[ -f /etc/resolv.conf ] && grep '^nameserver*' /etc/resolv.conf
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
@ -444,7 +449,7 @@ else
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NET_OPTS+=" -device $ADAPTER,romfile=,netdev=hostnet0,mac=$VM_NET_MAC,id=net0"
|
NET_OPTS+=" -device $ADAPTER,romfile=,netdev=hostnet0,mac=$VM_NET_MAC,host_mtu=$MTU,id=net0"
|
||||||
|
|
||||||
html "Initialized network successfully..."
|
html "Initialized network successfully..."
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Reference in a new issue