bee-tui: default mask /24, gateway x.x.x.1, DNS 77.88.8.8/77.88.8.1/1.1.1.1/8.8.8.8
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -107,13 +107,13 @@ network_static_one() {
|
||||
return
|
||||
fi
|
||||
|
||||
printf 'Netmask (example 24 or 255.255.255.0): '
|
||||
# derive default gateway: first three octets of IP + .1
|
||||
ip_base="$(echo "$ip" | cut -d. -f1-3)"
|
||||
default_gw="${ip_base}.1"
|
||||
|
||||
printf 'Netmask [24]: '
|
||||
read -r mask
|
||||
if [ -z "$mask" ]; then
|
||||
echo "Netmask is required"
|
||||
pause
|
||||
return
|
||||
fi
|
||||
[ -z "$mask" ] && mask="24"
|
||||
prefix=$(mask_to_prefix "$mask")
|
||||
if [ -z "$prefix" ]; then
|
||||
echo "Invalid netmask: $mask"
|
||||
@@ -122,14 +122,11 @@ network_static_one() {
|
||||
fi
|
||||
cidr="$ip/$prefix"
|
||||
|
||||
printf 'Default gateway: '
|
||||
printf 'Default gateway [%s]: ' "$default_gw"
|
||||
read -r gw
|
||||
if [ -z "$gw" ]; then
|
||||
echo "Default gateway is required"
|
||||
pause
|
||||
return
|
||||
fi
|
||||
printf 'DNS server (optional): '
|
||||
[ -z "$gw" ] && gw="$default_gw"
|
||||
|
||||
printf 'DNS servers [77.88.8.8 77.88.8.1 1.1.1.1 8.8.8.8]: '
|
||||
read -r dns
|
||||
|
||||
ip link set "$iface" up 2>/dev/null || true
|
||||
@@ -145,9 +142,13 @@ network_static_one() {
|
||||
ip route add default via "$gw" dev "$iface"
|
||||
fi
|
||||
|
||||
if [ -n "$dns" ]; then
|
||||
printf 'nameserver %s\n' "$dns" > /etc/resolv.conf
|
||||
if [ -z "$dns" ]; then
|
||||
dns="77.88.8.8 77.88.8.1 1.1.1.1 8.8.8.8"
|
||||
fi
|
||||
: > /etc/resolv.conf
|
||||
for d in $dns; do
|
||||
printf 'nameserver %s\n' "$d" >> /etc/resolv.conf
|
||||
done
|
||||
|
||||
echo
|
||||
echo "Static config applied to $iface"
|
||||
|
||||
Reference in New Issue
Block a user