网关怎么设置才能上网(无线路由器密码重新设置的方法)

配置基于接口划分vlan示例二(接入层设备作为网关)

组网需求

如图 2-5 所示,S1 作为汇聚层交换机,S2、S3 作为 PC 电脑的网关设备下连 PC 电脑或 HUB 交换机;PC1 属于 vlan2 直连 SW2,网关为 vlanif 2 接口地址 192.168.2.1/24;PC2 属于 vlan 3 通过 hub接入到 SW2,网关为 vlanif3 接口地址 192.168.3.1/24;PC3 和 PC4 属于 vlan 4 直连 S3,网关为vlanif 4 接口地址 192.168.4.1/24;通过配置实现各 PC 电脑之间互访。

63b89bf69d5e4d8ba6d6bae5bd334061noop.image_

图 2-5 接入层做网关基于接口划分 vlan 组网

配置思路:

采用如下的思路配置 VLAN 间互通:

1. 创建 VLAN 并将连接用户的接口加入 VLAN,实现不同业务用户之间的二层流量隔离。

2. 配置各 PC 电脑的网关 IP 地址,实现相同业务用户之间三层互通

3. 配置静态路由实现不同业务用户之间三层互通

详细配置步骤:

SW2 配置如下:

1.创建 vlan

<SW2> system-view //进入系统模式

[SW2] vlan batch 2 to 3 //批量创建 vlan 2 和 3

[SW2] vlan 5 //新建 vlan 5

[SW2-vlan5] quit //退出 vlan 5

2.接口加入到相应 vlan

# SW2—–PC

[SW2] interface GigabitEthernet 0/0/3 //对接 PC1

[SW2-GigabitEthernet0/0/3] port link-type access //链路类型为 access

[SW2-GigabitEthernet0/0/3] port default vlan 2

[SW2-GigabitEthernet0/0/3] quit

[SW2] interface GigabitEthernet 0/0/2 //对接 PC2

[SW2-GigabitEthernet0/0/2] port link-type access

[SW2-GigabitEthernet0/0/2] port default vlan 3

[SW2-GigabitEthernet0/0/2] quit

# SW2—SW1

[SW2] interface GigabitEthernet 0/0/1 //对接 SW1

[SW2-GigabitEthernet0/0/1] port link-type access

[SW2-GigabitEthernet0/0/1] port default vlan 5

[SW2-GigabitEthernet0/0/1] quit

3.配置 ip 地址作为 PC 电脑的网关 IP 地址

[SW2] interface Vlanif 2 //系统视图下进入三层 vlanif 2

接口

[SW2-Vlanif2] ip address 192.168.2.1 255.255.255.0 //配置 PC1 的网关地址

[SW2-Vlanif2] quit //退出 vlanif 接口视图

[SW2] interface Vlanif 3

[SW2-Vlanif3] ip add 192.168.3.1 24

[SW2-Vlanif3] quit

4.配置 ip 地址实现 SW2 和 SW1 互联

[SW2] interface Vlanif 5

[SW2-Vlanif5] ip address 192.168.5.2 24 //互联接口 IP 地址

[SW2-Vlanif5] quit

5.配置静态路由,为 SW2 下 PC 网段出去指路

[SW2] ip route-static 0.0.0.0 0.0.0.0 192.168.5.1 //配置默认路由出去,下一跳为

对端 SW1 的接口地址 192.168.5.1

6.配置完成后保存配置

<SW2> save

SW3 配置如下:

1.创建 vlan

<SW3> system-view //进入系统模式

[SW3] vlan 4 //新建 vlan 4

[SW3-vlan4] quit // 退出 vlan 4

[SW3] vlan 5

[SW3-vlan5] quit

2.接口加入到相应 vlan

# SW2—–PC

[SW3] interface Ethernet 0/0/1 //接 PC 电脑

[SW3-Ethernet0/0/1] port link-type access //链路类型为 access

[SW3-Ethernet0/0/1] port default vlan 4

[SW3-Ethernet0/0/1] quit

# SW3—SW1

[SW3] interface GigabitEthernet 0/0/1 //对接 SW1

[SW3-GigabitEthernet0/0/1] port link-type access //链路类型为 access

[SW3-GigabitEthernet0/0/1] port default vlan 5

[SW3-GigabitEthernet0/0/1] quit

3.配置 IP 地址作为 PC 电脑的网关 IP 地址

[SW3] interface Vlanif 4 //系统视图进入 vlanif4 三层接口

[SW3-Vlanif4] ip address 192.168.4.1 24 //配置 PC3 和 PC4 的网关地址

[SW3-Vlanif4] quit

4.配置 ip 地址实现 SW3 和 SW1 互联

[SW3] interface Vlanif 5

[SW3-Vlanif5] ip address 192.168.5.3 24 //互联接口 IP 地址

[SW3-Vlanif5] quit

5.配置静态路由,为 SW3 下 PC 网段出去指路

[SW3] ip route-static 0.0.0.0 0.0.0.0 192.168.5.1 //配置默认路由出去,下一跳

为对端 SW1 的接口地址 192.168.5.1

6.配置完成后保存配置

<SW3> save

SW1 配置:

1.创建 vlan

<SW1> system-view //进入系统模式

[SW1] vlan 5 //新建 vlan 5

[SW1-vlan5] quit //退出 vlan5 模式

2.接口加入到相应 vlan 配置

[SW1] interface GigabitEthernet 0/0/2 //对接 SW2

[SW1-GigabitEthernet0/0/2] port link-type access //链路类型为 access

[SW1-GigabitEthernet0/0/2] port default vlan 5 //透传 vlan5

[SW1-GigabitEthernet0/0/2] quit //退出接口 GE0/0/5

[SW1] interface GigabitEthernet 0/0/24 //对接 SW3

[SW1-GigabitEthernet0/0/24] port link-type access

[SW1-GigabitEthernet0/0/24] port default vlan 5

[SW1-GigabitEthernet0/0/24] quit

[SW1] interface GigabitEthernet 0/0/1 //对接 R 路由器

[SW1-GigabitEthernet0/0/1] port link-type access

[SW1-GigabitEthernet0/0/1] port default vlan 5

[SW1-GigabitEthernet0/0/1] quit

3. 配 IP 地址,作为对接 SW2、SW3 及 R 路由器的互联接口地址

[SW1] interface Vlanif 5 //进入三层接口 vlanif5

[SW1-Vlanif5] ip address 192.168.5.1 24 //配置 ip 地址

[SW1-Vlanif5] quit //退出 vlanif 5

4.配置静态路由

# 配置回程明细路由,实现内网网段之间互访

[SW1] ip route-static 192.168.2.0 255.255.255.0 192.168.5.2

[SW1] ip route-static 192.168.3.0 255.255.255.0 192.168.5.2

[SW1] ip route-static 192.168.4.0 255.255.255.0 192.168.5.3

# 配置默认路由实现内网网段到 R 实现上网,假设对端接口地址为 192.168.5.4

[SW1] ip route-static 0.0.0.0 0.0.0.0 192.168.5.4

5.配置完成后保存配置

<SW1> save

本文内容来自网友供稿,文章观点仅代表作者本人,本站非盈利且无偿提供信息存储空间服务,不拥有所有权,如有文章有不实信息或侵犯了您的权益,请发送邮件至 cfseo1997@163.com 反馈核实,如需转载请注明出处:https://www.taobobolive.com/149832.html

(0)
上一篇 2023年3月27日 11:52:33
下一篇 2023年3月27日 11:54:07

相关推荐