[arch-projects] [netcfg] [PATCH 1/2] Allow IPv4 $ADDR be specified as address/netmask
This matches the syntax used by `ip` itself, and by $ADDR6. --- src/connections/ethernet | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/connections/ethernet b/src/connections/ethernet index 487adf8..6a16b66 100644 --- a/src/connections/ethernet +++ b/src/connections/ethernet @@ -87,9 +87,9 @@ ethernet_up() { ;; static) if [[ -n "$ADDR" ]]; then - [[ -z $NETMASK ]] && NETMASK=24 - report_debug ethernet_up ip addr add "$ADDR/$NETMASK" brd + dev "$INTERFACE" - if ! ip addr add "$ADDR/$NETMASK" brd + dev "$INTERFACE"; then + [[ $ADDR == */* ]] || ADDR+="/${NETMASK:-24}" + report_debug ethernet_up ip addr add "$ADDR" brd + dev "$INTERFACE" + if ! ip addr add "$ADDR" brd + dev "$INTERFACE"; then report_iproute "Could not configure interface" fi fi -- 1.8.0.1
It's unclear that the default is /24. --- docs/examples/ethernet-static | 2 +- docs/examples/wireless-wpa-static | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/examples/ethernet-static b/docs/examples/ethernet-static index ea88bde..a66cee5 100644 --- a/docs/examples/ethernet-static +++ b/docs/examples/ethernet-static @@ -2,7 +2,7 @@ CONNECTION='ethernet' DESCRIPTION='A basic static ethernet connection using iproute' INTERFACE='eth0' IP='static' -ADDR='192.168.1.23' +ADDR='192.168.1.30/24' #ROUTES=('192.168.0.0/24 via 192.168.1.2') GATEWAY='192.168.1.1' DNS=('192.168.1.1') diff --git a/docs/examples/wireless-wpa-static b/docs/examples/wireless-wpa-static index 25da514..5e973be 100644 --- a/docs/examples/wireless-wpa-static +++ b/docs/examples/wireless-wpa-static @@ -5,7 +5,7 @@ SECURITY='wpa' ESSID='MyNetwork' KEY='WirelessKey' IP='static' # Any other CONNECTION='ethernet' options may be used. -ADDR='192.168.1.23' +ADDR='192.168.1.30/24' GATEWAY='192.168.1.1' DNS=('192.168.1.1') # Uncomment this if your ssid is hidden -- 1.8.0.1
On Sun, Dec 9, 2012 at 1:09 AM, Mantas Mikulėnas <grawity@gmail.com> wrote:
This matches the syntax used by `ip` itself, and by $ADDR6.
This and FS#25427 have been included in netctl [1]. It is currently unclear what the future will look like. If there is going to be a migration path from netcfg to netctl, it might be worthwile to *not* pull this patch into netcfg. Thanks, - Jouke [1] https://github.com/joukewitteveen/netctl
participants (2)
-
Jouke Witteveen
-
Mantas Mikulėnas