Syed Jahanzaib – Personal Blog to Share Knowledge !

March 10, 2023

Story about Mass migration of SLD / VLAN’s / IP Pool / Wifi Mesh Loop / Rectification of Bonjour mDNS using Parallel Topologies







This post is a quick reference notes for myself on how I managed to rectify some of long pending IT related issues which were left by previous network team, including AD Domain S.L.D migration to FQDN / Public IP scheme being used at Private LAN & its migration to multiple /24 Private IP Pools, Single default VLAN-1 migration to Different VLAN’s with smaller subnets.

The number of desktop/laptop/devices were in several hundreds. Downtime was not an option, therefore we managed to complete the task using parallel topologies for each segment.

Our existing network was running on default VLAN with /8 flat subnet, having each & every device on default VLAN-1 generating enormous number of broadcasts flooding causing network delays/timeout. There was no control on any switch segment, All switch edge port were set on Default roles making situation even worst from Spanning-Tree protocol flooding perspective. Above all like Cherry on the TOP, existing admin used public IP scheme with /8 subnet & many websites which were on this subnet over the internet, never worked on our network.

To over come these issues without any Downtime or disruption, I decided to sort issues on a one by one basis by creating parallel network, using below methods


SLD/FQDN Migration:

  • On same network, I added new FQDN A.D Domain, Established two way trust between both domains. Then using Microsoft migration tool (ADMT ), I start migrating users (one by one, targeted activity ) from old SLD to FQDN. More details are documented in another article.

Short Notes for Active Directory SLD to FQDN Cross Forest Migration – Using ADMT tool


*  Network Related *

We have Cisco L3 Stacked switch at data center & all departmental L2 switches are connected via 10G Fiber TRUNK links. To convert the existing Public IP scheme to Private without having any downtime, I I designed different VLAN’s scheme with smaller /24 private IP’s pool on per department basis, Created there SVI’s on main core switch stack. Using IP helper commands. I also created different vlans for management example different vlan for switch / access points / devices / servers & Users. I created DHCP relay pointed towards our domain controller. As I have to create parallel environment to avoid any downtime or any communication disruption, I didn’t changed any server’s device IP, rather On all server’s I create routes using ROUTE cmd) pointing to switch gateway (SVI) so that all devices can two way communicate with each other either its public or private.


Segmentation of different VLAN’s

Slowly gradually, we changed the Server’s/users/devices VLAN form 1 to new vlan scheme, & changed the DNS entries as well (Most of them auto updated there DNS entries at DC DNS upon rebooting or using Group Policy to enforce DNS registration every 30 minutes). New vlan users were able to communicate with older vlan-1 or x users because we configured CLASSLESS for each DHCP pool pointing to Core switch gateway using there corresponding gateways (SVI’s IP’s at Core L3 Switch).

Some Common Tuning we performed resulted in increased reliability of overall network

  • Most important set root bridge priority to 1 on L3 Core switch by setting the bridge priority to 1 then set all the others  switches to higher number. This will ensure the STP is built correctly
  • Subdivide the network into multiple VLAN’s & smaller logical subnets e.g. Servers, Users, Management vlans for switch n access points, devices like printers , time machines & NVR cameras, departmental vlans etc with each having a /24 e.g. 192.168.1.0/24, 192.168.2.0/24 and so on
  • On your core switch allocate SVI’s per required vlan
  • ensure each device can talk to each other using intervlan routing [exception to those who required firewalling/security]
  • Make all trunk uplinks 802.1q trunks [doesnt requires at new cisco IOS]
  • TAG / Associate ports on all switches with the appropriate vlans
  • Ensure all ports roles are defined properly, example edge / trunk ports
  • User connected EDGE port should be in access mode, & Portfast enabled along with BPDU enabled.
  • Disable all UNUSED ports (or make default sandbox VLAN for all unused ports & assign those ports with this sandbox VLAN, to ensure that unknown devices inserted in those ports should remain in sandbox VLAN
  • Make sure your Wifi APs are not meshing or bridging
  • I added all devices in DNS entries like printers etc , and at user end, added the required devices by DNS name, so that next time if any changes are required, modify the DNS entry only & no need to reconfigure the device at user end.

Some DRY theory on ACCESS/TRUNK Mode

  • An access port can have only one VLAN configured on the interface; it can carry traffic for only one VLAN. An access port transmits packets on only one VLAN (traffic is not tagged on this type of port). Portfast feature causes a switch port to enter the spanning tree forwarding state immediately, bypassing the listening and learning states. Portfast on switch ports connected to a single workstation or server allows those devices to connect to the network immediately, instead of waiting for the port to transition from the listening and learning states to the forwarding state.
  • Edge ports are configured such that they immediately go to the forwarding state. However, this does not mean that there is no loop protection. It is assumed that edge ports will connect to end devices, and thus it is convenient for them to go directly to the forwarding state. However, someone can try to plug in a switch on such a port and can try to become the root bridge or may connect to multiple ports and create a loop. That’s where you should use BPDUGuard. On all edge ports, BPDUGuard should be enabled so that as soon as such a port receives a BPDU, it will go into err-disabled state, thus preventing an L2 loop. Now keep in mind that for RSTP, if you don’t enable BPDUGuard, and a BPDU is received on an edge port, the edge port simply loses its edge port status.

Windows / Linux Route CMD’s for OS with Static IP

At user end, all routes were distributed via windows DHCP Classless routes which worked transparently fine. But server OS with static IP I had to provide proper routes according to our network. Example we have two gateways for internet at LAN, one is SANGFOR IAM for end users, second is Router/NGFW for server ends. Some times we have to route user/server at one or other gateway.

First get the Interface number via ROUTE PRINT CMD

  • route print

(Note down the interface name, example Interface number is 8)

Now add the appropriate gateway for intervlan routing & internet routing as well

*** WINDWOS OS / ADD PERMANENT ROUTES using ROUTE command

Note: -p syntax with route cmd adds the route on permanent basis (in registry)

# Below is an example for SERVER which is on 172.16.2.x VLAN , below is for INTERVLAN Routing for local subnet’s intervlan routing . 172.16.2.1 is the CORE Switch Gateway which have SVI’s configured,

route add -p 172.16.0.0 MASK 255.255.0.0 172.16.2.1 metric 1 IF 8
route add -p 192.168.0.0 MASK 255.255.0.0 172.16.2.1 metric 2 IF 8
# Below is for Internet access , 2 Gateways with priority pointing to Sangfor & NGFW Respectively (NGFW route is added as some port forwarding is done which is routed via NGFW)
route add -p 0.0.0.0 MASK 0.0.0.0 172.16.2.2 metric 3 IF 8
route add -p 0.0.0.0 MASK 0.0.0.0 172.16.2.6 metric 4 IF 8

*** LINUX / ADD PERMANENT ROUTES in interfaces FILE [Ubuntu ver 16 or below]

  • For older version of Linux (Ubuntu ver 16 or below) I added below in interfaces file
up route add -net 172.16.0.0 netmask 255.255.0.0 gw 172.16.2.1
down route del -net 172.16.0.0 netmask 255.255.0.0 gw 172.16.2.1
up route add -net 192.168.0.0 netmask 255.255.0.0 gw 172.16.2.1
down route del -net 192.168.0.0.0 netmask 255.255.0.0 gw 172.16.2.1
  • For new version of Ubuntu ver 18 & above, I used below [sample file shown below]

cat /etc/netplan/00-installer-config.yaml

network:
ethernets:
ens160:
dhcp4: false
addresses: [192.168.0.28/24]
nameservers:
# DNS server is on different VLAN
addresses: [192.168.1.71,192.168.1.72,8.8.8.8]

# STATIC ROUTES for INTERVLAN ROUTING, GW pointing to L3 Core Switch corresponding SVI
routes:
- to: 10.11.0.0/16
via: 192.168.0.1
- to: 10.10.0.0/16
via: 192.168.0.1
# FOR INTERNET , GW POINTING TO SANGFORIAM OR NGFW
- to: default
via: 192.168.0.6
version: 2

DHCP for Different VLAN Users

 

On Domain controller (Default route pointed towards L3 Core Switch SVI) I created multiple IP pool for corresponding VLAN users. At departmental L2 switches, I added corresponding VLAN’s & with the help of IP Helper at core switch, users get IP from the Domain controller DHCP server via there corresponding vlan pool. One by One all departments moved to different Vlan’s with smaller IP pool  resulting in dramatically decline in broadcast traffic. This improve network connectivity reliability at a greater extent.

 


IP Helper not working across VLAN’s

I got stucked at one point where ‘IP helper’ was not forwarding the other vlans (like vlan 10/11/12) users dhcp pkts to domain controller dhcp residing on default vlan-1 despite all settings seems correct, I contacted few Cisco / VM experts & they remotely checked in cisco & vm config in details & yet no one  was able to solved it. At Core switch there was this “no service dhcp” set & it was the culprit , as soon as I set it to service dhcp, & Alhamodlillah! all got sorted !

One example of IP helper at Wireless (with mDNS support) VLAN interface on L3 Core Switch

interface VlanXX
description WIFI_XXX-MOBILE-VLAN
ip address 10.0.0.1 255.255.255.0
ip helper-address 192.168.0.1
service-routing mdns-sd
service-policy-query querier 60
service-policy mypermit-all IN
service-policy mypermit-all OUT

VLAN’s in VMWARE ESXI

Configuring VLAN’s in ESXI was easiest part. The only thing at switch level was to configure TRUNK at which ESXI is connected to. On esxi server, I created new network (VLAN) & tag the required vlan to desired VM guest & Done.

Allah Shuker!


Ref:

Howto Add VLAN in ESXI Server

Following is quick short notes on howto add VLAN in ESXI Server

  • Login to ESXI (I am using VCSA to manage all esxi servers).
  • Now Goto Configure
  • Networking > Virtual Switches (NEXT)
  • Add Networking (NEXT)
  • Select ‘Virtual Machine Port Group for a Standard Switch’ (NEXT)
  • Select ‘Select an existing standard switch’ & click on BROWSE & select vSWITCH0 (NEXT)
  • In next window (Connection settings) at NETWORK LABEL , type suitable name like VLAN-100 / & under VLAN ID tab, type in the required VLAN ID example 100 (NEXT)
  • Click on (FINISH).

Done. Now you can assign this vlan to your desired VM Guest in its network adapter settings.


UniFi Access Points with Multiple SSID’s & VLANS

We have many wireless access points installed at various locations & all controlled centrally by UniFi controller software application. After addition of VLAN’s we decided to remove the default vlan1 SSID, & introduce new SSID based on targeted audience like XYZ-Corporate , XYZ-Mobile , XYZ-Guest & each SSID is tagged with different VLAN’s to control the users based on SSID type. The setup was straight forward. First We create separate VLAN for access points management e.g: VLAN100 & at all access points we changed the ips with vlan100 pool & set there default gateway to vlan-100 SVI configured ta Core Switch, Also we changed there management VLAN to VLAN-100.

  • Sample of IP/MGT VLAN setting on per AP Basis

  • Adding new VLAN ID in UniFi Controller Application

To add VLAN in UniFi Controller ,
Goto SETTINGS  > NETWORKS > & create new VLAN with VLAN-ID number,

  • Adding new SSID in UniFi Controller Application

Now to ADD SSID in UniFi Controller Application& tag with NEW VLAN-ID,
Goto SETTINGS  > WiFi > Create NEW Wifi , Now enter the name of SSID like XYZ-Corporate & in Network select the desired VLAN you created in earlier step

Warning: After applying any setting that needs to be synced to all access points in the group, traffic disruption & timeout to access points may occur upto 1or 2 minutes. Therefore perform such operations Only in Off-Peak hours.


UniFi Access Point – Trunk Port Config at Cisco Switch PORT

At Cisco switch where access points ethernet cable is attached. We did below config for that port,

interface GigabitEthernet1/0/20
description UniFi_AP_Finance
switchport mode trunk

This enabled to carry all vlans including AP Mgt / Different Vlan’s based on various SSID’s [each SSID tagged with different VLAN via Unifi Controller application]


UniFi Wireless Meshing Causing Loop/Broadcast

We noticed that whenever we modify any settings which requires syncing with All AP’s, then one by one AP’s freezes packet transmission connectivity & then get back online few 15-20 seconds but few access points uplink gets there uplink connectivity with another AP wireless (Meshing). This was also creating the loop broadcast. Disabling WIRELESS MESHING in Unifi Controller application & then readopting the AP’s reduced such events.


SANGFOR VLAN

To Provide internet access via sangfor to all vlan users, we added corresponding VLAN’s in SANGFOR IAM device, Each vlan sub-interface with corresponding IP to be used as gateway at corresponding VLAN users (all via DC DHCP)

To add corresponding VLAN’s in SANGFOR,

Goto System > Network / Deployment / Settings > & under LAN interface Page add as per below

10/10.10.10.3/255.255.255.0

Whereas 10/ is the cisco VLAN number, and then the IP of this sub interface &  then the subnet

Warning: After modifying any network related settings, SANGFOR Network services will be restarted, & may cause traffic disruption, therefore perform such actions in off-peak hours.


TIPS:

Bonjour (mDNS) discovery across different VLAN’s (Wired/WiFi)

After segregated network into smaller subnets along with separate vlans for wired/wifi users/devices etc, users were not able to *cast/discover* LCD TV /  MFD Printers if both are on different vlans. (they works fine if the device & user are on same vlan/subnet).  If wired user on vlan2 tries to connect with LCD (on wifi)  on vlan3, he cannot. if they are on same vlan they can connect fine. This is because broadcast doesnt’ works across different vlan.

In UniFi Controller, there is an option of enabling mDNS which is a service provided by a Unifi router like USG, UXG Pro or UDM. but since we didn’t had any UniFi router/switch therefore UniFi mDNS didn’t had any mDNS functionality and it didn’t worked. We had to configure the service to repeat broadcasts across VLANs using Cisco switches.

The solution was to enable the mDNS ‘service discovery’ at Core L3 Switch.

At core switch where all SVI’s are configured, I allowed mDNS service on particular VLAN’s (wired/wifi) using below CMD’s & the problem got sorted out.

interface VlanXX
description WIFI_MOBILE-VLAN
ip address X.X.X.X 255.X.X.X
ip helper-address X.X.X.X
service-routing mdns-sd
service-policy-query querier 60
service-policy mypermit-all IN
service-policy mypermit-all OUT
end

I will keep updating this article as I get free time

Regards
Syed Jahanzaib

January 11, 2021

Cisco 10G Switch & Lenovo SFP Module Compatibility issue

Filed under: Cisco Related — Tags: , , , , — Syed Jahanzaib / Pinochio~:) @ 11:46 AM

