소스 검색

Revised edition of shell scripts for addition and delete of a system ipv6 interface

bin/v-add-sys-ipv6: revised

bin/v-delete-sys-ipv6: revised

func/main.sh: small changes

revised and tested with debian based hestia
asmcc 3 년 전
부모
커밋
e08e3c7948
3개의 변경된 파일179개의 추가작업 그리고 115개의 파일을 삭제
  1. 88 44
      bin/v-add-sys-ipv6
  2. 51 35
      bin/v-delete-sys-ipv6
  3. 40 36
      func/main.sh

+ 88 - 44
bin/v-add-sys-ipv6

@@ -1,76 +1,104 @@
 #!/bin/bash
-# info: add system ip address
-# options: IPV6 NETMASK [INTERFACE] [USER] [IP_STATUS] [IP_NAME]
+# info: add system ipv6 address
+# options: IPV6 [PREFIXLEN] [INTERFACE] [USER] [IP_STATUS] [IP_NAME]
 #
-# The function adds ipv6 address into a system. It also creates rc scripts. You
+# example: v-add-sys-ipv6 1234:55:66::1 /64
+#
+# This function adds ipv6 address into a system. It also creates rc scripts. You
 # can specify ipv6 name which will be used as root domain for temporary aliases.
 # For example, if you set a1.myhosting.com as name, each new domain created on
 # this ipv6 will automatically receive alias $domain.a1.myhosting.com. Of course
 # you must have wildcard record *.a1.myhosting.com pointed to ipv6. This feature 
 # is very handy when customer wants to test domain before dns migration.
 
-
 #----------------------------------------------------------#
-#                    Variable&Function                     #
+#                Variables & Functions                     #
 #----------------------------------------------------------#
 
