Thứ Ba, 21 tháng 10, 2014

Two Ways of Setting Up Trunks on Juniper Switches

In a previous blog, I’ve shown you how to create VLANs on a Juniper switch, particularly running JunOS. Furthermore, I’ve shown you how to edit the vlan membership using two methods. In this blog, I will now show you the two methods for setting up a trunk.
But let’s quickly review what a trunk is, since this is actually important towards understanding the configuration logic.
Depending on how deep you want to dive into it, there is actually quite a bit of theory behind trunk links, from the switch logic itself, all the way to protocols, standard, encapsulation, etc. Though for the sole purpose of this blog, let’s just agree on the following definition:
A trunk port is  a logical link which can transport frames for more than one VLAN.
Outgoing frames going out a trunk port will be tagged with the VLAN tag, unless the frame belongs to the native-vlan. This is the default behaviour which, could be changed in configuration.
Incoming frames are inspected and the switch forwards them based on the vlan-tag found within the frame (when one exists).
How does the switch know that a frame has a tag? When a frame is received, the switch will read the Ethernet frame, particularly, the EtherType field. In regards to trunking, the following values are possible: 0×9100 – QinQ encapsulation; 0×8100 – VLAN Tagging.
Without going into more advanced scenarios, we need trunks to accommodate, primarily, two scenarios:trunks-01
  1. Router on a stick
  2. Interconnection between switches
Let’s now see how do we configure a trunk on a Juniper switch running JunOS. I will be using the following topology:
vlans-03
METHOD I
The logic here is to configure a logical interface belonging to more than one VLAN – kind of makes sense, if you understood the actual purpose of a trunk port! Next, I will configure interface/port ge-0/0/23 so that it belongs to both vlans VLAN-10 and VLAN-20 respectively…
Note: Keep in mind that I will skip over the configuration of the actual VLANs for this has already been explained here. I have also removed some lines from the output for added clarity.
{master:0}[edit]
root# show vlans
VLAN-10 {
   vlan-id 10;
   interface {
      ge-0/0/23.0;
   }
}
VLAN-20 {
   vlan-id 20;
   interface {
      ge-0/0/23.0;
   }
}
default {
vlan-id 1;
interface {
ge-0/0/23.0;
}
}

… and the set commands:
{master:0}[edit]
root# show vlans | display set
set vlans VLAN-10 interface ge-0/0/23.0
set vlans VLAN-20 interface ge-0/0/23.0
But, when I try to commit the configuration, I get an error!!!
root# commit check
error: Access interface <ge-0/0/23.0> has more than one vlan member: <VLAN-20> and <VLAN-10>
error: configuration check-out failed
The reason why we get this error is that, although we’ve configured the port for Layer2 (using the ethernet-switching property), by default, the port is an access portIn order to setup this port as a trunk port, we need to run the following set command:
{master:0}[edit]
root# set interfaces ge-0/0/23 unit 0 family ethernet-switching port-mode trunk
{master:0}[edit]
root# show interfaces ge-0/0/23
unit 0 {
   family ethernet-switching {
      port-mode trunk;
      native-vlan-id 1;
   }
}
Notice the native-vlan-id 1 command - this is telling the switch that the native-vlan on this trunk is the VLAN with the vlan-id 1.
We can now successfully commit the configuration!
{master:0}[edit]
root# commit
fpc0:
configuration check succeeds
fpc1:
commit complete
fpc0:
commit complete
METHOD II
The 2nd method goes by the same logic applied on the 2nd method of editing VLAN membership – when setting up trunks, instead of “attaching” a VLAN to an interface, we “attach” multiple VLANs to the same interface.
To demonstrate, I’ve removed the previous configuration used with METHOD I.
Here is the configuration snippet:
ge-0/0/23 {
   unit 0 {
      family ethernet-switching {
         port-mode trunk;
         vlan { 
            members [ VLAN-10 VLAN-20 ];
         }
         native-vlan-id 1;
      }
   }
}
… and the set commands:
{master:0}[edit]
root# show interfaces | display set
[...]
set interfaces ge-0/0/23 unit 0 family ethernet-switching port-mode trunk
set interfaces ge-0/0/23 unit 0 family ethernet-switching vlan members VLAN-10
set interfaces ge-0/0/23 unit 0 family ethernet-switching vlan members VLAN-20
set interfaces ge-0/0/23 unit 0 family ethernet-switching native-vlan-id 1
Let’s take a look at two show commands:
{master:0}[edit]
root# run show vlans extensive
VLAN: VLAN-10, Created at: Fri Sep 13 06:41:32 2013
802.1Q Tag: 10, Internal index: 2, Admin State: Enabled, Origin: Static
Protocol: Port Mode, Mac aging time: 300 seconds
Number of interfaces: Tagged 1 (Active = 1), Untagged 2 (Active = 0)
             ge-0/0/23.0*, tagged, trunk
             ge-0/0/10.0, untagged, access
             ge-0/0/11.0, untagged, access
VLAN: VLAN-20, Created at: Fri Sep 13 08:32:16 2013
802.1Q Tag: 20, Internal index: 5, Admin State: Enabled, Origin: Static
Protocol: Port Mode, Mac aging time: 300 seconds
Number of interfaces: Tagged 1 (Active = 1), Untagged 2 (Active = 0)
             ge-0/0/23.0*, tagged, trunk
             ge-0/0/20.0, untagged, access
             ge-0/0/21.0, untagged, access
VLAN: default, Created at: Fri Sep 13 06:41:32 2013
802.1Q Tag: 1, Internal index: 3, Admin State: Enabled, Origin: Static
Protocol: Port Mode, Mac aging time: 300 seconds
Number of interfaces: Tagged 1 (Active = 1), Untagged 1 (Active = 1)
             ge-0/0/23.0*, tagged, trunk
            ge-0/0/23.0*, untagged, trunk
__________________________________________________________
{master:0}[edit]
root# run show ethernet-switching interfaces
Interface State VLAN members Tag Tagging Blocking
bme0.32770 down mgmt untagged unblocked
ge-0/0/10.0 down VLAN-10 10 untagged blocked by STP
ge-0/0/11.0 down VLAN-10 10 untagged blocked by STP
ge-0/0/20.0 down VLAN-20 20 untagged blocked by STP
ge-0/0/21.0 down VLAN-20 20 untagged blocked by STP
ge-0/0/23.0 up default 1 untagged unblocked
                                 VLAN-10 10 tagged unblocked
                                 VLAN-20 20 tagged unblocked
                                 default 1 tagged unblocked
me0.0 down mgmt untagged unblocked

Thank you,
source : http://blogbt.net/index.php/2014/09/setting-up-trunks-juniper-switches/

Không có nhận xét nào:

Đăng nhận xét