> For the complete documentation index, see [llms.txt](https://moluo.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://moluo.gitbook.io/notes/bian-cheng-xue-xi/wang-luo/cisco/lu-you-qi-chang-yong-ming-ling.md).

# 路由器常用命令

配置路由器 配置路由器密码： （1）配置Console端口密码： R1(config)# line console 0 R1(config-line)# password cisco R1(config-line)# login （2）配置从用户模式切换到特权模式的使能密码： R1(config)# enable password cisco R1(config)# enable secret cisco123 （另外可以配置秘密使能密码） （3）配置远程登录密码（VTY，虚拟终端类型）默认不允许远程访问 R1(config)#line vty 0 4 R1(config-line)#password cisco R1(config-line)#login

配置路由器接口IP：

```bash
R1(config)# interface s1/1
R1(config-if)# ip address 12.1.1.1 255.255.255.0
R1(config-if)# no shutdown
R1(config-if)# exit
```

配置路由器接口secondary地址：

```bash
R1(config)# interface s1/1
R1(config-if)# ip address 12.1.1.1 255.255.255.0
R1(config-if)# ip address 13.1.1.1 255.255.255.0 secondary
R1(config-if)# no shutdown
R1(config-if)# exit
```

取消接口的多个IP地址：

```bash
R1(config-if)# no ip address [ip] [子网掩码]
```

删除接口下的所有IP：

```bash
R1(config-if)# no ip address
```

配置主机名列表：

```bash
R1(config)#ip host abc 12.1.1.2 (配置完后远程登录可以用telnet abc代替主机IP)
```

查看路由器上配置的主机名列表:

```bash
show host
```

配置DNS服务器：

```bash
ip name-server dns 服务器的IP地址
```

配置静态路由 R1(config)#ip route 目标网络 掩码 下一跳路由器直连接口的IP或本路由器外出接口 管理距离 \[permanent] 使用permanent参数，不管发生什么意外情况，该静态路由不会从路由表消失。 前面加no删除该静态路由。

默认路由：用来转发不在路由列表中列出的远端目的网络的数据包 R1(config)#ip route 0.0.0.0 0.0.0.0 下一跳路由地址

动态路由 1. RIPv1协议配置

```bash
  R1(config)# router rip  启动路由选择进程
  R1(config-router)#network 11.0.0.0  宣告各接口的直连网络
  R1(config-router)#network 12.0.0.0
```

配置默认路由（默认网关）：

```bash
R1(config)# ip route 0.0.0.0 0.0.0.0 23.1.1.3
R1(config)# ip default-network 23.0.0.0  默认网络，仅支持有类网络后面要写网络的主类地址
```

负载均衡：

```bash
R1(config-router)#maximum-paths 6
```

关闭快速交换使用进程交换：

```bash
R1(config)#no ip cef
```

禁用水平分割：

```bash
R1(config-if)# no ip split-horizon
```

1. RIPv2协议配置

   ```bash
   R1(config)# router rip
   R1(config-router)# version 2
   R1(config-router)#network 主类网络号
   ```
2. OSPF协议配置

   ```bash
   R1(config)#router ospf 1
   R1(config-router)#network IP子网 反掩码 area 0
   ```

## 使用路由器模拟PC

```bash
conf t
no ip routing
interface f0/0
ip address 200.200.200.200 255.255.255.0
ip default-gateway 200.200.200.1
no shutdown

end
show interfaces f0/0
show ip route
```