Recently we acquired cisco 10g SFP+ switch to be added in existing stack. While trying to connect Lenovo ThinkSystem SR650 (P.No: 7X06CTO1WW ) server along with lenovo provide SFP+ modules (P.No 46C3447) with 10g Cisco switch (WS-C3850-24XS-S) via MM Fiber cable. Upon SFP+ module insertion, at both end (server to switch) then the port gets shuts with err-disabled with following error on switch logs

010834: Jan 4 09:43:44: %GBIC_SECURITY_CRYPT-4-VN_DATA_CRC_ERROR: GBIC in port Te1/0/7 has bad crc
010836: Jan 4 09:43:44: %PM-4-ERR_DISABLE: gbic-invalid error detected on Te1/0/7, putting Te1/0/7 in err-disable state

& on vmware esxi  , it showed *DISCONNECTED*

Following were technical details:

SEVER END:

  • ThinkSystem SR650 (P.No: 7X06CTO1WW )
  • 10g NIC: Emulex VFA5.2 2×10 GbE SFP+ PCIe Adapter (P.No: AT7S )
  • 10g SFP+ Module: Lenovo SFP 10gbase-sr Fiber Optic Transceiver Module (P.No 46C3447 / )

SWITCH END:

  • SWITCH MODEL : Cisco 10g SFP+ switch (P.No: WS-C3850-24XS-S )
  • Cisco Switch 10GBASE Fiber Optic SFP 10G Transceiver Module: Cisco SFP-10G-SR * Part No: 10-2415-03)
  • Vivanco Optical Fiber Patch Cord: LC-LC MM DUPLEX OM3 10M

Solution:

After searching here & there, I found that we have to disable SFP compatibility check in the switch using below CMD’s

Add these two commands (blue highlighted) to the switch:

Switch(config)# service unsupported-transceiver
— you will get a warning message here—
Switch(config)# no errdisable detect cause gbic-invalid

Afterwards , shut/no shut the switch interface then plugged in the Lenovo cable back in.  & the connectivity got OK. (make sure WRITE the config on switch so that it stays permanent.

Note: Any time non-Cisco optics are going to be plugged in to a Cisco switch it’s worth adding these commands.


Regard’s
Syed Jahanzaib

May 15, 2020

Mikrotik to Mikrotik/Cisco Bonding – Reference Notes

Filed under: Cisco Related, Mikrotik Related — Tags: , , , , — Syed Jahanzaib / Pinochio~:) @ 2:40 PM

aggregated

cisco bonding mikrotik to cisco

2 ports bonding

4ports_bonding

2020-05-13 13.19.04

This post was made for self reference purposes, so that I can find the configs easily from this page when needed again.


This post describes possible methods of creating ethernet interfaces bonding between Mikrotik to Cisco (etherchannel) or Mikrotik to Mikrotik to achieve load balancing & failover to achieve higher speed from multiple ethernet interfaces. Bonding is a technology that allows aggregation of multiple Ethernet-like interfaces into a single virtual link, thus getting Maximum Throughput and providing failover. You can use this technique to create bonding between WAN Cisco switch/R to User Mikrotik, then from User mikrotik to User distribution vlan switch. lots of combinations you can create in this regard.

Possible Scenarios:

OP have Mikrotik CCR1036 routerboard with SFP+. ISP have given OP with 10G of SFP+ connectivity on OP WAN Mikrotik router. but on user side router OP have simple CCR1036 with 1G ports only. So the wan link from 1036-wan to 1036-LAN is choking at  1G. Proper solution is to have back to back 10G connectivity between all routers, but since it requires cash investment, therefore the OP sometimes chooses workaround to fulfill the requirements for the time being. BONDING is one of that workaround that can be chosen. although I try to avoid using it as much as possible & always look for 10/25G solutions.


Hardware Used in this post

  • Mikrotik: RB2011
  • Cisco 36450 24 Ports Switch
  • In general you can use upto 8 ports Bonding, should be of same type/speed.
  • All ports should be enabled before adding them to bond.

Option-1# Mikrotik to Cisco Bonding (using 1Gx2 interfaces to achieve failover / load balancing / higher speed)

Using any two interfaces, we are creating 2 port Bonding interface. Example from Mikrotik Port 9 & 10 we will connect two cables connected to Cisco Switch port 23 & 24.

#Mikrotik Example Code , using port 9 & 10

/interface bonding
add link-monitoring=none mode=802.3ad name=bonding1-lan slaves=ether9,ether10 transmit-hash-policy=layer-2-and-3

# Cisco Switch Example Code, suing port 23 & 24

configure terminal
inter range gigabitEthernet 1/0/23-24
channel-group 1 mode active
channel-protocol lacp
#on newer IOS you dont need following CMD
#switchport trunk encapsulation dot1q
switchport mode trunk

Note: If you are doing Cisco to Cisco Port Bonding , then you need to repeat above code on 2nd switch too

Option-2# Mikrotik to Mikrotik Bonding

Its very simple. Just issue below command on both mikrotik and connect the cables from designated interfaces, assign IP, and you are good to go …

/interface bonding
add name=bonding1-to-ppp slaves=ether1,ether2

Some Helpful CMD’s related to etherchannel on Cisco switch …

show etherchannel summary
show etherchannel 1 port-channel
show interfaces etherchannel

Note: Before you connect both cable, make sure to add the config on Mikrotik & Cisco side, Else cisco port will get shut dueto STP protection to avoid loop.

*May 13 04:58:33.710: %ETC-5-L3DONTBNDL2: Gi1/0/23 suspended: LACP currently not enabled on the remote port.

Configuring EtherChannel Load Balancing

 

To view etherchannel load balancing setting, use the show command …

enable
show etherchannel load-balance

To configure load balancing, use the following commands:

enable
configure terminal
port-channel load-balance dst-mac
do wr

Regard’s
Syed Jahanzaib

December 16, 2019

TACACS+ Cisco centralized authentication server

Filed under: Cisco Related — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 3:29 PM

tacacs plus server.png

Disclaimer:

My humble request, Kindly donot consider me as an expert on this stuff, I am NOT certified in anything Mikrotik/Cisco/Linux or Windows. However I have worked with some core networks and I read , research & try stuff all of the time. When you are enslaved by private job & working as one man army, you have to perform many task in which you are not formally trained for. So I am not speaking/posting about stuff I am formerly trained in, I pretty much go with experience and what I have learned on my own. And , If I don’t know something then I read & learn all about it.

So , please don’t hold me/my-postings to be always 100 percent correct. I make mistakes just like everybody else. However – I do my best, learn from my mistakes and try to help others


