how to assign static IP on a switch – 14861 – The Cisco Learning Network

As you may know there are layer 2 and layer 3 switches. A layer 2 switch only does layer 2 fowarding, as such it doesn’t have any additional ip interfaces. On a layer 2 switch the ip address is instead assigned to the vlan interface:

 

config t

interface vlan 1

ip address 192.168.1.1 255.255.255.0

 

* Note on a L2 switch you can assign an ip to any vlan you want (vlan 1, vlan 2, vlan 4000). You can only assign an ip address to one vlan at a time on a l2 switch. If you configured an ip on a vlan and then try to assign an ip to another vlan…the switch will shut down the first vlan and bring up the second vlan interface)*

 

On a L3 switch you can have multiple ip interfances. Unlike a L2 switch, an L3 switch can have static ip addresses on multiple vlan interfaces (configuration is the same as the above example). In addtion unlike L2 swithes a L3 switch can have a static ip address assigned to any one of its fastethernet (fa0/1) or gig ethernet ports (gi0/1).

 

Config t

int fa0/1

ip address 192.168.1.1 255.255.255.0

description *** Assigning an ip address to a physical fast ethernet port on the switch***

 

int vlan 1

ip address 192.168.2.1 255.255.255.0

description *** Assigning an ip address to the virtual (vlan) interface on the switch ***

 

int vlan 2

ip address 192.168.3.1 255.255.255.0

description *** Assigning an ip address to another virtual (vlan) interface on the switch ***

 

Note that although you can assign multiple ip addresses on a L3 switche’s physical (e.g. fa0/1 fa0/2 gi0/1) or virtual (vlan 1, vlan 3, vlan 3000, or a loopback lo1, lo2,lo3), all of the ip address must be in different networks. If subnetting is used, the interfaces belonging to the same switch must have a different subnet mask.

 

Example

 

int fa0/1

ip address 192.168.1.1 255.255.255.252

description *** This interface is on the 192.168.1.0/30 network ***

 

int fa0/2

ip address 192.168.1.5 255.255.255.252

description *** This interface is on the 192.168.1.4/30 network***

 

int vlan 1

ip address 192.168.9 255.255.255.252

description *** This interface is on the 192.168.1.8/30 network ***

 

HTH

Source: how to assign static IP on a switch – 14861 – The Cisco Learning Network

how to assign static IP on a switch – 14861 – The Cisco Learning Network was last modified: July 13th, 2017 by Jovan Stosic