15 Replies Latest reply: Jun 6, 2017 9:43 PM by Marius RSS

    how to assign static IP on a switch

    rishi

      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 - CCNA Sec / CCNP R&S

                            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

                            • 12. Re: how to assign static IP on a switch
                              Jawad

                              Hello Josph

                               

                              Will you please right syntax how to run command " no switch port" as i tried but not success..

                               

                              Thank you

                              • 13. Re: how to assign static IP on a switch
                                Marius

                                Hi Rishi,

                                 

                                There are two ways to configuring a switch with an IP address, and this is done only under the interface configuration:

                                Assign a static IP with:                                    ip address ip_address network_mask

                                Dynamically obtain IP from DHCP service:    ip address dhcp

                                 

                                Let's clarify on which interface type can we apply the IP configuration.

                                 

                                As you read the previously replies, there are two types of switches: ones that have only Layer 2 capabilities - forwarding frames,  or others that have both, the L2 and L3  - switching frames and packets.

                                Note: That the process of "routing" on a multilayer switch is called packet switching as it is performed on hardware - different from what a software router does.

                                 

                                Differences between a switch port and an interface:

                                - a switch port has no intelligence and only perform L2 capability by forwarding frames based on physical MAC addresses. A switch port is like a bridge - forwarding from one layer to the same layer, so as a result you cannot assign an virtual IP to a switch port - it has only a physical MAC address;

                                - in exchange, an interface, has its own intelligence where encapsulate frames from L2 to upper layer into packets. So because an interface is a multilayer capable it must have a physical MAC address and could also have a virtual L3 address as an IP.

                                 

                                So, because a L2 switch cannot have an virtual IP address on none of its switch ports, Cisco introduce the concept of SVI (Switch Virtual Interface), where you can create them and have an IPs assigned to them. The SVI represent the switch ports on the belonging VLAN and where it acts as a default gateway for the VLAN, performing in this way a L3 capabilities.

                                 

                                Configuring a static IP on a L2 switch capability:

                                 

                                SW(config)#interface vlan1

                                SW(config-if)#ip address ip_address network_mask

                                 

                                Note: To have the SVI become in up state, you must have at least one switch ports that belongs to the same VLAN group where the SVI point, to be up also.

                                 

                                 

                                Now, on a L3 switch you can configure the IP address in both cases:

                                - you can also create a SVI and assign an address to it, same as the L2 switch;

                                - or you can directly assign the IP address to the interface:

                                 

                                But, there is a small "trick" here. Remember that a L3 switch can have a switch port or an interface.

                                How to turn a switch port into an interface and vice-versa on a L3 switch?

                                By using the commands "switchport" or "no switchport"

                                 

                                Example:

                                SW(config)#interface f0/1

                                SW(config-if)#no switchport

                                SW(config-if)#ip address ip_address network_mask

                                 

                                Important:

                                Switch models restrictions:

                                - on some L2 switch models you cannot create more then one SVI;

                                - on some L3 switch models not all interfaces has L2 capabilities. Is were the "switchport" command is not allowed.

                                 

                                Also you cannot turn a router interface into a switchport unless you have a L2\L3 module.

                                • 14. Re: how to assign static IP on a switch
                                  Marius

                                  Sorry, have to correct:

                                  - on L2 switch models you cannot create more then one SVI and usually this is configured for the management VLAN;