diff options
Diffstat (limited to 'templates/interfaces/ethernet')
12 files changed, 123 insertions, 36 deletions
diff --git a/templates/interfaces/ethernet/node.def b/templates/interfaces/ethernet/node.def index 081cabb5..05b2e03c 100644 --- a/templates/interfaces/ethernet/node.def +++ b/templates/interfaces/ethernet/node.def @@ -1,7 +1,9 @@ tag: priority: 318 type: txt -help: Set ethernet interface +help: Set Ethernet interface name +comp_help: Enter Ethernet interface name (eth0 - eth999) + allowed: /opt/vyatta/sbin/vyatta-interfaces.pl --show=ethernet syntax:expression: pattern $VAR(@) "^eth[0-9]+$" \ ; "interface ethernet $VAR(@): not a valid name" @@ -10,7 +12,7 @@ syntax:expression: exec \ echo \"interface ethernet $VAR(@): does not exist\"; exit 1; \ fi" -create: sudo ip link set "$VAR(@)" up +create: ip link set "$VAR(@)" up /opt/vyatta/sbin/vyatta-link-detect $VAR(@) on delete: [ -d /sys/class/net/$VAR(../@) ] || exit 0 - sudo ip link set $VAR(@) down + ip link set $VAR(@) down diff --git a/templates/interfaces/ethernet/node.tag/address/node.def b/templates/interfaces/ethernet/node.tag/address/node.def index db87ff05..7ed12bba 100644 --- a/templates/interfaces/ethernet/node.tag/address/node.def +++ b/templates/interfaces/ethernet/node.tag/address/node.def @@ -15,14 +15,41 @@ syntax:expression: exec "/opt/vyatta/sbin/vyatta-interfaces.pl --valid-addr-set # commit:expression: exec "/opt/vyatta/sbin/vyatta-interfaces.pl --valid-addr-commit $VAR(@@) --dev $VAR(../@)" -create:sudo /opt/vyatta/sbin/vyatta-interfaces.pl --eth-addr-update $VAR(@) --dev $VAR(../@) - -delete:sudo /opt/vyatta/sbin/vyatta-interfaces.pl --eth-addr-delete $VAR(@) --dev $VAR(../@) - -allowed: echo "dhcp <>" +create: + ifname=$VAR(../@) + param=$VAR(@) + if [ "$param" = "dhcpv6" ]; then + if [ -n "$VAR(../dhcpv6-options/parameters-only)" ]; then + echo "parameters-only is set" + arg1="--parameters-only" + fi + if [ -n "$VAR(../dhcpv6-options/temporary)" ]; then + echo "temporary is set" + arg2="--temporary" + fi + + echo "Starting DHCPv6 client on ${ifname}..." + sudo /opt/vyatta/sbin/vyatta-dhcpv6-client.pl --start \ + --ifname $ifname $arg1 $arg2 + else + sudo /opt/vyatta/sbin/vyatta-interfaces.pl --eth-addr-update $VAR(@) --dev $VAR(../@) + fi + +delete: + ifname=$VAR(../@) + param=$VAR(@) + if [ "$param" = "dhcpv6" ]; then + echo "Stopping DHCPv6 client on ${ifname}..." + sudo /opt/vyatta/sbin/vyatta-dhcpv6-client.pl --stop --ifname \ + $ifname + else + sudo /opt/vyatta/sbin/vyatta-interfaces.pl --eth-addr-delete $VAR(@) --dev $VAR(../@) + fi + +allowed: echo "dhcp dhcpv6 <>" comp_help:Possible completions: - <x.x.x.x/x> Set the IP address and prefix length + <x.x.x.x/x> Set the IPv4 address and prefix length <h:h:h:h:h:h:h:h/x> Set the IPv6 address and prefix length - dhcp Set the IP address and prefix length via DHCP - + dhcp Set the IPv4 address and prefix length via DHCP + dhcpv6 Set the IPv6 address and prefix length via DHCPv6 diff --git a/templates/interfaces/ethernet/node.tag/bridge-group/node.def b/templates/interfaces/ethernet/node.tag/bridge-group/node.def index 7590dc96..c56c31cc 100644 --- a/templates/interfaces/ethernet/node.tag/bridge-group/node.def +++ b/templates/interfaces/ethernet/node.tag/bridge-group/node.def @@ -11,13 +11,13 @@ end: exit 1 else echo "Adding interface $ethif to bridge $newbridge." - sudo brctl addif $newbridge $ethif; + /usr/sbin/brctl addif $newbridge $ethif; if [ -n "$VAR(./cost/@)" ]; then - sudo brctl setpathcost $newbridge $ethif $VAR(./cost/@); + /usr/sbin/brctl setpathcost $newbridge $ethif $VAR(./cost/@); fi; if [ -n "$VAR(./priority/@)" ]; then - sudo brctl setportprio $newbridge $ethif $VAR(./priority/@); + /usr/sbin/brctl setportprio $newbridge $ethif $VAR(./priority/@); fi fi elif [ ${COMMIT_ACTION} = 'DELETE' ]; then @@ -31,7 +31,7 @@ end: # it gets deleted before the removal of bridge-groups under interfaces exit 0 else - sudo brctl delif $oldbridge $ethif + /usr/sbin/brctl delif $oldbridge $ethif fi else if [ -z "$newbridge" ]; then @@ -45,15 +45,15 @@ end: if ! /opt/vyatta/sbin/vyatta-bridgegroup-depedency.pl \ --bridge-notin-proposedcfg \ --bridge-interface="$oldbridge"; then \ - sudo brctl delif $oldbridge $ethif + /usr/sbin/brctl delif $oldbridge $ethif fi - sudo brctl addif $newbridge $ethif + /usr/sbin/brctl addif $newbridge $ethif fi if [ -n "$VAR(./cost/@)" ]; then - sudo brctl setpathcost $newbridge $ethif $VAR(./cost/@) + /usr/sbin/brctl setpathcost $newbridge $ethif $VAR(./cost/@) fi if [ -n "$VAR(./priority/@)" ]; then - sudo brctl setportprio $newbridge $ethif $VAR(./priority/@) + /usr/sbin/brctl setportprio $newbridge $ethif $VAR(./priority/@) fi fi fi diff --git a/templates/interfaces/ethernet/node.tag/dhcpv6-options/node.def b/templates/interfaces/ethernet/node.tag/dhcpv6-options/node.def new file mode 100644 index 00000000..aaeca067 --- /dev/null +++ b/templates/interfaces/ethernet/node.tag/dhcpv6-options/node.def @@ -0,0 +1,49 @@ +# This node is run before the rest of the interface is configured. +# We first check to see if DHCPv6 is still configured on the interface by +# looking over at the interface address parameters. Then we check to see +# if the DHCPv6 client program is still running on this interface. If both +# of those are true, then any change to this tree means that the user +# has changed this tree ONLY, and that we are going to have to re-start +# the DHCPv6 client using the new parameters. + + +priority: 317 # Run before interface has been configured + +help: Set options for DHCPv6 + +end: + ifname="$VAR(../@)" + echo "dhcpv6-options: ifname is $ifname" + + dhcpv6_set=0 + for param in $VAR(../address/@@); do + if [ "$param" = "dhcpv6" ]; then + dhcpv6_set=1 + fi + done + + if [ $dhcpv6_set -eq 0 ]; then + echo "DHCPv6 is not configured on this interface" + exit 0 + fi + + conffile=/var/lib/dhcp3/dhclient_v6_$VAR(../@).conf + if [ ! -e $conffile ]; then + echo "Conf file $conffile doesn't exist" + exit 0 + fi + + if [ -n "$VAR(./parameters-only)" ]; then + arg1="--parameters-only" + fi + + if [ -n "$VAR(./temporary)" ]; then + arg2="--temporary" + fi + + echo "Re-starting DHCPv6 client on ${ifname}..." + sudo /opt/vyatta/sbin/vyatta-dhcpv6-client.pl --stop --start \ + --ifname $ifname $arg1 $arg2 + + echo "Done." + exit 0
\ No newline at end of file diff --git a/templates/interfaces/ethernet/node.tag/dhcpv6-options/parameters-only/node.def b/templates/interfaces/ethernet/node.tag/dhcpv6-options/parameters-only/node.def new file mode 100644 index 00000000..0178c469 --- /dev/null +++ b/templates/interfaces/ethernet/node.tag/dhcpv6-options/parameters-only/node.def @@ -0,0 +1,3 @@ + +help: Acquire only config parameters, not address, via DHCPv6 + diff --git a/templates/interfaces/ethernet/node.tag/dhcpv6-options/temporary/node.def b/templates/interfaces/ethernet/node.tag/dhcpv6-options/temporary/node.def new file mode 100644 index 00000000..afb9de9c --- /dev/null +++ b/templates/interfaces/ethernet/node.tag/dhcpv6-options/temporary/node.def @@ -0,0 +1,3 @@ + +help: Acquire a "temporary" IPv6 address + diff --git a/templates/interfaces/ethernet/node.tag/disable/node.def b/templates/interfaces/ethernet/node.tag/disable/node.def index fbfb155a..5fe2b748 100644 --- a/templates/interfaces/ethernet/node.tag/disable/node.def +++ b/templates/interfaces/ethernet/node.tag/disable/node.def @@ -1,12 +1,12 @@ help: Set interface disabled create: /etc/netplug/linkdown.d/dhclient $VAR(../@) - if ! sudo ip link set $VAR(../@) down 2>/dev/null; then + if ! ip link set $VAR(../@) down 2>/dev/null; then echo "Error disabling dev $VAR(../@)" /etc/netplug/linkup.d/dhclient $VAR(../@) exit 1 fi delete: [ -d /sys/class/net/$VAR(../@) ] || exit 0 - if ! sudo ip link set $VAR(../@) up; then + if ! ip link set $VAR(../@) up; then echo "Error enabling dev $VAR(../@)" exit 1 fi diff --git a/templates/interfaces/ethernet/node.tag/mtu/node.def b/templates/interfaces/ethernet/node.tag/mtu/node.def index dc03ae16..f33158f8 100644 --- a/templates/interfaces/ethernet/node.tag/mtu/node.def +++ b/templates/interfaces/ethernet/node.tag/mtu/node.def @@ -1,8 +1,8 @@ type: u32 help: Set the Maximum Transmission Unit (MTU) for this interface syntax:expression: $VAR(@) >= 68 && $VAR(@) <= 9000; "MTU must be between 68 and 9000" -update: if ! sudo ip link set $VAR(../@) mtu $VAR(@) +update: if ! ip link set $VAR(../@) mtu $VAR(@) then echo "Error setting MTU on dev $VAR(../@)"; exit 1 fi delete: [ -d /sys/class/net/$VAR(../@) ] || exit 0 - sudo ip link set $VAR(../@) mtu 1500 + ip link set $VAR(../@) mtu 1500 diff --git a/templates/interfaces/ethernet/node.tag/vif/node.def b/templates/interfaces/ethernet/node.tag/vif/node.def index b6b8abc7..c14ed002 100644 --- a/templates/interfaces/ethernet/node.tag/vif/node.def +++ b/templates/interfaces/ethernet/node.tag/vif/node.def @@ -5,17 +5,17 @@ help: Set Virtual Local Area Network (VLAN) ID syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 4094; "VLAN ID must be between 0 and 4094" -create: if ! sudo ip link add link $VAR(../@) name "$VAR(../@).$VAR(@)" type vlan id $VAR(@) +create: if ! ip link add link $VAR(../@) name "$VAR(../@).$VAR(@)" type vlan id $VAR(@) then echo "Error creating VLAN device $VAR(../@).$VAR(@)" exit 1 fi # if parent is up, then bring VLAN up if [ $(( $(cat /sys/class/net/$VAR(../@)/flags) & 1 )) -eq 1 ]; then - sudo ip link set "$VAR(../@).$VAR(@)" up + ip link set "$VAR(../@).$VAR(@)" up fi /opt/vyatta/sbin/vyatta-link-detect "$VAR(../@).$VAR(@)" on delete: [ -d /sys/class/net/$VAR(../@) ] || exit 0 - sudo ip link delete dev "$VAR(../@).$VAR(@)" type vlan id $VAR(@) + ip link delete dev "$VAR(../@).$VAR(@)" type vlan id $VAR(@) comp_help: possible completions: <0-4094> Set VLAN ID diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/node.def index dd3863a0..84fa14f1 100644 --- a/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/node.def +++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/node.def @@ -14,13 +14,13 @@ end: exit 1 else echo "Adding interface $ethif to bridge $newbridge." - sudo brctl addif $newbridge $ethif; + /usr/sbin/brctl addif $newbridge $ethif; if [ -n "$VAR(./cost/@)" ]; then - sudo brctl setpathcost $newbridge $ethif $VAR(./cost/@); + /usr/sbin/brctl setpathcost $newbridge $ethif $VAR(./cost/@); fi; if [ -n "$VAR(./priority/@)" ]; then - sudo brctl setportprio $newbridge $ethif $VAR(./priority/@); + /usr/sbin/brctl setportprio $newbridge $ethif $VAR(./priority/@); fi fi elif [ ${COMMIT_ACTION} = 'DELETE' ]; then @@ -34,7 +34,7 @@ end: # it gets deleted before the removal of bridge-groups under interfaces exit 0 else - sudo brctl delif $oldbridge $ethif + /usr/sbin/brctl delif $oldbridge $ethif fi else if [ -z "$newbridge" ]; then @@ -48,15 +48,15 @@ end: if ! /opt/vyatta/sbin/vyatta-bridgegroup-depedency.pl \ --bridge-notin-proposedcfg \ --bridge-interface="$oldbridge"; then \ - sudo brctl delif $oldbridge $ethif + /usr/sbin/brctl delif $oldbridge $ethif fi - sudo brctl addif $newbridge $ethif + /usr/sbin/brctl addif $newbridge $ethif fi if [ -n "$VAR(./cost/@)" ]; then - sudo brctl setpathcost $newbridge $ethif $VAR(./cost/@) + /usr/sbin/brctl setpathcost $newbridge $ethif $VAR(./cost/@) fi if [ -n "$VAR(./priority/@)" ]; then - sudo brctl setportprio $newbridge $ethif $VAR(./priority/@) + /usr/sbin/brctl setportprio $newbridge $ethif $VAR(./priority/@) fi fi fi diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/disable/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/disable/node.def index 78b24870..b2119c9c 100644 --- a/templates/interfaces/ethernet/node.tag/vif/node.tag/disable/node.def +++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/disable/node.def @@ -1,11 +1,11 @@ help: Set interface disabled update: /etc/netplug/linkdown.d/dhclient $VAR(../../@).$VAR(../@) - if ! sudo ip link set $VAR(../../@).$VAR(../@) down 2>/dev/null; then + if ! ip link set $VAR(../../@).$VAR(../@) down 2>/dev/null; then echo "Error disabling dev $VAR(../../@).$VAR(../@)" /etc/netplug/linkup.d/dhclient $VAR(../../@).$VAR(../@) exit 1 fi -delete: if ! sudo ip link set $VAR(../../@).$VAR(../@) up; then +delete: if ! ip link set $VAR(../../@).$VAR(../@) up; then echo "Error enabling dev $VAR(../../@).$VAR(../@)" exit 1 fi diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/ip/enable-proxy-arp/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/ip/enable-proxy-arp/node.def new file mode 100644 index 00000000..a45d4129 --- /dev/null +++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/ip/enable-proxy-arp/node.def @@ -0,0 +1,3 @@ +help: Set to enable proxy-arp on this interface +create:expression: "sudo sh -c \"echo 1 > /proc/sys/net/ipv4/conf/$VAR(../../../@).$VAR(../../@)/proxy_arp\" " +delete:expression: "sudo sh -c \"echo 0 > /proc/sys/net/ipv4/conf/$VAR(../../../@).$VAR(../../@)/proxy_arp\" " |