11 Replies Latest reply: Apr 23, 2014 4:36 AM by Isaac RSS

    how to assign static IP on a switch

    rishi
      Powerful, on-demand CCNA and CCNP Resources:
      Cisco Learning Network Premium

       

      hi

       

      can nebdy tell d the commands to assign static IP on a switch

       

      guess we do use Mac address here

       

      Keith

       

      a request plzz create a video on this

       

      or if its already created

       

      share the link

       

      regards

       

      Rishi

        • 1. Re: how to assign static IP on a switch
          Joseph Nelson

          Hi Rishi,

           

          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

           

          Joe

          • 2. Re: how to assign static IP on a switch
            Angela

              Basically, to assign a static IP address, use 'ip address', you can do this for a VLAN in a L2 or L3 switches. In MLS, you can convert a port to L3 port using 'no switchport' then configure an IP address on that physical port.

             

              On the other hand, if you are talking about static route, you can only configure it on L3 switches as L2 switches can't route.

             

             

            Regards

            • 3. Re: how to assign static IP on a switch
              Joseph Nelson

              Ahhhh Angela,

               

              Thanks for pointing that out....before you can assign an ip to a port, you must disable switching on the port with the "no switchport" sub interface command.

               

              Thanks again, it was an oversight on my part.

               

              Joe

              • 4. Re: how to assign static IP on a switch
                Angela

                You are very welcome, I also have many times when others pointed out something I did think of. It's great to study with everybody, happy learner

                 

                Regards

                • 6. Re: how to assign static IP on a switch
                  cadetalain

                  Hi,

                   

                  if you want to create an IP address for management then just simply use a SVI:

                  eg

                  int vlan 1

                  ip address 192.168.1.1 255.255.255.0

                   

                  Regards.

                   

                  Alain

                  • 7. Re: how to assign static IP on a switch
                    Rahul

                    yeah well if he wanna create a management VLAN then its the way,,

                    His question was doubtfull so i gave him the way to create routed port on Layer 3

                    • 8. Re: how to assign static IP on a switch
                      cadetalain

                      Hi,

                       

                      yes indeed the question was ambiguous .

                       

                      Regards.

                       

                      Alain

                      • 9. Re: how to assign static IP on a switch
                        Joshua Johnson - CCNP R&S

                        Yeah you may want to say SVI or VLAN interface for the newer people even though we know what you are talking about, Angela

                         

                        Angela wrote:

                         

                          Basically, to assign a static IP address, use 'ip address', you can do this for a VLAN in a L2 or L3 switches. In MLS, you can convert a port to L3 port using 'no switchport' then configure an IP address on that physical port.

                         

                          On the other hand, if you are talking about static route, you can only configure it on L3 switches as L2 switches can't route.

                         

                         

                        Regards

                        • 10. Re: how to assign static IP on a switch
                          Ashish

                          Hi

                          For assigning  Static ip to a Switch,

                          Assign IP to VLAN 1 by command

                           

                          Switch>enable

                          Switch#conf ter

                          Enter configuration commands, one per line.  End with CNTL/Z.

                          Switch(config)#interfac

                          Switch(config)#interface vlan 1

                          Switch(config-if)#ip address 192.168.1.1 255.255.255.0

                          Switch(config-if)#no shut

                           

                           

                          Switch(config-if)#

                          %LINK-5-CHANGED: Interface Vlan1, changed state to up

                           

                           

                          Switch(config-if)#^Z

                          Switch#

                          %SYS-5-CONFIG_I: Configured from console by console

                           

                           

                          Switch#

                          • 11. Re: how to assign static IP on a switch
                            Isaac

                            Hello Rishi

                             

                            I just would like to add my to cents..

                             

                            Using vlan 1 is never a good idea. Just create a vlan for managemnt of your network devices - specially if you are talking about a production network.

                             

                            Best regards

                             

                            Isaac