Cisco 3k NX-OS config

Roelf Zomerman

Active Member
Jan 10, 2019
129
25
28
blog.azureinfra.com
Hi everyone,

I'm trying to configure my Cisco switch with the following, and was hoping someone has some tips for me (else I have to go through all the docs)..

Code:
vlan 1 - ip 172.16.5.250/24

ports 17-32 - native vlan 1 - allowed VLANS 1-200


vlan 100 - ip 172.16.100.1/24

ports 1-16 - native VLAN 100 - allowed VLANS 1-10 + 100


vlan 200 - ip 172.16.200.1/24

ports 33-48 - native VLAN 200 - allowed VLANS 1-10 + 200
and then able to route traffic between all interfaces

I managed to set the IP's but not yet attached to the ports - and no routing yet.
 

maze

Active Member
Apr 27, 2013
573
94
28
So you’ll want to just add the vlans to the ports by doing:

conf t
int gix/x
switchport mode trunk
Switchport trunk allowed vlan add 1,200
Switchport trunk native vlan 1
- that last one im a bit in doubt about, long time since i’v done a trunk port with native vlan on a Cisco box

and Then for the router part try this - bit unsure just going on my phone

ip routing
Ip default gateway 1.2.3.4
 

sleeper404

New Member
Jan 10, 2021
19
5
3
There's a bit of setup here in stages.

1. Turn on features - NX-OS needs features enabled prior to allowing any config!
2. Define VLANs - Nothing will forward at layer 2 or 3 on IOS/NX-OS switches without defining the VLANS (names optional) in global config
3. Enabled IP Routing (menitoned in the last post) needed to even allow the switch to do layer 3 switching
4. Configure VLAN interfaces (SVI-Switch Virtual Interface) These are the logical interfaces that represent the router on a stick inside the switch config (your subnet gateway interface/mask goes here, turn them on afterwards
5. put a static route somewhere, or configure dynamic routing (if you enabled the feature set for the protocol)
6. Configure your interfaces



Code:
Step 1: (in global config)
feature interface-vlan (needed to enable l3 switching)
feature osp (if you intend to run OSPF as a routing protocol, substitute EIGRP/BGP/etc)
feature dhcp (if you intend to forward DHCP to a central server)

Step 2: (in global config)
vlan 1
  name Default-vlan
vlan 100
  name SomeNameForVL100
vlan 200
  name AnotherVLANforSomething

Step 3: (in global config)
ip routing (this is usually already done when the interface vlan feature is enabled)

Step 4: (create interfaces, remaining config in vlan-interface level)
interface vlan 1
  description **Give me a comment**
  ip address 172.16.6.250/24
  ip dhcp-relay X.X.X.X <-- ip of DHCP server
 
  no shutdown
interface vlan 100
  ip address 172.16.100.1/24
  no shutdown
interface vlan 200
  ip address 172.16.200.1/24
  no shutdown


Step 5: (in global config)
ip route 0.0.0.0/0 X.X.X.X name ThisIsADefaultRoute  <-- Obviously X.X.X.X is a static next-hop to the internet

Step 6: (configure in interface level config)
int eth1/17-32 <-- feel free to use ranges with dashes and commas for multi port configuration
  switchport <-- indicates a L2 interface and not routed
  switchport mode trunk <-- indicates multiple VLAN tags, all are allowed by Default
  switchport trunk allowed vlan 1-200 <-- prunes all other VLANs off of the interface (add, remove are also options)
  spanning-tree port type edge <-- Enables portfast, allows the port to skip spanning-tree learning phase and move to forwarding
  no shutdowd
int eth1/1-16
  switchport
  switchport mode trunk
  swithcport trunk allowed vlan 1-10,100
  switchport trunk native vlan 100
int eth1/33-48
  switchport
  switchport mode trunk
  swithcport trunk allowed vlan 1-10,200
  switchport trunk native vlan 200
  no shutdown


Bonus: (L3 interface, for routed uplink to firewall/router/etc)
int ethX/X
  no switchport <-- switches the interface to routed mode, no VLAN needed all native
  ip address x.x.x.x/xx
  no shutdown

Bonus 2: (reset an interface to default)
default interface ethX/X-X/X