TACACS+

Terminal Access Controller Access-Control System (TACACS, usually pronounced like tack-axe) refers to a authentication / authorization related services for cisco switches/routers/firewalls access control through a centralized server. With the help of Tacacs+ you can set up a much more granular level access for the users, groups, subnets or device type etc. Example which user can issue which commands on switches etc.

 

central auth server.jpeg

 

Hardware Software Components used in this guide:

In this post I have used

  • Ubuntu 18 server edition for TACACS+ deployment / IP: 101.11.11.254
  • Cisco WS-C3850-24T switch / IOS Version 16.3.9 [Denali]

Quick Notes:

TACACS Server installation

apt-get -y install tacacs+

Once the installation is done , we will modify or add the tacacs+ server default config file to to suite our needs. On default installation, the configuration file is found here /etc/tacacs+/tac_plus.conf

nano /etc/tacacs+/tac_plus.conf

Remove existing configuration, and use below sample config, make sure to change the KEY, id pass as required

# Key is like password or shared secret, make sure to make it strong

key = testing123
accounting file = /var/log/tacplus.log
#default authentication = file /etc/passwd
group = admins {
default service = permit
service = exec {
priv-lvl = 15
}
}

# For support group, we are allowing only specific sets of CMD only
group = support {
default service = deny
service = shell {
priv-lvl = 15
}
cmd = show {
permit version.*
permit clock.*
permit interface.*
permit running-config.*
permit logging.*
}
cmd = configure {
permit .*
}
cmd = interface {
permit .*
}
cmd = vlan {
permit .*
}
cmd = switchport {
permit .*
}
cmd = write {
permit .*
}
}

#Create local user here
user = admin {
login = cleartext admin123
name = "Admin Group"
member = admins
}
user = support {
login = cleartext support123
name = "Network Support"
member = support
}<span style="color:var(--color-text);">


 

& if all configuration is OK , you should get something like below …

 * Checking TACACS+ authentication daemon configuration files successful tacacs+

Restart tacacs+ service

/etc/init.d/tacacs_plus restart

Next up we will make changes to the Cisco switch ,
in this example am using a Cisco switch WS-C3850-24T and the one working configuration look like this:

Note: This is just basic example. It may be not well tuned insecure too but for test it will work fine.


Switch configuration

enable
conf t

aaa new-model
aaa authentication login default group tacacs+ local
aaa authentication enable default enable
aaa authorization config-commands
aaa authorization commands 1 support group tacacs+ local
aaa authorization commands 15 admins group tacacs+ local
aaa accounting commands 1 support-act1 start-stop group tacacs+
aaa accounting commands 15 admins-act15 start-stop group tacacs+
login on-success log

# change tacacs IP address / KEY as per your local network
tacacs-server host 101.11.11.254
tacacs-server key 0 testing123

!
line con 0
exec-timeout 35791 0
privilege level 15
stopbits 1
line aux 0
no exec
stopbits 1
line vty 0 3
privilege level 15
authorization commands 1 support
authorization commands 15 admins
accounting commands 1 support-act1
accounting commands 15 admins-act15
length 0
transport input ssh
line vty 4
exec-timeout 35791 0
privilege level 15
authorization commands 1 support
authorization commands 15 admins
length 0
transport input ssh
line vty 5 15
length 0
!

do wr

Done.

Now try to login to switch with support account & execute try to permitted / non-permitted commands.

Result for SUPPORT ACCOUNT

login as: support
Using keyboard-interactive authentication.
Password:

spare-sw#ping 101.11.11.254
Command authorization failed.

spare-sw#show clock
*10:24:07.527 UTC Mon Dec 16 2019

spare-sw#sh inter
spare-sw#sh interfaces status

Port Name Status Vlan Duplex Speed Type
Gi1/0/1 notconnect 1 auto auto 10/100/1000BaseTX
Gi1/0/2 notconnect 1 auto auto 10/100/1000BaseTX
Gi1/0/3 notconnect 1 auto auto 10/100/1000BaseTX
Gi1/0/4 notconnect 1 auto auto 10/100/1000BaseTX
Gi1/0/5 notconnect 1 auto auto 10/100/1000BaseTX
Gi1/0/6 notconnect 1 auto auto 10/100/1000BaseTX
Gi1/0/7 notconnect 1 auto auto 10/100/1000BaseTX
Gi1/0/8 notconnect 1 auto auto 10/100/1000BaseTX
Gi1/0/9 notconnect 1 auto auto 10/100/1000BaseTX
Gi1/0/10 notconnect 1 auto auto 10/100/1000BaseTX
Gi1/0/11 notconnect 1 auto auto 10/100/1000BaseTX

spare-sw#

 



Regard’s
Syed Jahanzaib

December 3, 2019

Cisco Switch: Upgrading Firmwares & Recovering from Failed ones !

Filed under: Cisco Related — Tags: , , , , , , , , — Syed Jahanzaib / Pinochio~:) @ 9:56 AM

If it ain’t broke, don’t fix it ! So true 🙂 Z@ib


advise on upgrade of switch fw.PNG


Quick notes for myself: Disclaimer! This is important!

My humble request is that kindly donot consider me as an expert on this stuff, I am NOT certified in anything Mikrotik/Cisco/Linux or Windows. However I have worked with some core networks and I read , research & try stuff all of the time. When you are enslaved by private job & working as one man army, you have to perform many task in which you are not formally trained for. So I am not speaking/posting about stuff I am formerly trained in, I pretty much go with experience and what I have learned on my own. And , If I don’t know something then I read & learn all about it.

So , please don’t hold me/my-postings to be always 100 percent correct. I make mistakes just like everybody else. However – I do my best, learn from my mistakes and try to help others

Maybe this post will help some other novice like me

Regard’s
Syed Jahanzaib


WS-C3650-48PD

Fortunately this model have nice GUI which supports easy upgrade of firmwares , therefore I used it to upgrade to latest stable build Fuji-16.9.4

365048pdl fw upgrade.PNG


SG300-28PP/SG500-52PP

This model also have nice GUI which supports easy upgrade of firmwares , therefore I used it to upgrade to latest stable build

https://www.cisco.com/c/en/us/support/switches/sg500-52-52-port-gigabit-stackable-managed-switch/model.html#~tab-downloads

sg300-500.PNG


3750X-48T-S

.

WS-C3750E-24TD

OLD version:

WS-C3750E-24TD     12.2(40)SE

3750 fw old.PNG

Steps for Upgrade:

First setup new or use existing TFTP server, download the new firmware from

https://software.cisco.com/download/home/280831016/type/280805680/release/15.0.2-SE11?i=!pp

& copy the firmware file (.BIN format) in TFTP root folder. Now from switch console , copy the file from TFTp into switch FLASH

copy tftp: flash:

It will ask the tftp server IP, and source/destination file name, fill them up as per your local scenario

>Address or name of remote host? <IP_ADDRESS_OF_TFTP_SERVER>
>source filename? <IMAGE_NAME.bin>
>Destination filename? <IMAGE_NAME.bin>
conf t
boot system flash:<IMAGE_NAME.bin>
exit
wr
reload

after this switch will reboot , and new firmware will be overwritten.

New version:

Release 15.0.2-SE11 MD

3750 fw new.PNG

 


WS-C3850-24T

Notes:

With this model, I encountered few issues in upgrading 3850 switch.

  • Gibralter 16.12.1 ED : 3850 / Switch was doing reboot in loop with following error

Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(1,0)

  • Fuji 16.9.4 MD : 3850 / Switch Port Orange Light issue

With this upgrade , switch booted but all ports lights runed to amber.

  • Denali 16.3.9 MD : 3850 / Well tested , worked OK

Therefore I reverted back to to Denali-16.3.9 which worked fine & stable.

Steps for Upgrade:

First setup new or use existing TFTP server, download the new firmware from

https://www.cisco.com/c/en/us/support/switches/catalyst-3850-24t-s-switch/model.html#~tab-downloads

>Address or name of remote host? <IP_ADDRESS_OF_TFTP_SERVER>
>source filename? <IMAGE_NAME.bin>
>Destination filename? <IMAGE_NAME.bin>
conf t
software install file flash:cat3k_caa-universalk9.16.03.09.SPA.bin new force verbose

after this switch will ask to reload , do so to apply changes

New version:

16.3.9

3850 new ver.PNG


Recovering from IOS FAILED upgrade on 3850 Switch

after the Gibralter firmware upgrade , 3850 switch wen into reboot loop.

Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(1,0)

More infor on this issue mentioned here @ https://community.cisco.com/t5/switching/catalyst-c3850-gibraltar-16-12-1-ed/td-p/3907723

After entering recovery mode , I made the situation worsen by deleting some flash files. This is how I recovered from this situation.

from the switch Management port, connect a cable directly to your laptop/desktop & assign any private IP on the system like 192.168.99.1/24. Install any free TFTP server like SOLARWINDS TFTP Server. copy the stable firmware like DENALI 16.0.3.09 in the tftp root folder.

cat3k_caa-universalk9.16.03.09.SPA.bin

Now using any terminal tool like putty, connected to switch via CONSOLE port, press MODE button while booting & entered RECOVERY mode. & issued following CMD’s

  • flash_init
  • mgmt_init
  • set IP_ADDR 192.168.99.2/255.255.255.0
  • set default_router 192.168.99.1
  • emergency-install tftp://192.168.99.1/cat3k_caa-universalk9.16.03.09.SPA.bin

There was another easy method by connecting USB into usb port of switch, but since switch may not recognize most modern usb’s , therefore I had to take a long route of TFTP.

To read in more details , refere following post

http://blog.unolution.com/networking/how-to-recover-a-cisco-switch-3560x-3750x-from-boot-loader/


Regard’s
Syed Jahanzaib

 

January 16, 2019

BASH script to monitor Cisco Switch Port Status

Filed under: Cisco Related, Linux Related — Tags: , , , , , , — Syed Jahanzaib / Pinochio~:) @ 10:55 AM

portmonitor

2019-01-17 10.05.47.jpg

Following script was designed for an OP who wanted to monitor his cisco switch ports status via linux base bash script.

  • Created: February, 2016
  • Revision: January, 2019

 

OP Requirements:

  • We need a bash script that can acquire ports status of Cisco switch using SNMP query & act accordingly based on the results, example send sms/email etc,
  • The script should first check target device network connectivity by ping, if PING NOT responding, Exit,
  • If ping OK, then check SNMP status, if SNMP NOT responding, then error report, & Exit,
  • If Ping / SNMP responds OK, then check the port status, if port status is NOT UP , then send email/sms alert 1 time until next status change.

