FreeBSD Bugzilla – Attachment 185215 Details for
Bug 221379
bsdinstall(8): Installer doesn't support default router outside local subnet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Detect the gateway-outside-subnet scenario and generate a working rc.conf for it
router-outside-subnet.patch (text/plain), 2.79 KB, created by
Nils Steinger
on 2017-08-09 23:03:55 UTC
(
hide
)
Description:
Detect the gateway-outside-subnet scenario and generate a working rc.conf for it
Filename:
MIME Type:
Creator:
Nils Steinger
Created:
2017-08-09 23:03:55 UTC
Size:
2.79 KB
patch
obsolete
>diff --git a/usr.sbin/bsdinstall/scripts/netconfig_ipv4 b/usr.sbin/bsdinstall/scripts/netconfig_ipv4 >index 393a6ef..aade88d 100755 >--- a/usr.sbin/bsdinstall/scripts/netconfig_ipv4 >+++ b/usr.sbin/bsdinstall/scripts/netconfig_ipv4 >@@ -75,12 +75,51 @@ IF_CONFIG=$(dialog --backtitle 'FreeBSD Installer' --title 'Network Configuratio > if [ $? -eq $DIALOG_CANCEL ]; then exit 1; fi > exec 3>&- > >-echo $INTERFACE $IF_CONFIG | >- awk -v prefix="$IFCONFIG_PREFIX" '{ >- printf("ifconfig_%s=\"%s\inet %s netmask %s\"\n", $1, prefix, $2, $3); >- printf("defaultrouter=\"%s\"\n", $4); >- }' >> $BSDINSTALL_TMPETC/._rc.conf.net >-retval=$? >+read IP_ADDRESS NETMASK ROUTER <<EOF >+$IF_CONFIG >+EOF >+ >+inside_subnet() { >+ local ip1="$1" >+ local ip2="$2" >+ local mask="$3" >+ local ip1_int=$(echo "$ip1" | awk -F. '{if ($1 ~ /^0x/) {print $1 + 0} else {x = 0; for (i = 1; i <= 4; i++) {x += $i * 256^(4-i)} print(x)} }') >+ local ip2_int=$(echo "$ip2" | awk -F. '{if ($1 ~ /^0x/) {print $1 + 0} else {x = 0; for (i = 1; i <= 4; i++) {x += $i * 256^(4-i)} print(x)} }') >+ local mask_int=$(echo "$mask" | awk -F. '{if ($1 ~ /^0x/) {print $1 + 0} else {x = 0; for (i = 1; i <= 4; i++) {x += $i * 256^(4-i)} print(x)} }') >+ local mask_bin=$(awk -v x="$mask_int" 'BEGIN {while (x >= 1) {out = sprintf("%d", x%2) out; x/=2} print(out)}') >+ >+ awk -v mask=$mask_bin -v ip1=$ip1_int -v ip2=$ip2_int 'BEGIN {match(mask, /1+/); mask_len = RLENGTH; local_len = 32 - mask_len; ip1 = ip1 / (2^local_len); ip2 = ip2 / (2^local_len); if (sprintf("%d", ip1) != sprintf("%d", ip2)) {exit 1}}' >+} >+ >+# Check if router is in our subnet. If not, we need to add a route to the router >+if ! inside_subnet $ROUTER $IP_ADDRESS $NETMASK >+then >+ >+ # $1 = Interface >+ # $2 = IP Address >+ # $3 = Subnet Mask >+ # $4 = Default Router >+ echo $INTERFACE $IF_CONFIG | >+ awk -v prefix="$IFCONFIG_PREFIX" '{ >+ printf("ifconfig_%s=\"%s\inet %s netmask %s\"\n", $1, prefix, $2, $3); >+ printf("gateway_if=\"%s\"\n", $1); >+ printf("gateway_ip=\"%s\"\n", $4); >+ printf("static_routes=\"gateway\"\n"); >+ printf("route_gateway=\"-host $gateway_ip -interface $gateway_if\"\n"); >+ printf("defaultrouter=\"%s\"\n", $4); >+ }' >> $BSDINSTALL_TMPETC/._rc.conf.net >+ retval=$? >+ >+else >+ >+ echo $INTERFACE $IF_CONFIG | >+ awk -v prefix="$IFCONFIG_PREFIX" '{ >+ printf("ifconfig_%s=\"%s\inet %s netmask %s\"\n", $1, prefix, $2, $3); >+ printf("defaultrouter=\"%s\"\n", $4); >+ }' >> $BSDINSTALL_TMPETC/._rc.conf.net >+ retval=$? >+ >+fi > > if [ "$BSDINSTALL_CONFIGCURRENT" ]; then > . $BSDINSTALL_TMPETC/._rc.conf.net >@@ -91,6 +130,8 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then > fi > if [ "$defaultrouter" ]; then > route delete -inet default >+ # add route to router (just in case it's outside our subnet) >+ route add -host $defaultrouter -interface $INTERFACE > route add -inet default $defaultrouter > retval=$? > fi
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 221379
:
185214
| 185215