Pages

Monday, December 12, 2016

Day Night Bandwidth Script for CISCO L3 Switches by Linux


Day Night Bandwidth Script for CISCO L3 Switches by Linux

Create two files, One for Day which will start from 08:30am and Another for Night which will start from 06:10PM


crontab -e
30 8 * * 0-4   /usr/bin/bandwidth/CISCO-L3-Day
10 18 * * 0-4    /usr/bin/bandwidth/CISCO-L3-Night

### Day File create CISCO-L3-Day

vi /usr/bin/bandwidth/CISCO-L3-Day
#!/bin/sh
#Day Shift User Bandwidth Limit  for 192.168.10.10 L3 Switch
( echo open 192.168.10.10
  sleep 5
  echo UserName
  sleep 5
  echo Password
  sleep 1
  echo en
  sleep 1
  echo EnablePassword
  echo "conf t"
  sleep 1


####### User-1 Name ID etc for Day in fa0/3 interface #######

echo "interface FastEthernet0/3"
sleep 1
echo "no service-policy output 21mb"
sleep 1
echo "service-policy output 7mb"
sleep 1

####### User-2 Name ID etc for Day in fa0/4 interface #######

echo "interface FastEthernet0/4"
sleep 1
echo "no service-policy output 2mb"
sleep 1
echo "service-policy output 1mb"
sleep 1


echo "exit"
sleep 1
echo "exit"

echo some more output, etc. ) | telnet

################ End of Day File ###########

### Night File create CISCO-L3-Night

vi /usr/bin/bandwidth/CISCO-L3-Night
#!/bin/sh
#Day Shift User Bandwidth Limit  for 192.168.10.10 L3 Switch
( echo open 192.168.10.10
  sleep 5
  echo UserName
  sleep 5
  echo Password
  sleep 1
  echo en
  sleep 1
  echo EnablePassword
  echo "conf t"
  sleep 1


####### User-1 Name ID etc for Night in fa0/3 interface #######

echo "interface FastEthernet0/3"
sleep 1
echo "no service-policy output 7mb"
sleep 1
echo "service-policy output 21mb"
sleep 1

####### User-2 Name ID etc for Day in fa0/4 interface #######

echo "interface FastEthernet0/4"
sleep 1
echo "no service-policy output 1mb"
sleep 1
echo "service-policy output 2mb"
sleep 1


echo "exit"
sleep 1
echo "exit"

echo some more output, etc. ) | telnet

################ End of Night File #######################################
###########################################################################
Make Sure to create  Profile of policy-map to Switch 192.168.10.10 L3 Switch

policy-map 21mb
 class traffic
    police 21504000 2000000 exceed-action drop

policy-map 7mb
 class traffic
    police 7168000 2000000 exceed-action drop

policy-map 2mb
 class traffic
    police 2048000 2000000 exceed-action drop

policy-map 1mb
 class traffic
    police 1024000 1024000 exceed-action drop

############################################# Enjoy#####################