Hardware / Software Used in this post:

  • Cisco 3750 24 Gigabit Ports Switch
  • Ubuntu 12.4 Server Edition
  • Bash Script
  • SNMP support enabled on Cisco switch to query port status using MIB names

Solution:

I made following script which checks PING/SNMP status, and then Port Status of Cisco 3750 Switch. This is just an example. You can use your own techniques to acquire the same result. This is fully tested and working script. There are many other ways to do the same like using any NMS app like Nagios, or DUDE which have good GUI control so no need to do coding in the dark : )

Surely this contains too much junk or some unwanted sections, so you may want to trim it according to your taste and requirements.

Regard’s
Syed Jahanzaib


  1. Install SNMP MIBS

First we need to make sure that MIB are installed, Do so by

sudo apt-get install -y snmp
apt-get install -y snmp-mibs-downloader
sudo download-mibs

After this , Add SNMP Mibs entry in

/etc/snmp/snmp.conf

by adding this line

mibs +ALL

Save & Exit

Now query your switch by following command to see if snmpwalk is working …

root@Radius:/temp# snmpwalk -v1 -c wl 10.0.0.1 IF-MIB::ifOperStatus

& you should see something line below if SNMP is working …

IF-MIB::ifOperStatus.1 = INTEGER: up(1)
IF-MIB::ifOperStatus.17 = INTEGER: up(1)
IF-MIB::ifOperStatus.5182 = INTEGER: down(2)
IF-MIB::ifOperStatus.5183 = INTEGER: down(2)
IF-MIB::ifOperStatus.5184 = INTEGER: down(2)
IF-MIB::ifOperStatus.10601 = INTEGER: up(1)
IF-MIB::ifOperStatus.10602 = INTEGER: down(2)
IF-MIB::ifOperStatus.10603 = INTEGER: down(2)
IF-MIB::ifOperStatus.10604 = INTEGER: down(2)
IF-MIB::ifOperStatus.10605 = INTEGER: up(1)
IF-MIB::ifOperStatus.10606 = INTEGER: up(1)
IF-MIB::ifOperStatus.10607 = INTEGER: up(1)
IF-MIB::ifOperStatus.10608 = INTEGER: up(1)
IF-MIB::ifOperStatus.10609 = INTEGER: up(1)
IF-MIB::ifOperStatus.10610 = INTEGER: up(1)
IF-MIB::ifOperStatus.10611 = INTEGER: up(1)
IF-MIB::ifOperStatus.10612 = INTEGER: up(1)
IF-MIB::ifOperStatus.10613 = INTEGER: up(1)
IF-MIB::ifOperStatus.10614 = INTEGER: up(1)
IF-MIB::ifOperStatus.10615 = INTEGER: up(1)
IF-MIB::ifOperStatus.10616 = INTEGER: up(1)
IF-MIB::ifOperStatus.10617 = INTEGER: up(1)
IF-MIB::ifOperStatus.10618 = INTEGER: up(1)
IF-MIB::ifOperStatus.10619 = INTEGER: up(1)
IF-MIB::ifOperStatus.10620 = INTEGER: up(1)
IF-MIB::ifOperStatus.10621 = INTEGER: up(1)
IF-MIB::ifOperStatus.10622 = INTEGER: up(1)
IF-MIB::ifOperStatus.10623 = INTEGER: up(1)
IF-MIB::ifOperStatus.10624 = INTEGER: up(1)
IF-MIB::ifOperStatus.10625 = INTEGER: down(2)
IF-MIB::ifOperStatus.10626 = INTEGER: down(2)
IF-MIB::ifOperStatus.10627 = INTEGER: down(2)
IF-MIB::ifOperStatus.10628 = INTEGER: down(2)
IF-MIB::ifOperStatus.14501 = INTEGER: up(1)

OR getting UP/DOWN result for particular port (port 10)

snmpwalk -v1 -c wl 10.0.0.1 IF-MIB::ifOperStatus.10610 -Oqv

Output Result:

up

 

 


the Script!

  • mkdir /temp
  • cd /temp
  • touch monitor_sw_port.sh
  • chmod +x monitor_sw_port.sh
  • nano monitor_sw_port.sh

and paste following, make sure to edit all info accordingly…

#!/bin/bash
#set -x
# Script to check Cisco Switch Port Status and send alert accordingly
# It will first check PING, then SNMP Status, then PORT status & act accordingly
# Email: aacable at hotmail dot com / http : // aacable . wordpress . com
# 15-Jan-2019
HOST="$1"
PORT="$2"
SNMP="public"
DEVNAME="ZAIB_Main_Switch"
HOSTNAME=`hostname`
TEMP="temp"
COMPANY="ZAIB (Pvt) Ltd."
DATE=`date`
# GMAIL DETAILS
GMAILID="MYGMAIL@gmail.com"
GMAILPASS="GMAIL_PASS"
ADMINMAIL1="aacableAThotmail.com"
SENDMAIL="/temp/sendEmail-v1.56/sendEmail"
# SMS RELATED and KANNEL INFO
# KANNEL SMS Gateway Info
KANNELURL="127.0.0.1:13013"
KANNELID="kannel"
KANNELPASS="KANNEL_PASS"
CELL1="03333021909"
PING_ATTEMPTS="2"
HOST_PING_STATUS="/$TEMP/$HOST.$PORT.ping"
HOST_PORT_STATUS="/$TEMP/$HOST.$PORT.port"
LAST_DOWNTIME_HOLDER="/$TEMP/$HOST.$PORT.last_down.status.txt"
touch $HOST_PING_STATUS
touch $HOST_PORT_STATUS
touch $LAST_DOWNTIME_HOLDER
# If ip parameters are missing, then inform & exit
if [ -z "$HOST" ];then
echo "Error: IP missing, Please use this,
./monitor_sw_port.sh 10.0.0.1 10601"
exit 1
fi
# If port parameters are missing, then inform & exit
if [ -z "$PORT" ];then
echo "Error: PORT number missing, Please use this,
./monitor_sw_port.sh 10.0.0.1 10601"
exit 1
fi
# Test PING to device
count=$(ping -c $PING_ATTEMPTS $HOST | awk -F, '/received/{print $2*1}')
if [ $count -eq 0 ]; then
echo "$HOST $DEVNAME is not responding to PING Attempts, cannot continue without , por disable ping check] !"
exit 1
else
echo "- PING Result : OK"
fi
# Test SNMP Result of device
snmpwalk -v1 -c $SNMP $HOST SNMPv2-MIB::sysDescr.0 > /tmp/$HOST.$PORT.snmp.status.txt
if [ ! -f "/tmp/$HOST.$PORT.snmp.status.txt" ]; then
echo "- ALERT: ..... $HOST $DEVNAME is not responding to SNMP Request, Cannot continue without it ... Exit"
exit 1
else
echo "- SNMP Result : OK"
fi
# If all OK, then pull Port Description
PORT_DERSCRIPTION=`snmpwalk -v1 -c $SNMP $HOST IF-MIB::ifDescr.$PORT -Oqv`
# Check if folder exists, if not create one and continue
if [ ! -d "/$TEMP" ]; then
echo
echo
echo "/$TEMP folder not found, Creating it so all ping results should be saved there . . ."
mkdir /$TEMP
fi
### START ACTION
################################
### CHECK PORT STATUS - for UP #
################################
CHKPORT=`snmpwalk -v1 -c $SNMP $HOST IF-MIB::ifOperStatus.$PORT -Oqv`
#CHKPORT="up"
# If Port number does not exists, then inform and exit
if [ -z "$CHKPORT" ]; then
echo "ALERT: .... Port number $PORT NOT found on $HOST $DEVNAME , Please check Port Number, Exiting ..."
exit 1
fi
#########################################
# SMS/EMAIL Messages for PORT UP / DOWN #
#########################################
# Temporary file holder for PORT DOWN/UP storing sms/email
PORT_DOWN_MSG_HOLDER="/$TEMP/$HOST.$PORT.down.msg"
PORT_UP_MSG_HOLDER="/$TEMP/$HOST.$PORT.up.msg"
echo "ALERT:
$DEVNAME $HOST port $PORT $PORT_DESCRIPTION is DOWN @ $DATE
$COMPANY" > $PORT_DOWN_MSG_HOLDER
echo "INFO:
$DEVNAME $HOST port $PORT $PORT_DESCRIPTION is OK @ $DATE!
$COMPANY" > $PORT_UP_MSG_HOLDER

PORT_DERSCRIPTION=`snmpwalk -v1 -c $SNMP $HOST IF-MIB::ifDescr.$PORT -Oqv`
HOST_PORT_DOWN_ALERTONSCREEN="ALERT: .... $HOST $DEVNAME port nummber $PORT $PORT_DERSCRIPTION is DOWN @ $DATE"
HOST_PORT_UP_ALERTONSCREEN="INFO: .... $HOST $DEVNAME port nummber $PORT $PORT_DERSCRIPTION is OK @ $DATE"
# Check if port is UP
if [ "$CHKPORT" = "up" ]; then
echo -e "$HOST_PORT_UP_ALERTONSCREEN"
# Check if port isUP and its previous state was DOWN, then send UP sms/email
if [ $(grep -c "$HOST" "$HOST_PORT_STATUS") -eq 1 ]; then
echo "INFO: This port was previosuly DOWN, and now its UP ,Sending UP SMS 1 time only"
# Sending PORT DOWN ALERT via EMAIL
$SENDMAIL -u "$HOST_PORT_UP_ALERTONSCREEN" -o tls=yes -s smtp.gmail.com:587 -t $ADMINMAIL1 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o message-file=$PORT_UP_MSG_HOLDER -o message-content-type=text
# Sending PORT DOWN ALERT via SMS using KANNEL SMS Gateway
cat $PORT_UP_MSG_HOLDER | curl "http://$KANNELURL/cgi-bin/sendsms?username=$KANNELID&password=$KANNELPASS&to=$CELL1" -G --data-urlencode text@-
sed -i "/$HOST/d" "$HOST_PORT_STATUS"
fi
fi
##################################
### CHECK PORT STATUS - for DOWN #
##################################
if [ "$CHKPORT" = "down" ]; then
echo "$HOST_PORT_DOWN_ALERTONSCREEN"
#check if port staus was previosly UP, then act
if [ $(grep -c "$HOST" "$HOST_PORT_STATUS") -eq 1 ]; then
echo "ALERT: ..... $HOST $DEVNAME port $PORT $PORT_DERSCRIPTION is DOWN. SMS have already been sent."
fi
if [ $(grep -c "$HOST" "$HOST_PORT_STATUS") -eq 0 ]; then
echo "ALERT: ..... $HOST $DEVNAME port $PORT $PORT_DERSCRIPTION is now down! - SENDING PORT DOWN SMS ..."
echo "$HOST" > $HOST_PORT_STATUS
echo "SMS Sent FOR $HOST $DEVNAME port $PORT $PORT_DERSCRIPTION DOWN have been sent only 1 time until next status change ..."
# Sending PORT DOWN ALERT via EMAIL
$SENDMAIL -u "$HOST_PORT_DOWN_ALERTONSCREEN" -o tls=yes -s smtp.gmail.com:587 -t $ADMINMAIL1 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o message-file=$PORT_DOWN_MSG_HOLDER -o message-content-type=text
# Sending PORT UP ALERT via SMS
cat $PORT_DOWN_MSG_HOLDER | curl "http://$KANNELURL/cgi-bin/sendsms?username=$KANNELID&password=$KANNELPASS&to=$CELL1" -G --data-urlencode text@-
fi
fi
####################
# SCRIPT ENDS HERE #
# SYED JAHANZAIB #
####################

