#################### Bandwidth Setup #####################
user_variables() {
#Percent of download speed guaranteed per QOS category, change below as desired (minimum value per section 5, sum should not be greater than 100)
NetControl_DownBandPercent=5 #This value can be adjust as desired ** no spaces before or after the "=" sign **
VoIP_DownBandPercent=10 #This value can be adjust as desired ** no decimals **
Gaming_DownBandPercent=15 #This value can be adjust as desired
Others_DownBandPercent=10 #This value can be adjust as desired #Note: New destination for unidentified traffic
WebSurfing_DownBandPercent=10 #This value can be adjust as desired
Video_DownBandPercent=40 #This value can be adjust as desired
FileTransfer_DownBandPercent=5 #This value can be adjust as desired
Default_DownBandPercent=5 #This value can be adjust as desired #Note: Original destination for unidentified traffic, repurposed for "Gaming Downloads on ports 80/443"
#Percent of upload speed guaranteed per QOS category, change below as desired (minimum value per section 5, sum should not be greater than 100)
NetControl_UpBandPercent=5 #This value can be adjust as desired
VoIP_UpBandPercent=20 #This value can be adjust as desired
Gaming_UpBandPercent=15 #This value can be adjust as desired
Others_UpBandPercent=20 #This value can be adjust as desired #Note: New destination for unidentified traffic
WebSurfing_UpBandPercent=10 #This value can be adjust as desired
Video_UpBandPercent=20 #This value can be adjust as desired
FileTransfer_UpBandPercent=5 #This value can be adjust as desired
Default_UpBandPercent=5 #This value can be adjust as desired #Note: Original destination for unidentified traffic, repurposed for "Gaming Downloads on ports 80/443"
}
#################### Custom Rules Setup #####################
iptable_down_rules() {
echo "Applying - Iptable Down Rules"
##DOWNLOAD (INCOMMING TRAFFIC) CUSTOM RULES START HERE
iptables -D POSTROUTING -t mangle -o br0 -p udp --sport 500 -j MARK --set-mark ${VOIP_mark_down} &> /dev/null #Wifi Calling (1/2) - (All incoming traffic w/ WAN source port 500 goes to "VOIP" Traffic Container)
iptables -A POSTROUTING -t mangle -o br0 -p udp --sport 500 -j MARK --set-mark ${VOIP_mark_down}
iptables -D POSTROUTING -t mangle -o br0 -p udp --sport 4500 -j MARK --set-mark ${VOIP_mark_down} &> /dev/null #Wifi Calling (2/2) - (All incoming traffic w/ WAN source port 4500 goes to "VOIP" Traffic Container)
iptables -A POSTROUTING -t mangle -o br0 -p udp --sport 4500 -j MARK --set-mark ${VOIP_mark_down}
iptables -D POSTROUTING -t mangle -o br0 -p udp --dport 16384:16415 -j MARK --set-mark ${VOIP_mark_down} &> /dev/null #Facetime
iptables -A POSTROUTING -t mangle -o br0 -p udp --dport 16384:16415 -j MARK --set-mark ${VOIP_mark_down}
iptables -D POSTROUTING -t mangle -o br0 -m mark --mark 0x80080000/0xc03f0000 -p tcp --sport 80 -j MARK --set-mark ${Default_mark_down} &> /dev/null #Gaming (1/3) - Routes "Gaming" traffic coming from port 443 into "Defaults"
iptables -A POSTROUTING -t mangle -o br0 -m mark --mark 0x80080000/0xc03f0000 -p tcp --sport 80 -j MARK --set-mark ${Default_mark_down}
iptables -D POSTROUTING -t mangle -o br0 -m mark --mark 0x80080000/0xc03f0000 -p tcp --sport 443 -j MARK --set-mark ${Default_mark_down} &> /dev/null #Gaming (2/3) - Routes "Gaming" traffic coming from port 80 into "Defaults"
iptables -A POSTROUTING -t mangle -o br0 -m mark --mark 0x80080000/0xc03f0000 -p tcp --sport 443 -j MARK --set-mark ${Default_mark_down}
iptables -D POSTROUTING -t mangle -o br0 -d 192.168.1.198/32 -m mark --mark 0x80000000/0x8000ffff -p tcp -m multiport ! --sports 443,80 -j MARK --set-mark ${Gaming_mark_down} &> /dev/null #Gaming (3/3) - Routes Unidentified Traffic into "Gaming", instead of "Others", for LAN clients specified
iptables -A POSTROUTING -t mangle -o br0 -d 192.168.1.198/32 -m mark --mark 0x80000000/0x8000ffff -p tcp -m multiport ! --sports 443,80 -j MARK --set-mark ${Gaming_mark_down}
#iptables -D POSTROUTING -t mangle -o br0 -d 192.168.2.100/30 -m mark --mark 0x80000000/0x8000ffff -p udp -m multiport ! --sports 443,80 -j MARK --set-mark ${Gaming_mark_down} &> /dev/null #Gaming (3/3) - Routes Unidentified Traffic into "Gaming", instead of "Others", for LAN clients specified
#iptables -A POSTROUTING -t mangle -o br0 -d 192.168.2.100/30 -m mark --mark 0x80000000/0x8000ffff -p udp -m multiport ! --sports 443,80 -j MARK --set-mark ${Gaming_mark_down}
##DOWNLOAD (INCOMMING TRAFFIC) CUSTOM RULES END HERE
}
iptable_up_rules(){
#wan="ppp0" ## WAN interface over-ride for upload traffic -- Variable ONLY needs to be defined for users non-Rmerlin 384+ firmware
# RMerlin v384+ Firmware AUTOMATICALLY detects correct interface --> this variable should be left COMMENTED/DISABLED on RMerlin v384+
# Other firmwares are configured to assume an eth0 interface --> this variable should be manually set if the connection type differs from eth0 ( ppp0, vlanXXX, etc)
echo "Applying - Iptable Up Rules ($wan)"
##UPLOAD (OUTGOING TRAFFIC) CUSTOM RULES START HERE
iptables -D POSTROUTING -t mangle -o $wan -p udp --dport 500 -j MARK --set-mark ${VOIP_mark_up} &> /dev/null #Wifi Calling (1/2) - (All outgoing traffic w/ WAN destination port 500 goes to "VOIP" Traffic Container)
iptables -A POSTROUTING -t mangle -o $wan -p udp --dport 500 -j MARK --set-mark ${VOIP_mark_up}
iptables -D POSTROUTING -t mangle -o $wan -p udp --dport 4500 -j MARK --set-mark ${VOIP_mark_up} &> /dev/null #Wifi Calling (2/2) - (All outgoing traffic w/ WAN destination port 4500 goes to "VOIP" Traffic Container)
iptables -A POSTROUTING -t mangle -o $wan -p udp --dport 4500 -j MARK --set-mark ${VOIP_mark_up}
iptables -D POSTROUTING -t mangle -o $wan -p udp --sport 16384:16415 -j MARK --set-mark ${VOIP_mark_up} &> /dev/null #Facetime
iptables -A POSTROUTING -t mangle -o $wan -p udp --sport 16384:16415 -j MARK --set-mark ${VOIP_mark_up}
iptables -D POSTROUTING -t mangle -o $wan -m mark --mark 0x40080000/0xc03f0000 -p tcp --sport 80 -j MARK --set-mark ${Default_mark_up} &> /dev/null #Gaming (1/3) - Routes "Gaming" traffic going to port 443 into "Defaults"
iptables -A POSTROUTING -t mangle -o $wan -m mark --mark 0x40080000/0xc03f0000 -p tcp --sport 80 -j MARK --set-mark ${Default_mark_up}
iptables -D POSTROUTING -t mangle -o $wan -m mark --mark 0x40080000/0xc03f0000 -p tcp --sport 443 -j MARK --set-mark ${Default_mark_up} &> /dev/null #Gaming (2/3) - Routes "Gaming" traffic going to port 80 into "Defaults"
iptables -A POSTROUTING -t mangle -o $wan -m mark --mark 0x40080000/0xc03f0000 -p tcp --sport 443 -j MARK --set-mark ${Default_mark_up}
iptables -D POSTROUTING -t mangle -o $wan -s 192.168.1.198/32 -m mark --mark 0x40000000/0x4000ffff -p tcp -m multiport ! --dports 80,443 -j MARK --set-mark ${Gaming_mark_up} &> /dev/null #Gaming (3/3) - Routes Unidentified Traffic into "Gaming", instead of "Others", from specified LAN devices in rule (line 1/2)
iptables -A POSTROUTING -t mangle -o $wan -s 192.168.1.198/32 -m mark --mark 0x40000000/0x4000ffff -p tcp -m multiport ! --dports 80,443 -j MARK --set-mark ${Gaming_mark_up}
#iptables -D POSTROUTING -t mangle -o $wan -s 192.168.2.100/30 -m mark --mark 0x40000000/0x4000ffff -p udp -m multiport ! --dports 80,443 -j MARK --set-mark ${Gaming_mark_up} &> /dev/null #Gaming (3/3) - Routes Unidentified Traffic into "Gaming", instead of "Others", from specified LAN devices in rule (line 1/2)
#iptables -A POSTROUTING -t mangle -o $wan -s 192.168.2.100/30 -m mark --mark 0x40000000/0x4000ffff -p udp -m multiport ! --dports 80,443 -j MARK --set-mark ${Gaming_mark_up}
##UPLOAD (OUTGOING TRAFFIC) CUSTOM RULES END HERE
}