2

My question is simple: I have a Catalyst 3560-X series switch and the below macro applied when i connect my laptop to the switch and it's working fine .

function My_laptop_func()
{
 if [[ $LINKUP == YES  ]]
  then conf t
  interface $INTERFACE
  switchport access vlan 99
  exit
  end
 fi
 if [[ $LINKUP == NO ]]
  then conf t
  interface $INTERFACE
  no switchport access vlan 99
  exit
  end
 fi
}

But the problem is that even though I activated macro auto port sticky on my interfaces, when a link-down event occurs, the if [[ $LINKUP == NO ]] part does not work .

Why doesn'it it work?

  • 1
    Please consider adding more details. "It does not work" isn't a problem description. How did you apply the macro , what logs and error messages did you get, what have you tried to fix it? Keep in mind that a switch port in access mode needs to be assigned to a vlan, so you will have to move the port to another vlan instead of using 'no switchport access vlan 99' – Teun Vink Aug 30 '17 at 8:44
  • Ty for answering me ! The probleme is , for example i connect my laptotp to the switch port gi0/1 it goes to vlan 99 , so far so good , but when i take off the rg45 from gi0/1 then i have a linkdown .Unfortunatly when i cheek for sh vlan i still find int gi0/1 in vlan 99 – Walid Slaaouiter Aug 30 '17 at 10:59
  • Does it actually matter? If the link is down, then no traffic can be on the link, so the concept of VLAN is moot. A VLAN, simply determines which traffic will use the interface, but no traffic will use an interface that is down. – Ron Maupin Aug 30 '17 at 11:34
  • maybe it does not matter . but what if it is a configuration that need to be disabled when the link is down .i hope u understand me , this is just the begging of what i ought to do .Ty for ur answers i really appreciate – Walid Slaaouiter Aug 30 '17 at 11:37
  • Any bright ideas guys ? pliiz – Walid Slaaouiter Aug 30 '17 at 15:32
-1

Well, 'no shut' will bring the link up, so I don't see a way to avoid the loop there. Can you trigger the macro on some other event, instead of linkup?

What would be the operational goal of the macro? Just to see if there's an alternate way to achieve that. Do you really need the shut - no shut sequence? You could just change the vlan, the first DHCP packet might be lost, by the time the client retries, he's in the new vlan.

Plan B: MAC authentication bypass (MAB). It was basically built for this, it's just interesting to configure... :)

  • it's a mac authentification the macro only works when my laptop is connected :/ . i only want when i have a linkdown event the interface changes it vlan to the original – Walid Slaaouiter Aug 30 '17 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.