Usage:

change the IP and port number.

  • /temp/monitor_sw_port.sh 10.0.0.1 10610

You can add entry in cron like this

# Check for Service remote host port status
*/5 * * * * /temp/portmon.sh 10.0.0.1 10610

RESULT:

SMS result:
2019-01-17 10.05.47.jpgEmail Result:

email alert on port down vlan.PNG

# Monitoring Port # 10 , when port is DOWN ...

root@Radius:/temp# ./monitor_sw_port.sh 10.0.0.1 10610
- PING Result : OK
- SNMP Result : OK
ALERT: .... 10.0.0.1 WL_Main_Switch port nummber 10610 GigabitEthernet2/0/10 is DOWN @ Tue Jan 15 12:44:45 PKT 2019
ALERT: ..... 10.0.0.1 WL_Main_Switch port 10610 GigabitEthernet2/0/10 is DOWN. SMS have already been sent.

root@Radius:/temp# ./monitor_sw_port.sh 10.0.0.1 10610
- PING Result : OK
- SNMP Result : OK
ALERT: .... 10.0.0.1 WL_Main_Switch port nummber 10610 GigabitEthernet2/0/10 is DOWN @ Tue Jan 15 12:44:51 PKT 2019
ALERT: ..... 10.0.0.1 WL_Main_Switch port 10610 GigabitEthernet2/0/10 is DOWN. SMS have already been sent.

# Monitoring Port # 10 , when port is UP now ...
root@Radius:/temp# ./monitor_sw_port.sh 10.0.0.1 10610
- PING Result : OK
- SNMP Result : OK
INFO: .... 10.0.0.1 WL_Main_Switch port nummber 10610 GigabitEthernet2/0/10 is OK @ Tue Jan 15 12:45:01 PKT 2019
INFO: This port was previosuly DOWN, and now its UP ,Sending UP SMS 1 time only
Jan 15 12:45:11 radius sendEmail[18700]: Email was sent successfully!
0: Accepted for delivery

# Monitoring Port # 10 , when port is working UP ...
root@Radius:/temp# ./monitor_sw_port.sh 10.0.0.1 10610
- PING Result : OK
- SNMP Result : OK
INFO: .... 10.0.0.1 WL_Main_Switch port nummber 10610 GigabitEthernet2/0/10 is OK @ Tue Jan 15 12:45:12 PKT 2019

April 11, 2018

Short Notes for Cisco 3850-24T IOS XE Upgrade & Stack Configuration

Filed under: Cisco Related — Tags: , — Syed Jahanzaib / Pinochio~:) @ 3:49 PM

ZAIB_ Cisco 3850- 24-t.jpg

 


1# Upgrade Firmware of Cisco 3850 24T-S (INSTALL MODE) by copying FW from TFTP to Switch Flash Directory

Read these first on BUNDLE vs INSTALL mode.

http://blog.qsolved.com/2014/02/what-are-methods-to-boot-and-run-ios-xe.html

http://wannabelab.blogspot.com/2015/09/cisco-catalyst-3650-ios-recovery-via-usb.html

Last week we received new Cisco switches shipment having model WS-C3850-24T which will be replacing existing 3750 stack series in our data center. These switches have 2 methods of booting and running IOS XE software (in 3850).  By default, the switches comes with INSTALL mode. 

Before Upgrading Firmware ,we need to check for current mode in which the switch is currently booted in. [It should be INSTALL mode]

show version | begin Switch Port
Switch Ports Model SW Version SW Image Mode
------ ----- ----- ---------- ---------- ----
* 1 32 WS-C3850-24T 16.3.5b CAT3K_CAA-UNIVERSALK9 INSTALL
Configuration register is 0x102

We can use local USB as well to copy the firmware but since I already have TFTP for centralized backup for all Cisco switches therefore I am using TFTP method in this post.

Having TFTP server will give more leverage of doing various luxuries. copy the latest firmware to TFTP and then from switch console download the switch upgraded ISO and upload it to TFTP root folder. At the time of writing latest IOS XE version for 385024-T-S is cat3k_caa-universalk9.SPA.03.06.08.E.152-2.E8.bin

Connect to switch by ssh/telnet or by console and issue following command

copy tftp: flash:
Address or name of remote host []? 192.168.0.1
Source file name []? cat3k_caa-universalk9.SPA.03.06.08.E.152-2.E8.bin
Destination file name []? cat3k_caa-universalk9.SPA.03.06.08.E.152-2.E8.bin

After some minutes the new IOS will be downloaded to flash directory. in my case it took around 90 seconds to copy 291 MB IOS EX file.

# Switch to enable mode
en
#Issue command to upgrade to new firmware we just downloaded in above steps
request platform software package install switch all file flash:cat3k_caa-universalk9.SPA.03.06.08.E.152-2.E8.bin

Switch will now start the upgrade processing …

--- Starting install local lock acquisition on switch 1 ---
Finished install local lock acquisition on switch 1
Expanding image file: flash:cat3k_caa-universalk9.SPA.03.06.08.E.152-2.E8.bin
[1]: Expanding file
[1]: Finished expanding all-in-one software package in switch 1
SUCCESS: Finished expanding all-in-one software package.
[1]: Performing install
 SUCCESS: install Finished
[1]: install package(s) on switch 1
--- Starting list of software package changes ---
Old files list:
 Removed cat3k_caa-guestshell.16.03.05b.SPA.pkg
 Removed cat3k_caa-rpbase.16.03.05b.SPA.pkg
 Removed cat3k_caa-rpcore.16.03.05b.SPA.pkg
 Removed cat3k_caa-srdriver.16.03.05b.SPA.pkg
 Removed cat3k_caa-wcm.16.03.05b.SPA.pkg
 Removed cat3k_caa-webui.16.03.05b.SPA.pkg
New files list:
 Added cat3k_caa-base.SPA.03.06.08E.pkg
 Added cat3k_caa-drivers.SPA.03.06.08E.pkg
 Added cat3k_caa-infra.SPA.03.06.08E.pkg
 Added cat3k_caa-iosd-universalk9.SPA.152-2.E8.pkg
 Added cat3k_caa-platform.SPA.03.06.08E.pkg
 Added cat3k_caa-wcm.SPA.10.2.180.0.pkg
Finished list of software package changes
SUCCESS: Software provisioned. New software will load on reboot.
[1]: Finished install successful on switch 1
Checking status of install on [1]
[1]: Finished install in switch 1
SUCCESS: Finished install: Success on [1]

Now issue reload command to restart/reload the new config.

reload

Continue to reboot.

After the upgrade We will see new version in action !

show version | b SW
Switch Ports Model SW Version SW Image Mode
------ ----- ----- ---------- ---------- ----
* 1 32 WS-C3850-24T 03.06.08E cat3k_caa-universalk9 INSTALLConfiguration
register is 0x102


2# Short Notes on STACK Configuration!

cisco 3850 stack cable.jpg

Stacking is simple ! Example we want to connect 2 switches in stack mode.

1.  Power up the switch master only, let it boot completely,

2.   Attach the stacking cable from 1st switch to second one,

3.  Power up the second switch.

By default there will be no extra config required. and if both switches matches they will be added in STACK automatically.

JUST MAKE SURE THAT …

1.  All switches are running the same IOS version, same Feature Set (example IP Base);

Setting Switch Priority for MASTER

We can set switch priority to decide which switch should be MASTER. To do this, Power ON the Master switch only and issue following command

sh switch

Switch/Stack Mac Address : 009a.d29c.daXX - Local Mac Address
Mac persistency wait time: Indefinite
H/W Current
Switch# Role Mac Address Priority Version State
------------------------------------------------------------
*1 Active 009a.d29c.daXX 15 V07 Ready

Note down your switch number.

# switch to ENABLE mode
en
# Set Switch Priority
switch 1 priority 15
# WRITE CONFIG
wr
# RELOAD the configuration / reboot
reload

now boot second switch.

Once all Done. Issue following command to confirm the STACKING status.

Switch#sh switch
Switch/Stack Mac Address : 009a.d29c.da00 - Local Mac Address
Mac persistency wait time: Indefinite
H/W Current
Switch# Role Mac Address Priority Version State
------------------------------------------------------------
*1 Active 009a.d29c.da00 15 V07 Ready
2 Standby 682c.7b3c.4180 1 V07 Ready

Check Stack Ports status

Switch#show switch stack-ports
Switch# Port1 Port2
----------------------------
1 OK DOWN
2 OK DOWN

3# Some Useful STACK commands

show license right-to-use
switch stack-bandwidth
show switch detail

Following is one good Link for 3750 stack configuration …

https://www.petenetlive.com/KB/Article/0001205


4# Connecting Cisco 3850 Switch via USB console cable !

Following cable was used in this scenario

Console Cable 6 ft with USB Type A and mini-B

Console Cable 6 ft with USB Type A and mini-B

To connect with switch console using USB cable, first download & install the Cisco  USB Driver from my google drive

https://drive.google.com/drive/u/0/folders/0B8B_P2ljEc2xQlpvRUQ2QWVfR0E

Now plugin the USB cable into your desktop/laptp, Open Putty and connect to switch with settings mentioned in the image, make sure to change port as per your local system setting

3850 putty setting


Regard’s
Syed Jahanzaib ~

November 27, 2017

Automating Centralized backup for Cisco Switches

Filed under: Cisco Related — Tags: , , , — Syed Jahanzaib / Pinochio~:) @ 12:16 PM

cisco_backup.JPG

Another day to day troubleshooting short notes:

Disclaimer: There are many other proper techniques to achieve the centralized backup task, like Linux base scripting or FTP base route, But dueto my laziness I made this method according to the already available resources with minimum work required . 


Scenario:

Let’s assume:

Operator have dozen’s of manageable Cisco switches installed at various indoor/outdoor locations. Switches configuration are dynamic & the OP make changes on almost daily basis. For backup of switches configs, OP uses TFTP server on local windows server /& perform backup commands on all switches manually once a month. We want to automate this by having centralized backup server & all switches should run schedule backup task which should upload backup to the TFTP server automatically on daily or weekly basis.


Solution: [for personnel referenec]

1- Install TFTP Server in Windows to receive backup files from devices

Download & install Solarwind free TFTP Server application. Its quite and simple application which can receive backups from your switches/routers/devices and store them in c:\tftp-root folder (default location, you can change it)

tftp.JPG

At Cisco switch issue following command to test if TFTP is working fine. Your switch must be able to ping/communicate with the tftp server. Login tot switch via terminal or ssh and issue this command to test the TFTP connectivity from switch to tftp server …

en
show running-config | redirect tftp://10.0.0.1/cisco_sw/sw_10.0.0.20.txt

Note: I create new folder name cisco_sw so that all switches configurations should store in a separate folder for easy identification.

received.JPG


2 – Add Backup Schedule Job / Task on Cisco Switches

Network Details:

  1. TFTP SERVER IN WINDOWS IP : 10.0.0.1
  2. SWITCH IP : 10.0.0.20

Use following commands to add schedule task to run backup daily in midnight

en
conf t
kron policy-list daily-backup
cli show startup-config | redirect tftp://10.0.0.10/cisco_sw/sw_10.0.0.20.txt
exit
kron occurrence daily-backup at 00:00 recurring
policy-list daily-backup
exit
wr

 

  • Verify the kron configuration by using the show command.
show kron schedule
  • Result:
Kron Occurrence Schedule
daily-backup inactive, will run again in 0 days 12:58:04 at 0 :00 on

End Result:

files


Tips:

(for specific day and time, use following:

kron occurrence daily-backup at 23:00 Sun recurring)

To run task every 2 minute

kron occurrence daily-backup in 2 recurring
policy-list daily-backup

Copy to TFTP manually / Short Version:

copy running-config tftp

FTP Base backup

At one network, we configured FILEZILLA FTP Server, to make switch upload to FTP, we used following


#JZ # Make sure to change "MYSWITCHNAME_OR_IP.txt" & path to match your switch ip or name / ftp folder

en
conf term
ip ftp username cisco
ip ftp password View*pak
end

en
conf t
kron policy-list daily-backup
cli show startup-config | redirect ftp://192.168.0.1/cisco/MYSWITCHNAME_OR_IP.txt
exit
kron occurrence daily-backup at 00:00 recurring
policy-list daily-backup
exit
do wr


Regard’s
~Syed Jahanzaib

October 19, 2017

Prevent Mikrotik from Chocking with Cisco Inter-Vlan Routing


overload

 

intervlan_routing_diag_JZ


Disclaimer! This is important!

My humble request is that kindly donot consider me as an expert on this stuff, I am NOT certified in anything Mikrotik/Cisco/Linux or Windows. However I have worked with some core networks and I read , research & try stuff all of the time. When you are enslaved by private job & working as one man army, you have to perform many task in which you are not formally trained for. So I am not speaking/posting about stuff I am formerly trained in, I pretty much go with experience and what I have learned on my own. And , If I don’t know something then I read & learn all about it.

So , please don’t hold me/my-postings to be always 100 percent correct. I make mistakes just like everybody else. However – I do my best, learn from my mistakes and try to help others


For adding classless routes under Mikrotik DHCP , Please read below

https://aacable.wordpress.com/2019/12/05/intervlan-routing-with-mikrotik-dhcp-option-121-249/


Scenario: [Example]

OP have mini ISP setup. Different areas are connected with Cisco 3750 switch where Vlan(s) for each port is configured. Trunk port is connected with Mikrotik Routerboard where vlan interfaces are configured accordingly. DHCP for each VLAN is configured on the Mikrotik RB which provides different subnet to each vlan with default gateway pointing to each VLAN IP.

PPPoE Server is configured on the RB to facilitate ppp dialing for each vlan. As per policy, user must dial pppoe dialer to connect with the mikrotik PPP server in order to access internet.


Problem:

OP have few media sharing server located on Vlan No 3. When user starts downloading heavy media files from the Vlan No 3, all of his traffic routes via Mikrotik Router which creates load on router.


Solution # 1: [that worked partially]

After some R&D, I implemented following

  • Moved DHCP role to Cisco
  • Setup intervlan routing. enabled ip routing
  • Added default gateway in DHCP options pointing to Cisco local vlan ip respectively

This partially solves the problem. When user join the LAN, he gets IP address from the Cisco dhcp with default gateway to its respective vlan IP. all goes well , communication was happening fine with in vlan without touching the Mikrotik. But as soon as users dial the PPPOE dialer, his traffic starts routing via Mikrotik . after some troubleshooting it appears that when user dials pppoe dialer, his routes changes and ppp gets preference over other routes which force all traffic to go via RB.

As showed in the image below …

Load on Trunk Port when ppp user download from vlan no 3

 

routes and ipconfig of client before dhcp option


Solution # 2: [worked 100% as required]

In Cisco Switch DHCP settings for each vlan, Remove Default Gateway,  and add static routes for the sharing media servers subnet via using DHCP classless static routes option

Sounds fair enough :~)


Working Example Config for Cisco Switch 3750

# Cisco Switch Part

[Model: ws-c3750e-24pd / Version 15.0(2)SE10a ]


!
system mtu routing 1500
ip routing
!
ip dhcp pool vlan2
network 192.168.2.0 255.255.255.0
dns-server 101.11.11.36
option 121 ip 24.192.168.3 192.168.2.1 ## This option provides route information , /24.x is the subnet info and other is gw
!
ip dhcp pool vlan3
network 192.168.3.0 255.255.255.0 ## This is media server vlan, we have added manual ip & gateway pointing to vlan ip 192.168.3.0
! to add multiple routes use below
! option 121 ip 24.192.168.3 192.168.2.1 24.192.168.100 192.168.2.1
!
ip dhcp pool vlan4
network 192.168.4.0 255.255.255.0
option 121 ip 24.192.168.3 192.168.4.1 ## This option provides route information , /24.x is the subnet info and other is gw
!

! This port is connected with the Mikrotik RB
interface GigabitEthernet1/0/1
switchport trunk encapsulation dot1q
switchport mode trunk

! This port is connected with user area 2
interface GigabitEthernet1/0/2
switchport access vlan 2
switchport mode access

! This port is connected with local FTP/Media sharing server's
interface GigabitEthernet1/0/3
switchport access vlan 3
switchport mode access

!This port is connected with user area 4
interface GigabitEthernet1/0/4
switchport access vlan 4
switchport mode access
!
interface Vlan1
ip address 192.168.254.1 255.255.255.0
!
interface Vlan2
ip address 192.168.2.1 255.255.255.0
!
interface Vlan3
ip address 192.168.3.1 255.255.255.0
!
interface Vlan4
ip address 192.168.4.1 255.255.255.0
! Following route is pointing to Mikrotik RB
ip route 0.0.0.0 0.0.0.0 192.168.254.2
!

# Mikrotik Routerboard Part


/interface ethernet

set [ find default-name=ether1 ] name=LAN-TRUNK

/interface vlan
add interface=LAN-TRUNK name=vlan2 vlan-id=2
add interface=LAN-TRUNK name=vlan3 vlan-id=3
add interface=LAN-TRUNK name=vlan4 vlan-id=4

# It is recommended to use small subnet, like /29 for below (zaib)
/ip address
add address=192.168.254.2/24 interface=LAN-TRUNK network=192.168.254.0

/interface pppoe-server server
add default-profile=pppoe-profile disabled=no interface=vlan2 max-mru=1480 max-mtu=1480 mrru=1600 one-session-per-host=yes service-name=service2
add default-profile=pppoe-profile disabled=no interface=vlan3 max-mru=1480 max-mtu=1480 mrru=1600 one-session-per-host=yes service-name=service3
add default-profile=pppoe-profile disabled=no interface=vlan4 max-mru=1480 max-mtu=1480 mrru=1600 one-session-per-host=yes service-name=service4

# FTP / Media Sharing Server Part

at your FTP server, which is under vlan no 3, define static ip like 192.168.3.2 and point its gateway to 192.168.3.1, That’s It 🙂

Results are showed as below …

 

client ROUTEs and ipconfig AFTER DHCP OPTIOIN

 

download gpoign via vlan only after addding dhcp option

 

no load on mikrotik router and local vlan download going via local vlan

 


 

Note:

I have posted minimalist configuration to reduce any complication. Most of parts are quite self explanatory. This exercise was done successfully in LAB & required results were achieved. However you must consult with some Cisco expert & conduct your own testing  before implementing it on production.

Also you may want to use ACL in order to restrict access to shared resources, YKWIM


Regard’s
Syed Jahanzaib

 

April 27, 2017

iBBi Switcher – Cisco Management Tool

Filed under: Cisco Related — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 4:29 PM


iBBi Switcher – Cisco Monitoring Tool

This is another application I made in C# using Visual Studio 2012. I generally use Cisco Configuration Assistant tool to Manage/Monitor our Cisco switches. Its great , works flawlessly, but still sometimes I need some thing quick to just monitor port status without  using full sized apps , above all the biggest advantage for our local environment is that I can give this app to local support staff and technician easily without giving them any further access to any panel.

Development is Powerful & Fun as well ~

Functions:

This app uses SNMPSHARPNET  library to query remove device by SNMP. It performs following actions …

  • Once Start button is pressed, It will first check if remote device or its SNMP is responding, if not give error (without freezing User Interface), If Response is OK, then continue further
  • Query all 24 ports with there description dynamically, Update the labels and Up/Down image according to the status.
  • Update Timer Label to see when last update on ports were made
  • Strip Menu for info/Exit Function.
  • Exit button on top right corner to exit the app immediately
  • Display progress bar to indicate process is active
  • Display CPU progress bar with temperature as well
  • Once START button is pushed, disable it to prevent duplication, added error as well.
  • STOP button to stop monitoring and timer and revert labels/images to default.
  • In Status Box window, display any ports UP / DOWN Status As showed in the image below

port down


the Code:

First download SNMPSHARPNET library and import it.

