text
stringlengths
0
6.55k
R1 192.168.1.1 (Default Gateway)
Interface VLAN 1
192.168.1.200
(Box Shows Internal Switch Concepts)
Figure 6-8 The Need for a Default Gateway
Configuring IPv4 on a Switch
A switch configures its IPv4 address and mask on this special NIC-like VLAN interface. The following steps list the commands used to configure IPv4 on a switch, assuming that the IP address is configured to be in VLAN 1, with Example 6-7 that follows showing an example configuration.
Config Checklist
Step 1. Use the interface vlan 1 command in global configuration mode to enter inter-face VLAN 1 configuration mode.
Step 2. Use the ip address ip-address mask command in interface configuration mode to assign an IP address and mask.
Step 3. Use the no shutdown command in interface configuration mode to enable the VLAN 1 interface if it is not already enabled.
Step 4. Add the ip default-gateway ip-address command in global configuration mode to configure the default gateway.
Step 5. (Optional) Add the ip name-server ip-address1 ip-address2 … command in global configuration mode to configure the switch to use Domain Name System
(DNS) to resolve names into their matching IP address.
Example 6-7 Switch Static IP Address Configuration
Emma# configure terminal
Emma(config)# interface vlan 1
Emma(config-if)# ip address 192.168.1.200 255.255.255.0
Emma(config-if)# no shutdown
00:25:07: %LINK-3-UPDOWN: Interface Vlan1, changed state to up
00:25:08: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed
state to up
Emma(config-if)# exit
Emma(config)# ip default-gateway 192.168.1.1
|||||||||||||||||||| Technet24
||||||||||||||||||||
Chapter 6: Configuring Basic Switch Management 143
On a side note, this example shows a particularly important and common command: the [no] shutdown command. To administratively enable an interface on a switch, use the no shutdown interface subcommand; to disable an interface, use the shutdown interface
subcommand. This command can be used on the physical Ethernet interfaces that the switch uses to switch Ethernet messages in addition to the VLAN interface shown here in this example.
Also, pause long enough to look at the messages that appear just below the no shutdown command in Example 6-7. Those messages are syslog messages generated by the switch stat-ing that the switch did indeed enable the interface. Switches (and routers) generate syslog messages in response to a variety of events, and by d...
Configuring a Switch to Learn Its IP Address with DHCP
The switch can also use Dynamic Host Configuration Protocol (DHCP) to dynamically learn its IPv4 settings. Basically, all you have to do is tell the switch to use DHCP on the interface and enable the interface. Assuming that DHCP works in this network, the switch will learn all its settings. The following list details ...
with Example 6-8 that follows showing an example:
6
Config Checklist
Step 1. Enter VLAN 1 configuration mode using the interface vlan 1 global configura-tion command, and enable the interface using the no shutdown command as necessary.
Step 2. Assign an IP address and mask using the ip address dhcp interface subcommand.
Example 6-8 Switch Dynamic IP Address Configuration with DHCP
Emma# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Emma(config)# interface vlan 1
Emma(config-if)# ip address dhcp
Emma(config-if)# no shutdown
Emma(config-if)# ^Z
Emma#
00:38:20: %LINK-3-UPDOWN: Interface Vlan1, changed state to up
00:38:21: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up
Verifying IPv4 on a Switch
The switch IPv4 configuration can be checked in several places. First, you can always look at the current configuration using the show running-config command. Second, you can look at the IP address and mask information using the show interfaces vlan x command, which shows detailed status information about the VLAN inte...
||||||||||||||||||||
||||||||||||||||||||
144 CCNA 200-301 Official Cert Guide, Volume 1
the running-config file.) Example 6-9 shows sample output from these commands to match the configuration in Example 6-8.