Skip to content

Instantly share code, notes, and snippets.

@highgain86j
Last active September 1, 2021 20:00
Show Gist options
  • Save highgain86j/42c89b9c301852b9ca4cee7e7194ac8e to your computer and use it in GitHub Desktop.
Save highgain86j/42c89b9c301852b9ca4cee7e7194ac8e to your computer and use it in GitHub Desktop.
This bash file enables configuration of encaplimit on tunnel interfaces on EdgeOS.
#!/bin/bash
temp="node.def"
interface_templates_dir=/opt/vyatta/share/vyatta-cfg/templates/interfaces
ip4ip6_dir=`find ${interface_templates_dir} -type d -name node\.tag | egrep '\/ipv6-tunnel\/node\.tag$'`
ip4ip6_encaplimit_dir="${ip4ip6_dir}/encaplimit"
ip4ip4_dir=`find ${interface_templates_dir} -type d -name node\.tag | egrep '\/tunnel\/node\.tag$'`
ip4ip4_encaplimit_dir="${ip4ip4_dir}/encaplimit"
if [ ! -e ${ip4ip6_encaplimit_dir} ]; then
echo "Creating ${ip4ip6_encaplimit_dir}"
sudo mkdir ${ip4ip6_encaplimit_dir}
fi
cat << 'EOF' > ${temp}
type: txt
help: Encaplimit field
val_help: txt; Encaplimit (default 4)
val_help: <0-255>; Sets a fixed encapsulation limit. Default is 4.
val_help: none; Sets no encapsulation limit.
syntax:expression: ($VAR(@) == "none" || (pattern $VAR(@) "[0-9]*")) ; "Must be 'none' or a number between 0-255"
update: sudo ip -6 tunnel change $VAR(../@) encaplimit $VAR(@);
delete: sudo ip -6 tunnel change $VAR(../@) encaplimit 4
EOF
sudo mv ${temp} ${ip4ip6_encaplimit_dir}
if [ ! -e ${ip4ip4_encaplimit_dir} ]; then
echo "Creating ${ip4ip4_encaplimit_dir}"
sudo mkdir ${ip4ip4_encaplimit_dir}
fi
cat << 'EOF' > ${temp}
type: txt
help: Encaplimit field
val_help: txt; Encaplimit (default 4)
val_help: <0-255>; Sets a fixed encapsulation limit. Default is 4.
val_help: none; Sets no encapsulation limit.
syntax:expression: ($VAR(@) == "none" || (pattern $VAR(@) "[0-9]*")) ; "Must be 'none' or a number between 0-255"
update: sudo ip tunnel change $VAR(../@) encaplimit $VAR(@);
delete: sudo ip tunnel change $VAR(../@) encaplimit 4
EOF
sudo mv ${temp} ${ip4ip4_encaplimit_dir}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment