07-VLAN Configuration

HomeSupportConfigure & DeployConfiguration ExamplesH3C Routers Easy and Effortless Routing Feature Configuration Examples-6W10007-VLAN Configuration
02-Internet Access Through a Routing Protocol (CLI)

Internet Access Through a Routing Protocol

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Copyright © 2024 New H3C Technologies Co., Ltd. All rights reserved.

No part of this manual may be reproduced or transmitted in any form or by any means without prior written consent of New H3C Technologies Co., Ltd.

Except for the trademarks of New H3C Technologies Co., Ltd., any trademarks that may be mentioned in this document are the property of their respective owners.

The information in this document is subject to change without notice.



Introduction

The following information provides examples for configuring a routing protocol to implement Internet access for a switch.

Prerequisites

This document is not restricted to specific software or hardware versions. Procedures and information in the examples might be slightly different depending on the software or hardware version of the device.

The configuration examples were created and verified in a lab environment, and all the devices were started with the factory default configuration. When you are working on a live network, make sure you understand the potential impact of every command on your network.

The following information is based on the assumption that you have basic knowledge of VLANs and static routes.

Configuration example

Network configuration

As shown in Figure 1, Host A and Host B are connected to the switch. Host A belongs to VLAN 2, and Host B belongs to VLAN 3. On the switch, the IP address of VLAN interface 1 is 192.168.1.254/24, the IP address of VLAN interface 2 is 192.168.2.1/24, and the IP address of VLAN interface 3 is 192.168.3.1/24. On the device, the IP address of VLAN interface 1 is 192.168.1.1/24. Configure the switch and the device to enable Host A and Host B to access the Internet.

Figure 1 Network diagram

 

Analysis

To allow Layer 3 forwarding between the device and the switch through VLAN interface 1:

·     Configure two static routes on the device: one route has a destination address of 192.168.2.0/24 and a next hop of 192.168.1.254, and the other route has a destination address of 192.168.3.0/24 and a next hop of 192.168.1.254.

·     Configure a default route with a next hop of 192.168.1.1 on the switch.

Procedure

1.     Configure Host A and Host B:

# Assign IP address 192.168.2.2/24 to Host A, and configure its gateway address as 192.168.2.1/24. Assign IP address 192.168.3.2/24 to Host B, and configure its gateway address as 192.168.3.1/24.

2.     Configure the switch:

# Create VLAN 2 and VLAN 3.

<Switch> system-view

[Switch] vlan 2 to 3

# Assign GigabitEthernet 1/0/2 to VLAN 2.

[Switch] interface gigabitethernet 1/0/2

[Switch-GigabitEthernet1/0/2] port access vlan 2

[Switch-GigabitEthernet1/0/2] quit

# Assign GigabitEthernet 1/0/3 to VLAN 3.

[Switch] interface gigabitethernet 1/0/3

[Switch-GigabitEthernet1/0/3] port access vlan 3

[Switch-GigabitEthernet1/0/3] quit

# Create VLAN interface 1, and assign IP address 192.168.1.254/24 to the interface.

[Switch] interface vlan-interface 1

[Switch-Vlan-interface1] ip address 192.168.1.254 255.255.255.0

[Switch-Vlan-interface1] quit

# Create VLAN interface 2, and assign IP address 192.168.2.1/24 to the interface.

[Switch] interface vlan-interface 2

[Switch-Vlan-interface2] ip address 192.168.2.1 255.255.255.0

[Switch-Vlan-interface2] quit

# Create VLAN interface 3, and assign IP address 192.168.3.1/24 to the interface.

[Switch] interface vlan-interface 3

[Switch-Vlan-interface3] ip address 192.168.3.1 255.255.255.0

[Switch-Vlan-interface3] quit

# Configure a default route.

<Switch> system-view

[Switch] ip route-static 0.0.0.0 0.0.0.0 192.168.1.1

3.     Configure the device:

# Create VLAN interface 1, and assign IP address 192.168.1.1/24 to the interface.

<Device> system-view

[Device] vlan 1

[Device-vlan1] quit

[Device] interface vlan-interface 1

[Device-Vlan-interface1] ip address 192.168.1.1 255.255.255.0

[Device-Vlan-interface1] quit

# Configure two static routes.

[Device] ip route-static 192.168.2.0.0 255.255.255.0 192.168.1.254

[Device] ip route-static 192.168.3.0.0 255.255.255.0 192.168.1.254

Verifying the configuration

Verify that both Host A and Host B can access the Internet.

Configuration files

·     Switch:

#

vlan 1

#

vlan 2

#

vlan 3

#

interface Vlan-interface1

 ip address 192.168.1.254 255.255.255.0

#

interface Vlan-interface2

 ip address 192.168.2.1 255.255.255.0

#

interface Vlan-interface3

 ip address 192.168.3.1 255.255.255.0

#

interface GigabitEthernet1/0/1

 port link-mode bridge

#

interface GigabitEthernet1/0/2

 port link-mode bridge

 port access vlan 2

#

interface GigabitEthernet1/0/3

 port link-mode bridge

 port access vlan 3

#

 ip route-static 0.0.0.0 0 192.168.1.1

#

·     Device:

#

vlan 1

#

interface Vlan-interface1

 ip address 192.168.1.1 255.255.255.0

#

 ip route-static 192.168.2.0.0 24 192.168.1.254

 ip route-static 192.168.3.0.0 24 192.168.1.254

#

interface GigabitEthernet1/0/1

 port link-mode bridge

#

Related documentation

·     VLAN Configuration in H3C MSR Router Series Comware 7 Configuration Guides

·     VLAN Commands in H3C MSR Router Series Comware 7 Command References

·     Static Routing Configuration in H3C MSR Router Series Comware 7 Configuration Guides

·     Static Routing Commands in H3C MSR Router Series Comware 7 Command References

  • Cloud & AI
  • InterConnect
  • Intelligent Computing
  • Security
  • SMB Products
  • Intelligent Terminal Products
  • Product Support Services
  • Technical Service Solutions
All Services
  • Resource Center
  • Policy
  • Online Help
All Support
  • Become A Partner
  • Partner Policy & Program
  • Global Learning
  • Partner Sales Resources
  • Partner Business Management
  • Service Business
All Partners
  • Profile
  • News & Events
  • Online Exhibition Center
  • Contact Us
All About Us
新华三官网