# Set initial configuration in Cisco devices

## Intro <a href="#intro" id="intro"></a>

In this section learn how to set initial configuration in Cisco devices. You can also follow the video of this section on my channel on YouTube.

&#x20;We have 3 modes in Cisco devices, namely:

| Modes          | Symbols         | command                                                |
| -------------- | --------------- | ------------------------------------------------------ |
| User mode      | switch>         | -                                                      |
| Privilege mode | switch#         | enter *enable in* user mode                            |
| Global mode    | switch(config)# | enter *config terminal* or *conf t* to enter this mode |

In privilege mode, you can run show commands, while in global mode you can change configuration of switch.

## 1-1 Setting hostname <a href="#id-1-1-setting-hostname" id="id-1-1-setting-hostname"></a>

```
sw# conf t
sw(config)# hostname Cisco
```

## 1-2 Setting password for line console <a href="#id-1-2-setting-password-for-line-console" id="id-1-2-setting-password-for-line-console"></a>

![Console to PC ](/files/-LA9a0_hKn53wvAkbCDJ)

```
sw# conf t
sw(config)# line console 0
sw(config)# password CISCO
sw(config)# login
```

{% hint style="info" %}
&#x20;In line 4, if you forget to write *login*, switch will not ask any password. So, you have to write it, to enable password in line console 0.
{% endhint %}

## &#x20;1-3 Setting password for line vty <a href="#id-1-3-setting-password-for-line-vty" id="id-1-3-setting-password-for-line-vty"></a>

vty lines are using for users to connect via SSH, Telnet. In other words, to enable SSH or Telnet, you have to use these lines. By default, Cisco breaks up vty lines into two segments:

* vty 0 - 4 (older devices)
* vty 5- 15

```
sw# conf t
sw(config)# line vty 0 15
sw(config)# password CISCO
sw(config)# login
```

{% hint style="info" %}
&#x20;New devices have more than 15 vty. Usually system administrator define 5 vty in devices.
{% endhint %}

## 1-4 Setting password for the privilege mode <a href="#id-1-4-setting-password-for-the-privilege-mode" id="id-1-4-setting-password-for-the-privilege-mode"></a>

we have two options for setting password for the privilege mode:

* *password* which is in clear mode
* *secret* which is encryption mode

```
sw# conf t
sw(config)# enable password CISCO
```

or

```
sw# conf t
sw(config)# enable sercret CISCO
```

## 1-5 Encrypt your Cisco device <a href="#id-1-5-encrypt-your-cisco-device" id="id-1-5-encrypt-your-cisco-device"></a>

if you use *password* instead of *secret with # show running-config command you can see the* clear password. To encrypt the password use this command:

```
sw# conf t
sw(config)# service password-encryption
```

now if you look at running-config , everything has become encrypted.

![encrypted password](https://blobscdn.gitbook.com/v0/b/gitbook-28427.appspot.com/o/assets%2F-LA8bJEHYZEGCK8WGuvC%2F-LA8ntNEY7txCCKzqPCE%2F-LA8qO-5fbD05rXzX5ls%2Fimage.png?alt=media\&token=fcfb46ce-a4d6-4249-8300-89dd822f1df9)

## 1-6 Setting IP address for default vlan <a href="#id-1-6-setting-ip-address-for-default-vlan" id="id-1-6-setting-ip-address-for-default-vlan"></a>

by default, all Cisco devices have vlan 1, so in other section will know how to make a vlan. In this code, we set IP address 192.168.1.1 with subnet mask 255.255.255.0. Then, we use command *no shutdown* to enable interface.

```
sw# conf t
sw(config)# int vlan 1
sw(config-if)# ip address 192.168.1.1 255.255.255.0
sw(config-if)#no shutdown
```

{% hint style="info" %}
&#x20;Cisco recommends all use any vlan number except vlan 1.
{% endhint %}

## 1-7 Setting default gateway <a href="#id-1-7-setting-default-gateway" id="id-1-7-setting-default-gateway"></a>

if you have router and you want to access your Cisco switch to router for the Internet, you have to set default gateway.

```
sw# conf t
sw(config)# ip default-gateway 192.168.1.254
```

## 1-8 Shutdown ports <a href="#id-1-8-shutdown-ports" id="id-1-8-shutdown-ports"></a>

you can shutdown ports for the range of ports. For example, range of 1 to 4 is shutdown by *shutdown* command.

```
sw# conf t
sw(config)# int range fa0/1-4
sw(config)# shutdown
```

> use *no shutdown* or *no shut* to enable ports

## 1-9 Setting banner <a href="#id-1-9-setting-banner" id="id-1-9-setting-banner"></a>

you can set a banner for a switch with motd command. After motd you have to use kind of character and it can be \* + | or anything. The important matter is that both character should be the same as the code it is shown

```
sw# conf t
sw(config)# banner motd +
******************************************
cisco 3850 by HRT
​******************************************
+
```

​

![](https://blobscdn.gitbook.com/v0/b/gitbook-28427.appspot.com/o/assets%2F-LA8bJEHYZEGCK8WGuvC%2F-LA8yl0n6JuL2P0VIvJR%2F-LA9-RH55V-ASpaaH719%2Fimage.png?alt=media\&token=42a15555-3843-40b0-a1a3-7f0622f2e6d0)

​

## 1-10 Prevent mistype <a href="#id-1-10-prevent-mistype" id="id-1-10-prevent-mistype"></a>

​

![](https://blobscdn.gitbook.com/v0/b/gitbook-28427.appspot.com/o/assets%2F-LA8bJEHYZEGCK8WGuvC%2F-LA8yl0n6JuL2P0VIvJR%2F-LA96rynU9t4AAcWsX12%2Fimage.png?alt=media\&token=3755f6bb-8043-4d4c-9697-2ad291f7fa26)

Mistype translating domain server

In Cisco devices, if you enter a some command wrong, by default try to map it to domain name and it takes 30 sec to do that. To prevent mistype, we use this command:

```
sw# conf t
sw(config)# no ip domain-lookup
```

## 1-11 Setting timeout <a href="#id-1-11-setting-timeout" id="id-1-11-setting-timeout"></a>

if you are working with Cisco command line, you can set session timeout with these command. In these examples, we set timeout to 10 seconds.

**vty line:**

```
sw# conf t
sw(config)# line vty 0 5
sw(config)# exec-timeout 0 10
```

**line console:**

```
sw# conf t
sw(config)# line cosole 0
sw(config)# exec-timeout 0 10
```

## 1-12 **save configuration** <a href="#id-1-12-save-configuration" id="id-1-12-save-configuration"></a>

to save your configuration you can run these two commands:

```
sw# copy running-config startup-config
```

or

```
sw# write
```

## ​


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hamidsec.gitbook.io/cisco/setting-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