// C# / VS2012
// This is another application I made in C# using Visual Studio 2012.
// I generally use Cisco Configuration Assistant tool to Manage/Monitor our Cisco switches.
// Its great , works flawlessly, but still sometimes I need some thing quick to just monitor port status without using full sized apps
// above all the biggest advantage for our local environment is that I can give this app to local support staff and technician easily
// without giving them any further access to any panel.
// Make sure to download the SNMPSHARPNET library before using this code.
// Syed Jahanzaib
// aacable at hotmail dot com
// http:// aacable dot wordpress dot com
// 27-April-2017
using System;
using System.Net;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
using SnmpSharpNet;
using System.Threading.Tasks;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public class Globals
{
public static string P1 = "";
public static string P2 = "";
public static string P3 = "";
public static string P4 = "";
public static string P5 = "";
public static string P6 = "";
public static string P7 = "";
public static string P8 = "";
public static string P9 = "";
public static string P10 = "";
public static string P11 = "";
public static string P12 = "";
public static string P13 = "";
public static string P14 = "";
public static string P15 = "";
public static string P16 = "";
public static string P17 = "";
public static string P18 = "";
public static string P19 = "";
public static string P20 = "";
public static string P21 = "";
public static string P22 = "";
public static string P23 = "";
public static string P24 = "";
public static string PL1 = "";
public static string PL2 = "";
public static string PL3 = "";
public static string PL4 = "";
public static string PL5 = "";
public static string PL6 = "";
public static string PL7 = "";
public static string PL8 = "";
public static string PL9 = "";
public static string PL10 = "";
public static string PL11 = "";
public static string PL12 = "";
public static string PL13 = "";
public static string PL14 = "";
public static string PL15 = "";
public static string PL16 = "";
public static string PL17 = "";
public static string PL18 = "";
public static string PL19 = "";
public static string PL20 = "";
public static string PL21 = "";
public static string PL22 = "";
public static string PL23 = "";
public static string PL24 = "";
public static string CPU = "";
public static string TEMPER = "";

}
public Form1()
{
InitializeComponent();
timer1.Stop();
timer1.Enabled = false;
}
private void Form1_Load(object sender, EventArgs e)
{
portReset();
datelabel.Text = DateTime.Now.ToLongDateString();
timelabel.Text = DateTime.Now.ToLongTimeString();
}
private void portReset()
{
port1.Image = Properties.Resources.port_nostatus;
port2.Image = Properties.Resources.port_nostatus;
port3.Image = Properties.Resources.port_nostatus;
port4.Image = Properties.Resources.port_nostatus;
port5.Image = Properties.Resources.port_nostatus;
port6.Image = Properties.Resources.port_nostatus;
port7.Image = Properties.Resources.port_nostatus;
port8.Image = Properties.Resources.port_nostatus;
port9.Image = Properties.Resources.port_nostatus;
port10.Image = Properties.Resources.port_nostatus;
port11.Image = Properties.Resources.port_nostatus;
port12.Image = Properties.Resources.port_nostatus;
port13.Image = Properties.Resources.port_nostatus;
port14.Image = Properties.Resources.port_nostatus;
port15.Image = Properties.Resources.port_nostatus;
port16.Image = Properties.Resources.port_nostatus;
port17.Image = Properties.Resources.port_nostatus;
port18.Image = Properties.Resources.port_nostatus;
port19.Image = Properties.Resources.port_nostatus;
port20.Image = Properties.Resources.port_nostatus;
port21.Image = Properties.Resources.port_nostatus;
port22.Image = Properties.Resources.port_nostatus;
port23.Image = Properties.Resources.port_nostatus;
port24.Image = Properties.Resources.port_nostatus;
p1textBox1.Text = null;
p2textBox1.Text = null;
p3textBox1.Text = null;
p4textBox1.Text = null;
p5textBox1.Text = null;
p6textBox1.Text = null;
p7textBox1.Text = null;
p8textBox1.Text = null;
p9textBox1.Text = null;
p10textBox1.Text = null;
p11textBox1.Text = null;
p12textBox1.Text = null;
p13textBox1.Text = null;
p14textBox1.Text = null;
p15textBox1.Text = null;
p16textBox1.Text = null;
p17textBox1.Text = null;
p18textBox1.Text = null;
p19textBox1.Text = null;
p20textBox1.Text = null;
p21textBox1.Text = null;
p22textBox1.Text = null;
p23textBox1.Text = null;
p24textBox1.Text = null;
plabel1.Text = null;
plabel2.Text = null;
plabel3.Text = null;
plabel4.Text = null;
plabel5.Text = null;
plabel6.Text = null;
plabel7.Text = null;
plabel8.Text = null;
plabel9.Text = null;
plabel10.Text = null;
plabel11.Text = null;
plabel12.Text = null;
plabel13.Text = null;
plabel14.Text = null;
plabel15.Text = null;
plabel16.Text = null;
plabel17.Text = null;
plabel18.Text = null;
plabel19.Text = null;
plabel20.Text = null;
plabel21.Text = null;
plabel22.Text = null;
plabel23.Text = null;
plabel24.Text = null;
cpulabel.Text = null;

StatusTextBox1.Text = String.Empty;
this.statusLoadinBar.Image = null;
}
private async void snmpGetFunc()
{
timer1.Enabled = true;
this.Invoke((MethodInvoker)delegate
{
lastUpdateLabel.Text = "Last Updated @" + DateTime.Now.ToLongDateString() + DateTime.Now.ToLongTimeString();
});
OctetString community = new OctetString("PUBLIC");
AgentParameters param = new AgentParameters(community);
param.Version = SnmpVersion.Ver2;
IpAddress agent = new IpAddress("10.0.0.1");
UdpTarget target = new UdpTarget((IPAddress)agent, 161, 1000, 1);
Pdu pdu = new Pdu(PduType.Get);
// Make SNMP request to test if device is responding or not
try
{
//Query Switch name, just for testing if SNMP/Device is reponding or NOT : ~ D / zaib
//pdu.VbList.Add(".1.3.6.1.2.1.1.5.0");
SnmpV2Packet result = (SnmpV2Packet)target.Request(pdu, param);
}
catch (SnmpException ex)
{
this.Invoke((MethodInvoker)delegate
{
this.StatusTextBox1.AppendText("\r\n" + ex.Message + "Either Device or SNMP not responding. Retrying again ...");
});
target.Dispose();
return;
}
if (timer1.Enabled == true)
{
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10101");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10102");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10103");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10104");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10105");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10106");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10107");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10108");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10109");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10110");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10111");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10112");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10113");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10114");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10115");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10116");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10117");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10118");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10119");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10120");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10121");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10122");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10123");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10605");
// Ports End
// Now quering switch port names related data
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10101");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10102");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10103");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10104");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10105");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10106");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10107");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10108");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10109");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10110");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10111");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10112");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10113");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10114");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10115");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10116");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10117");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10118");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10119");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10120");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10121");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10122");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10123");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10605");
// CPU Usage
pdu.VbList.Add("1.3.6.1.4.1.9.2.1.56.0");
// Temprature
pdu.VbList.Add("1.3.6.1.4.1.9.9.13.1.3.1.3.1006");
// Get all data by SNMP query
SnmpV2Packet result = (SnmpV2Packet)target.Request(pdu, param);
// End
// Update Global Variables that will be used for few other functions
Globals.P1 = result.Pdu.VbList[0].Value.ToString();
Globals.P2 = result.Pdu.VbList[1].Value.ToString();
Globals.P3 = result.Pdu.VbList[2].Value.ToString();
Globals.P4 = result.Pdu.VbList[3].Value.ToString();
Globals.P5 = result.Pdu.VbList[4].Value.ToString();
Globals.P6 = result.Pdu.VbList[5].Value.ToString();
Globals.P7 = result.Pdu.VbList[6].Value.ToString();
Globals.P8 = result.Pdu.VbList[7].Value.ToString();
Globals.P9 = result.Pdu.VbList[8].Value.ToString();
Globals.P10 = result.Pdu.VbList[9].Value.ToString();
Globals.P11 = result.Pdu.VbList[10].Value.ToString();
Globals.P12 = result.Pdu.VbList[11].Value.ToString();
Globals.P13 = result.Pdu.VbList[12].Value.ToString();
Globals.P14 = result.Pdu.VbList[13].Value.ToString();
Globals.P15 = result.Pdu.VbList[14].Value.ToString();
Globals.P16 = result.Pdu.VbList[15].Value.ToString();
Globals.P17 = result.Pdu.VbList[16].Value.ToString();
Globals.P18 = result.Pdu.VbList[17].Value.ToString();
Globals.P19 = result.Pdu.VbList[18].Value.ToString();
Globals.P20 = result.Pdu.VbList[19].Value.ToString();
Globals.P21 = result.Pdu.VbList[20].Value.ToString();
Globals.P22 = result.Pdu.VbList[21].Value.ToString();
Globals.P23 = result.Pdu.VbList[22].Value.ToString();
Globals.P24 = result.Pdu.VbList[23].Value.ToString();
Globals.PL1 = result.Pdu.VbList[24].Value.ToString();
Globals.PL2 = result.Pdu.VbList[25].Value.ToString();
Globals.PL3 = result.Pdu.VbList[26].Value.ToString();
Globals.PL4 = result.Pdu.VbList[27].Value.ToString();
Globals.PL5 = result.Pdu.VbList[28].Value.ToString();
Globals.PL6 = result.Pdu.VbList[29].Value.ToString();
Globals.PL7 = result.Pdu.VbList[30].Value.ToString();
Globals.PL8 = result.Pdu.VbList[31].Value.ToString();
Globals.PL9 = result.Pdu.VbList[32].Value.ToString();
Globals.PL10 = result.Pdu.VbList[33].Value.ToString();
Globals.PL11 = result.Pdu.VbList[34].Value.ToString();
Globals.PL12 = result.Pdu.VbList[35].Value.ToString();
Globals.PL13 = result.Pdu.VbList[36].Value.ToString();
Globals.PL14 = result.Pdu.VbList[37].Value.ToString();
Globals.PL15 = result.Pdu.VbList[38].Value.ToString();
Globals.PL16 = result.Pdu.VbList[39].Value.ToString();
Globals.PL17 = result.Pdu.VbList[40].Value.ToString();
Globals.PL18 = result.Pdu.VbList[41].Value.ToString();
Globals.PL19 = result.Pdu.VbList[42].Value.ToString();
Globals.PL20 = result.Pdu.VbList[43].Value.ToString();
Globals.PL21 = result.Pdu.VbList[44].Value.ToString();
Globals.PL22 = result.Pdu.VbList[45].Value.ToString();
Globals.PL23 = result.Pdu.VbList[46].Value.ToString();
Globals.PL24 = result.Pdu.VbList[47].Value.ToString();
Globals.CPU = result.Pdu.VbList[48].Value.ToString();
Globals.TEMPER = result.Pdu.VbList[49].Value.ToString();
this.Invoke((MethodInvoker)delegate
{
//Update Port Description / Names Text Labels
plabel1.Text = Globals.PL1;
plabel2.Text = Globals.PL2;
plabel3.Text = Globals.PL3;
plabel4.Text = Globals.PL4;
plabel5.Text = Globals.PL5;
plabel6.Text = Globals.PL6;
plabel7.Text = Globals.PL7;
plabel8.Text = Globals.PL8;
plabel9.Text = Globals.PL9;
plabel10.Text = Globals.PL10;
plabel11.Text = Globals.PL11;
plabel12.Text = Globals.PL12;
plabel13.Text = Globals.PL13;
plabel14.Text = Globals.PL14;
plabel15.Text = Globals.PL15;
plabel16.Text = Globals.PL16;
plabel17.Text = Globals.PL17;
plabel18.Text = Globals.PL18;
plabel19.Text = Globals.PL19;
plabel20.Text = Globals.PL20;
plabel21.Text = Globals.PL21;
plabel22.Text = Globals.PL22;
plabel23.Text = Globals.PL23;
plabel24.Text = Globals.PL24;
cpulabel.Text = Globals.CPU + " %";
temper_label.Text = Globals.TEMPER + "c";

int cpuint = Int32.Parse(Globals.CPU);
progressBar1.Value = cpuint;

//});
if (Globals.P1 == "1")
{
port1.Image = Properties.Resources.port_up;
p1textBox1.Text = Globals.P1;
}
else
{
port1.Image = Properties.Resources.port_down;
}
if (Globals.P2 == "1")
{
port2.Image = Properties.Resources.port_up;
p2textBox1.Text = Globals.P2;
}
else
{
port2.Image = Properties.Resources.port_down;
}
if (Globals.P3 == "1")
{
port3.Image = Properties.Resources.port_up;
p3textBox1.Text = Globals.P3;
}
else
{
port3.Image = Properties.Resources.port_down;
}
if (Globals.P4 == "1")
{
port4.Image = Properties.Resources.port_up;
p4textBox1.Text = Globals.P4;
}
else
{
port4.Image = Properties.Resources.port_down;
}
if (Globals.P5 == "1")
{
port5.Image = Properties.Resources.port_up;
p5textBox1.Text = Globals.P5;
}
else
{
port5.Image = Properties.Resources.port_down;
}
if (Globals.P6 == "1")
{
port6.Image = Properties.Resources.port_up;
p6textBox1.Text = Globals.P6;
}
else
{
port6.Image = Properties.Resources.port_down;
}
if (Globals.P7 == "1")
{
port7.Image = Properties.Resources.port_up;
}
else
{
port7.Image = Properties.Resources.port_down;
}
if (Globals.P8 == "1")
{
port8.Image = Properties.Resources.port_up;
}
else
{
port8.Image = Properties.Resources.port_down;
}
if (Globals.P9 == "1")
{
port9.Image = Properties.Resources.port_up;
}
else
{
port9.Image = Properties.Resources.port_down;
}
if (Globals.P10 == "1")
{
port10.Image = Properties.Resources.port_up;
}
else
{
port10.Image = Properties.Resources.port_down;
}
if (Globals.P11 == "1")
{
port11.Image = Properties.Resources.port_up;
}
else
{
port11.Image = Properties.Resources.port_down;
}
if (Globals.P12 == "1")
{
port12.Image = Properties.Resources.port_up;
}
else
{
port12.Image = Properties.Resources.port_down;
}
if (Globals.P13 == "1")
{
port13.Image = Properties.Resources.port_up;
}
else
{
port13.Image = Properties.Resources.port_down;
}
if (Globals.P14 == "1")
{
port14.Image = Properties.Resources.port_up;
}
else
{
port14.Image = Properties.Resources.port_down;
}
if (Globals.P15 == "1")
{
port15.Image = Properties.Resources.port_up;
}
else
{
port15.Image = Properties.Resources.port_down;
}
if (Globals.P16 == "1")
{
port16.Image = Properties.Resources.port_up;
}
else
{
port16.Image = Properties.Resources.port_down;
}
if (Globals.P17 == "1")
{
port17.Image = Properties.Resources.port_up;
}
else
{
port17.Image = Properties.Resources.port_down;
}
if (Globals.P18 == "1")
{
port18.Image = Properties.Resources.port_up;
}
else
{
port18.Image = Properties.Resources.port_down;
}
if (Globals.P19 == "1")
{
port19.Image = Properties.Resources.port_up;
}
else
{
port19.Image = Properties.Resources.port_down;
}
if (Globals.P20 == "1")
{
port20.Image = Properties.Resources.port_up;
}
else
{
port20.Image = Properties.Resources.port_down;
}
if (Globals.P21 == "1")
{
port21.Image = Properties.Resources.port_up;
}
else
{
port21.Image = Properties.Resources.port_down;
}
if (Globals.P22 == "1")
{
port22.Image = Properties.Resources.port_up;
}
else
{
port22.Image = Properties.Resources.port_down;
}
if (Globals.P23 == "1")
{
port23.Image = Properties.Resources.port_up;
}
else
{
port23.Image = Properties.Resources.port_down;
}
if (Globals.P24 == "1")
{
port24.Image = Properties.Resources.port_up;
p24textBox1.Text = Globals.P24;
}
else
{
port24.Image = Properties.Resources.port_down;
p24textBox1.Text = Globals.P24;
}
});
ClearTextBox1TimeOnly();
}
}
private static bool isRun = false;
private static readonly object syncLock = new object();
public void ClearTextBox1TimeOnly()
{
lock (syncLock)
{
if (!isRun)
{
this.Invoke((MethodInvoker)delegate
{
StatusTextBox1.Text = String.Empty;
this.StatusTextBox1.Text += string.Format("Starting monitoring of Cisco Switch Ports. Activated [5 sec delay] ... \r\n");
});
isRun = true;
}
}
}
// Start the app. start button
private async void button1_Click(object sender, EventArgs e)
{
if (timer1.Enabled == true)
{
this.StatusTextBox1.Text += string.Format("Monitoring already started. Stop it to first to start new instance !\r\n");
}
else
{
startButton.Enabled = false;
isRun = false;
timer1.Enabled = true;
timer1.Start();
this.statusLoadinBar.Image = Properties.Resources.loading_gif;
//await Task.Run(() =>
//{
//await Task.Run(() => snmpGetFunc();
//});
Task.Factory.StartNew(() => snmpGetFunc());
this.StatusTextBox1.Text += string.Format("Starting monitoring of Cisco Switch Ports. \r\n");
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void exitToolStripMenuItem1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void timer4dt_Tick(object sender, EventArgs e)
{
timelabel.Text = DateTime.Now.ToLongTimeString();
timer4dt.Start();
}
private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
}
private void stopButton_Click(object sender, EventArgs e)
{
if (timer1.Enabled == true)
{
startButton.Enabled = true;
timer1.Enabled = false;
timer1.Stop();
portReset();
this.StatusTextBox1.AppendText("\r\nMonitoring of switch have been Stopped on user request \r\n");
}
else
{
this.StatusTextBox1.AppendText("\r\nMonitoring not started yet !\r\n");
startButton.Enabled = true;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
Task.Factory.StartNew(() => snmpGetFunc());
}
private void exitButton_Click(object sender, EventArgs e)
{
this.statusLoadinBar.Image = null;
timer1.Stop();
portReset();
this.StatusTextBox1.AppendText("\r\nExiting on user request \r\n");
Application.Exit();
}
private void StatusTextBox1_TextChanged(object sender, EventArgs e)
{
StatusTextBox1.SelectionStart = StatusTextBox1.Text.Length;
StatusTextBox1.ScrollToCaret();
}
private void p1textBox1_TextChanged(object sender, EventArgs e)
{
if (Globals.P1 == "1")
this.StatusTextBox1.AppendText("\r\nPort 1 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 1 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p2textBox1_TextChanged(object sender, EventArgs e)
{
if (Globals.P2 == "1")
this.StatusTextBox1.AppendText("\r\nPort 2 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 2 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p3textBox1_TextChanged(object sender, EventArgs e)
{
if (Globals.P3 == "1")
this.StatusTextBox1.AppendText("\r\nPort 3 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 3 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p4textBox1_TextChanged(object sender, EventArgs e)
{
if (Globals.P4 == "1")
this.StatusTextBox1.AppendText("\r\nPort 4 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 4 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p5textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P5 == "1")
this.StatusTextBox1.AppendText("\r\nPort 5 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 5 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p6textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P6 == "1")
this.StatusTextBox1.AppendText("\r\nPort 6 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 6 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p7textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P7 == "1")
this.StatusTextBox1.AppendText("\r\nPort 7 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 7 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p8textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P8 == "1")
this.StatusTextBox1.AppendText("\r\nPort 8 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 8 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p9textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P9 == "1")
this.StatusTextBox1.AppendText("\r\nPort 9 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 9 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p10textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P10 == "1")
this.StatusTextBox1.AppendText("\r\nPort 10 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 10 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p11textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P11 == "1")
this.StatusTextBox1.AppendText("\r\nPort 11is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 11is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p12TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P12 == "1")
this.StatusTextBox1.AppendText("\r\nPort 12 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 12 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p13TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P13 == "1")
this.StatusTextBox1.AppendText("\r\nPort 13 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 13 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p14TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P14 == "1")
this.StatusTextBox1.AppendText("\r\nPort 14 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 14 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p15TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P15 == "1")
this.StatusTextBox1.AppendText("\r\nPort 15 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 15 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p17TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P17 == "1")
this.StatusTextBox1.AppendText("\r\nPort 17 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 17 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p18TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P18 == "1")
this.StatusTextBox1.AppendText("\r\nPort 18 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 18 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p19TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P19 == "1")
this.StatusTextBox1.AppendText("\r\nPort 19 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 19 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p20TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P20 == "1")
this.StatusTextBox1.AppendText("\r\nPort 20 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 20 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p21TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P21 == "1")
this.StatusTextBox1.AppendText("\r\nPort 21 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 21 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p22TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P22 == "1")
this.StatusTextBox1.AppendText("\r\nPort 22 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 22 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p23TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P23 == "1")
this.StatusTextBox1.AppendText("\r\nPort 23 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 23 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p24textBox1_TextChanged(object sender, EventArgs e)
{
if (Globals.P24 == "1")
this.StatusTextBox1.AppendText("\r\nPort 24 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 24 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

}
}

Regard’s
Syed Jahanzaib

Older Posts »