+# Get interface name
+iface=$(/bin/ip token | awk -F 'dev ' '{print $2}')
+
 # Argument definition
 ipv6=${1// /}
-netmask=$2
-interface="${3-eth0}"
+prefix_length="${2-/64}"
+iface="${3-$iface}"
 user="${4-admin}"
 ip_status="${5-shared}"
 ip_name=$6
 
 # Includes
+# shellcheck source=/etc/hestiacp/hestia.conf
+source /etc/hestiacp/hestia.conf
+# shellcheck source=/usr/local/hestia/func/main.sh
 source $HESTIA/func/main.sh
+# shellcheck source=/usr/local/hestia/func/ipv6.sh
 source $HESTIA/func/ipv6.sh
+# shellcheck source=/usr/local/hestia/func/domain.sh
 source $HESTIA/func/domain.sh
-source $HESTIA/conf/hestia.conf
-
+# load config file
+source_conf "$HESTIA/conf/hestia.conf"
 
 #----------------------------------------------------------#
 #                    Verifications                         #
 #----------------------------------------------------------#
 
-check_args '2' "$#" 'IPV6 NETMASK [INTERFACE] [USER] [STATUS] [NAME]'
-is_format_valid 'ipv6' 'netmaskv6' 'interface' 'user' 'ip_status'
+check_args '1' "$#" 'IPV6 [PREFIXLEN] [INTERFACE] [USER] [STATUS] [NAME]'
+is_format_valid 'ipv6' 'prefix_length' 'iface' 'user' 'ip_status'
 is_ipv6_free
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
-if [ ! -z "$ip_name" ] ; then
+if [ -n "$ip_name" ] ; then
     is_format_valid 'ip_name'
 fi
+if [ "$user" != "admin" ]; then
+    ip_status="dedicated"
+fi
+
+# Perform verification if read-only mode is enabled
+check_hestia_demo_mode
 
 #----------------------------------------------------------#
 #                       Action                             #
 #----------------------------------------------------------#
-iface=$(get_ipv6_iface)
-#cidr=$(convert_netmaskv6 $netmask)
-cidr=$netmask
 
 sys_ip_check=$(/sbin/ip -6 addr | grep "$ipv6")
 if [ -z "$sys_ip_check" ]; then
     # Adding sys ip
-    /sbin/ip addr add $ipv6/$cidr dev $interface
-
-    # Adding RHEL/CentOS/Fedora startup script
-    if [ -e "/etc/redhat-release" ]; then
-        sys_ip="# Added by hestia"
-        sys_ip="$sys_ip\nIPV6INIT=yes"
-        sys_ip="$sys_ip\nIPV6ADDR=$ipv6/$cidr"
-        sys_ip="$sys_ip\nIPV6_DEFAULTGW=$interface"
-        sys_ip="$sys_ip\nIPV6_AUTOCONF=no"
-        #sys_ip="$sys_ip\nIPV6ADDR_SECONDARIES="""
-        echo -e $sys_ip > /etc/sysconfig/network-scripts/ifcfg-$interface
+    /sbin/ip addr add $ipv6$prefix_length dev ${iface%:*} label ${iface}
+										 
+    
+    # Check if netplan is in use and generate configuration file
+    if [ ! -z $(which netplan) ]; then 
+        if  [ ! -z "$(netplan generate --mapping "$iface" | grep networkd)" ]; then   
+            netplan=1
+        else
+            netplan=0
+        fi
+    else
+        netplan=0
     fi
-
-    # Adding Debian/Ubuntu startup script
-    if [ -e "/etc/debian_version" ]; then
-        sys_ip="\n# Added by hestia"
-        sys_ip="$sys_ip\niface $interface inet6 static"
-        sys_ip="$sys_ip\naddress $ipv6"
-        sys_ip="$sys_ip\nnetmask $cidr"
+    
+    if [ "$netplan" == "1" ]; then
+        if [ -f "/etc/netplan/60-hestia.yaml" ]; then
+            sys_ip="        - $ipv6$prefix_length"
+        else
+            sys_ip="# Added by hestia, please do not edit the file manually!"
+            sys_ip="$sys_ip\nnetwork:"
+            sys_ip="$sys_ip\n  version: 2"
+            sys_ip="$sys_ip\n  renderer: networkd"
+            sys_ip="$sys_ip\n  ethernets:"
+            sys_ip="$sys_ip\n    $iface:"
+            sys_ip="$sys_ip\n      addresses:"
+            sys_ip="$sys_ip\n        - $ipv6$prefix_length"
+        fi
+        IFS='%'
+        echo -e $sys_ip >> /etc/netplan/60-hestia.yaml
+        unset IFS
+    else
+        sys_ip="\n# Added by Hestia Control Panel"
+        sys_ip="$sys_ip\nauto ${iface}"
+        sys_ip="$sys_ip\niface ${iface} inet6 static"
+        sys_ip="$sys_ip\naddress $ipv6$prefix_length"
         echo -e $sys_ip >> /etc/network/interfaces
     fi
 fi
@@ -86,8 +114,8 @@ STATUS='$ip_status'
 NAME='$ip_name'
 U_SYS_USERS=''
 U_WEB_DOMAINS='0'
-INTERFACE='$interface'
-NETMASK='$netmask'
+INTERFACE='$iface'
+NETMASK='$prefix_length'
 NAT=''
 TIME='$time'
 DATE='$date'
@@ -104,28 +132,45 @@ if [ ! -z "$WEB_SYSTEM" ]; then
             echo "NameVirtualHost [$ipv6]:$WEB_PORT" >  $web_conf
         fi
         echo "Listen [$ipv6]:$WEB_PORT" >> $web_conf
+        cat $HESTIA_INSTALL_DIR/apache2/unassigned.conf >> $web_conf
+        sed -i 's/directIP/'$ipv6'/g' $web_conf
+        sed -i 's/directPORT/'$WEB_PORT'/g' $web_conf
+
+    elif [ "$WEB_SYSTEM" = 'nginx' ]; then
+        cp -f $HESTIA_INSTALL_DIR/nginx/unassigned.inc $web_conf
+        sed -i 's/directIP/'$ipv6'/g' $web_conf
     fi
 
     if [ "$WEB_SSL" = 'mod_ssl' ]; then
         if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then
-            echo "NameVirtualHost [$ipv6]:$WEB_SSL_PORT" >> $web_conf
+            sed -i "1s/^/NameVirtualHost $ipv6:$WEB_SSL_PORT\n/" $web_conf
         fi
-        echo "Listen [$ipv6]:$WEB_SSL_PORT" >> $web_conf
+        sed -i "1s/^/Listen $ipv6:$WEB_SSL_PORT\n/" $web_conf
+        sed -i 's/directSSLPORT/'$WEB_SSL_PORT'/g' $web_conf
     fi
 fi
 
 # Proxy support
-if [ ! -z "$PROXY_SYSTEM" ]; then
+if [ -n "$PROXY_SYSTEM" ]; then
     cat $WEBTPL/$PROXY_SYSTEM/proxy_ip.tpl |\
         sed -e "s/%ip%/[$ipv6]/g" \
             -e "s/%web_port%/$WEB_PORT/g" \
             -e "s/%proxy_port%/$PROXY_PORT/g" \
+            -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
         > /etc/$PROXY_SYSTEM/conf.d/$ipv6.conf
 
+    # mod_extract_forwarded
+    fw_conf="/etc/$WEB_SYSTEM/conf.d/mod_extract_forwarded.conf"
+    if [ -e "$fw_conf" ]; then
+        ips=$(grep 'MEFaccept ' $fw_conf | grep -v '#' | head -n1)
+        sed -i "s/$ips/$ips $ipv6/g" $fw_conf
+    fi
+
     # mod_rpaf
     rpaf_conf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf"
     if [ -e "$rpaf_conf" ]; then
         rpaf_str=$(grep RPAFproxy_ips $rpaf_conf)
+        [ -z "$rpaf_str" ] && sed -i 's|</IfModule>|RPAFproxy_ips\n</IfModule>|' $rpaf_conf && rpaf_str='RPAFproxy_ips'
         rpaf_str="$rpaf_str $ipv6"
         sed -i "s/.*RPAFproxy_ips.*/$rpaf_str/" $rpaf_conf
     fi
@@ -139,7 +184,6 @@ if [ ! -z "$PROXY_SYSTEM" ]; then
     fi
 fi
 
-
 #----------------------------------------------------------#
 #                       Hestia                             #
 #----------------------------------------------------------#
@@ -148,7 +192,7 @@ fi
 increase_user_value "$user" '$IPV6_OWNED'
 if [ "$user" = 'admin' ]; then
     if [ "$ip_status" = 'shared' ]; then
-        for user in $(ls $HESTIA/data/users); do
+        for hestia_user in $($HESTIA/bin/v-list-sys-users plain); do
             increase_user_value "$user" '$IPV6_AVAIL'
         done
     else
@@ -164,18 +208,18 @@ $BIN/v-restart-web
 check_result $? "Web restart failed" >/dev/null
 
 # Restarting proxy server
-if [ ! -z "$PROXY_SYSTEM" ]; then
+if [ -n "$PROXY_SYSTEM" ]; then
     $BIN/v-restart-proxy
     check_result $? "Proxy restart failed" >/dev/null
 fi
 
 # Restarting firewall
-if [ ! -z "$FIREWALL_SYSTEM" ]; then
+if [ -n "$FIREWALL_SYSTEM" ]; then
     $BIN/v-update-firewall
 fi
 
 # Logging
-log_history "added system ipv6 address $ipv6" '' 'admin'
+$BIN/v-log-action "system" "Info" "Network" "Added new IPV6 address to the system (IPV6: $ipv6)."
 log_event "$OK" "$ARGUMENTS"
 
-exit
+exit

+ 51 - 35
bin/v-delete-sys-ipv6

@@ -2,23 +2,29 @@
 # info: delete system ipv6
 # options: IPV6
 #
-# The function for deleting a system ip. It does not allow to delete first ip
-# on interface and do not allow to delete ip which is used by a web domain.
-
+# example: v-delete-sys-ipv6 1234:5678::1
+#
+# This function for deleting a system ipv6. It does not allow
+# to delete ip which is used by a web domain.
 
 #----------------------------------------------------------#
-#                    Variable&Function                     #
+#                Variables & Functions                     #
 #----------------------------------------------------------#
 
 # Argument definition
 ipv6=$1
 
 # Includes
+# shellcheck source=/etc/hestiacp/hestia.conf
+source /etc/hestiacp/hestia.conf
+# shellcheck source=/usr/local/hestia/func/main.sh
 source $HESTIA/func/main.sh
+# shellcheck source=/usr/local/hestia/func/ipv6.sh
 source $HESTIA/func/ipv6.sh
+# shellcheck source=/usr/local/hestia/func/domain.sh
 source $HESTIA/func/domain.sh
-source $HESTIA/conf/hestia.conf
-
+# load config file
+source_conf "$HESTIA/conf/hestia.conf"
 
 #----------------------------------------------------------#
 #                    Verifications                         #
@@ -26,30 +32,31 @@ source $HESTIA/conf/hestia.conf
 
 check_args '1' "$#" 'IPV6'
 is_format_valid 'ipv6'
-is_ip_valid "$ipv6"
-is_ip_key_empty '$U_WEB_DOMAINS'
-is_ip_key_empty '$U_SYS_USERS'
+is_ipv6_valid "$ipv6"
+is_ipv6_key_empty '$U_WEB_DOMAINS'
+is_ipv6_key_empty '$U_SYS_USERS'
 
+# Perform verification if read-only mode is enabled
+check_hestia_demo_mode
 
 #----------------------------------------------------------#
 #                       Action                             #
 #----------------------------------------------------------#
 
 # Import ip variables
-source $HESTIA/data/ips/$ipv6
-cidr=$(convert_netmaskv6 $NETMASK)
+source "$HESTIA/data/ips/$ipv6"
 
 # Checking main ip on the interface
-interface=$(/sbin/ip  -6 addr | grep "$ipv6/$cidr" | awk '{print $NF}')
-if [ ! -z "$interface" ] && [ -z "$(echo $interface |cut -s -f2 -d :)" ]; then
+interface=$(/sbin/ip  -6 addr | grep "$ipv6${NETMASK}" | awk '{print $NF}')
+if [ $(/sbin/ip -6 addr | grep -c global) -le 1 ]; then
     echo "Error: can't delete main IP address"
     log_event "$E_FORBIDEN" "$ARGUMENTS"
-    exit $E_FORBIDEN
+    exit "$E_FORBIDEN"
 fi
 
 # Deleting system ip
-if [ ! -z "$interface" ]; then
-    /sbin/ip -6 addr del $ip/$cidr dev $INTERFACE
+if [ -n "$interface" ]; then
+    /sbin/ip -6 addr del $ipv6${NETMASK} dev ${INTERFACE%:*}
     if [ "$?" -ne 0 ]; then
         echo "Error: can't delete system ip"
         log_event "$E_FORBIDEN" "$ARGUMENTS"
@@ -63,11 +70,16 @@ if [ -e "/etc/sysconfig/network-scripts/ifcfg-$interface" ]; then
 fi
 
 # Deleting startup conf on Debian/Ubuntu
-if [ -e "/etc/network/interfaces" ]; then
-    ip_str=$(grep -n $ip$ /etc/network/interfaces |cut -f1 -d:)
-    if [ ! -z "$ip_str" ]; then
-        first_str=$((ip_str - 3))
-        last_str=$((ip_str + 1))
+if [ -f "/etc/netplan/60-hestia.yaml" ]; then
+    sed -i "/$ipv6/d" /etc/netplan/60-hestia.yaml
+    if ! grep -q '-' /etc/netplan/60-hestia.yaml; then
+        rm /etc/netplan/60-hestia.yaml
+    fi
+elif [ -e "/etc/network/interfaces" ]; then
+    ip_str=$(grep -n $ipv6 /etc/network/interfaces |cut -f1 -d:)
+    if [ -n "$ip_str" ]; then
+		first_str=$((ip_str - 4))
+		last_str=$((ip_str + 1))
         sed -i "$first_str,$last_str d" /etc/network/interfaces
     fi
 fi
@@ -76,12 +88,12 @@ fi
 rm -f $HESTIA/data/ips/$ipv6
 
 # Deleting web config
-if [ ! -z "$WEB_SYSTEM" ]; then
+if [ -n "$WEB_SYSTEM" ]; then
     rm -f /etc/$WEB_SYSTEM/conf.d/$ipv6.conf
 fi
 
 # Deleting proxy config
-if [ ! -z "$PROXY_SYSTEM" ]; then
+if [ -n "$PROXY_SYSTEM" ]; then
     rm -f /etc/$PROXY_SYSTEM/conf.d/$ipv6.conf
 
     # mod_extract_forwarded
@@ -95,33 +107,37 @@ if [ ! -z "$PROXY_SYSTEM" ]; then
     # mod_rpaf
     rpaf_conf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf"
     if [ -e "$rpaf_conf" ]; then
-        ips=$(grep RPAFproxy_ips $rpaf_conf)
-        new_ips=$(echo "$rpaf_str" | sed "s/$ipv6//")
-        sed -i "s/$ips/$new_ips/g" $rpaf_conf
+        ips=$(grep RPAFproxy_ips "$rpaf_conf")
+        new_ips=$(echo "$ips" | sed "s/$ipv6//")
+        sed -i "s/$ips/$new_ips/g" "$rpaf_conf"
+
+        # Remove RPAFproxy_ips line when ip list is empty
+        [ "$(grep RPAFproxy_ips $rpaf_conf | sed 's/^[[:space:]]*//g')" = "RPAFproxy_ips" ] && sed -i "/RPAFproxy_ips/d" $rpaf_conf
     fi
     
     #mod_remoteip
     remoteip_conf="/etc/$WEB_SYSTEM/mods-enabled/remoteip.conf"
     if [ -e "$remoteip_conf" ]; then
-        sed -i "s/RemoteIPInternalProxy $ipv6//g" $remoteip_conf
+        sed -i "/RemoteIPInternalProxy $ipv6\$/d" "$remoteip_conf"
     fi
 fi
 
-
 #----------------------------------------------------------#
 #                       Hestia                             #
 #----------------------------------------------------------#
 
 # Updating user conf
-if [ ! -z "$OWNER" ]; then
+if [ -n "$OWNER" ]; then
     decrease_user_value "$OWNER" '$IPV6_OWNED'
 fi
 
 if [ "$OWNER" = 'admin' ]; then
     if [ "$STATUS" = 'shared' ]; then
-        for user in $(ls $HESTIA/data/users/); do
-            decrease_user_value "$user" '$IPV6_AVAIL'
+        for hestia_user in $($HESTIA/bin/v-list-sys-users plain); do
+            decrease_user_value "$hestia_user" '$IPV6_AVAIL'
         done
+    else
+        decrease_user_value "$OWNER" '$IPV6_AVAIL'
     fi
 else
     decrease_user_value "$OWNER" '$IPV6_AVAIL'
@@ -132,18 +148,18 @@ $BIN/v-restart-web
 check_result $? "Web restart failed" >/dev/null
 
 # Restarting proxy server
-if [ ! -z "$PROXY_SYSTEM" ]; then
+if [ -n "$PROXY_SYSTEM" ]; then
     $BIN/v-restart-proxy
     check_result $? "Proxy restart failed" >/dev/null
 fi
 
 # Restarting firewall
-if [ ! -z "$FIREWALL_SYSTEM" ]; then
+if [ -n "$FIREWALL_SYSTEM" ]; then
     $BIN/v-update-firewall
 fi
 
 # Logging
-log_history "deleted system ip address $ip"
+$BIN/v-log-action "system" "Info" "System" "IPV6 address deleted (IPV6: $ipv6)."
 log_event "$OK" "$ARGUMENTS"
 
-exit
+exit

+ 40 - 36
func/main.sh

@@ -710,7 +710,7 @@ is_domain_format_valid() {
 	is_no_new_line_format "$1"
 }
 
-# Alias forman validator
+# Alias format validator
 is_alias_format_valid() {
 	for object in ${1//,/ }; do
 		exclude="[!|@|#|$|^|&|(|)|+|=|{|}|:|<|>|?|_|/|\|\"|'|;|%|\`| ]"
@@ -742,43 +742,46 @@ is_ip_format_valid() {
 
 # IPv6 format validator
 is_ipv6_format_valid() {
-	object_name=${2-ipv6}
-	ip_regex='([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])'
-	t_ip=$(echo $1 | awk -F / '{print $1}')
-	t_cidr=$(echo $1 | awk -F / '{print $2}')
-	valid_cidr=1
-
-	WORD="[0-9A-Fa-f]\{1,4\}"
-	# flat address, no compressed words
-	FLAT="^${WORD}\(:${WORD}\)\{7\}$"
-
-	COMP2="^\(${WORD}:\)\{1,1\}\(:${WORD}\)\{1,6\}$"
-	COMP3="^\(${WORD}:\)\{1,2\}\(:${WORD}\)\{1,5\}$"
-	COMP4="^\(${WORD}:\)\{1,3\}\(:${WORD}\)\{1,4\}$"
-	COMP5="^\(${WORD}:\)\{1,4\}\(:${WORD}\)\{1,3\}$"
-	COMP6="^\(${WORD}:\)\{1,5\}\(:${WORD}\)\{1,2\}$"
-	COMP7="^\(${WORD}:\)\{1,6\}\(:${WORD}\)\{1,1\}$"
-	# trailing :: edge case, includes case of only :: (all 0's)
-	EDGE_TAIL="^\(\(${WORD}:\)\{1,7\}\|:\):$"
-	# leading :: edge case
-	EDGE_LEAD="^:\(:${WORD}\)\{1,7\}$"
-
-	echo $t_ip | grep --silent "\(${FLAT}\)\|\(${COMP2}\)\|\(${COMP3}\)\|\(${COMP4}\)\|\(${COMP5}\)\|\(${COMP6}\)\|\(${COMP7}\)\|\(${EDGE_TAIL}\)\|\(${EDGE_LEAD}\)"
-	if [ $? -ne 0 ]; then
-		check_result "$E_INVALID" "invalid $object_name format :: $1"
-	fi
+    object_name=${2-ipv6}
+    t_ipv6=$(echo $1 |awk -F / '{print $1}')
+    t_prefixlen=$(echo $1 |awk -F / '{print $2}')
+    valid_prefixlen=1
+	
+	if [[ "$object_name" != "prefix_length" ]] || [[ -n "$t_ipv6" ]]; then
+		# check for ipv6 address format excluding "prefix length only" mode
+		WORD="[0-9A-Fa-f]\{1,4\}"
+		# flat address, no compressed words
+		FLAT="^${WORD}\(:${WORD}\)\{7\}$"
 
-	if [ -n "$(echo $1 | grep '/')" ]; then
-		if [[ "$t_cidr" -lt 0 ]] || [[ "$t_cidr" -gt 128 ]]; then
-			valid_cidr=0
-		fi
-		if ! [[ "$t_cidr" =~ ^[0-9]+$ ]]; then
-			valid_cidr=0
+		COMP2="^\(${WORD}:\)\{1,1\}\(:${WORD}\)\{1,6\}$"
+		COMP3="^\(${WORD}:\)\{1,2\}\(:${WORD}\)\{1,5\}$"
+		COMP4="^\(${WORD}:\)\{1,3\}\(:${WORD}\)\{1,4\}$"
+		COMP5="^\(${WORD}:\)\{1,4\}\(:${WORD}\)\{1,3\}$"
+		COMP6="^\(${WORD}:\)\{1,5\}\(:${WORD}\)\{1,2\}$"
+		COMP7="^\(${WORD}:\)\{1,6\}\(:${WORD}\)\{1,1\}$"
+		# trailing :: edge case, includes case of only :: (all 0's)
+		EDGE_TAIL="^\(\(${WORD}:\)\{1,7\}\|:\):$"
+		# leading :: edge case
+		EDGE_LEAD="^:\(:${WORD}\)\{1,7\}$"
+		echo $t_ipv6 | grep --silent "\(${FLAT}\)\|\(${COMP2}\)\|\(${COMP3}\)\|\(${COMP4}\)\|\(${COMP5}\)\|\(${COMP6}\)\|\(${COMP7}\)\|\(${EDGE_TAIL}\)\|\(${EDGE_LEAD}\)"
+		if [ $? -ne 0 ]; then
+			check_result "$E_INVALID" "invalid ipv6 address format :: $1"
 		fi
 	fi
-	if [ "$valid_cidr" -eq 0 ]; then
-		check_result "$E_INVALID" "invalid $object_name format :: $1"
-	fi
+
+	# ipv6 prefix length checks
+    if [ -n "$(echo $1|grep '/')" ]; then
+		# introducing slash as prefix length attribute detected
+        if [[ "$t_prefixlen" -lt 0 ]] || [[ "$t_prefixlen" -gt 128 ]]; then
+            valid_prefixlen=0
+        fi
+        if ! [[ "$t_prefixlen" =~ ^[0-9]+$ ]]; then
+            valid_prefixlen=0
+        fi
+    fi
+    if [ "$valid_prefixlen" -eq 0 ]; then
+        check_result "$E_INVALID" "invalid ipv6 prefix length format :: $1"
+    fi
 }
 
 is_ip46_format_valid() {
@@ -1023,7 +1026,7 @@ is_int_format_valid() {
 # Interface validator
 is_interface_format_valid() {
 	netdevices=$(cat /proc/net/dev | grep : | cut -f 1 -d : | tr -d ' ')
-	if [ -z $(echo "$netdevices" | grep -x $1) ]; then
+	if [ -z $(echo "$netdevices" | grep -x ${1%:*}) ]; then
 		check_result "$E_INVALID" "invalid interface format :: $1"
 	fi
 }
@@ -1209,6 +1212,7 @@ is_format_valid() {
 				password) is_password_format_valid "$arg" ;;
 				port) is_int_format_valid "$arg" 'port' ;;
 				port_ext) is_fw_port_format_valid "$arg" ;;
+				prefix_length) is_ipv6_format_valid "$arg" 'prefix_length' ;;
 				protocol) is_fw_protocol_format_valid "$arg" ;;
 				proxy_ext) is_extention_format_valid "$arg" ;;
 				quota) is_int_format_valid "$arg" 'quota' ;;