Before we published about the Internet connection before the switch and the firewall, friends kept asking about the Internet connection configuration before the switch and the router. This is widely used in actual projects. Basically, some large-scale network projects need to be configured. About The topic of switch and router configuration is also constantly discussed.
In this issue, let’s learn about the configuration of the connection between the switch and the router.
Case: Layer 3 switch and router interconnection configuration
1. Project situation
A company has multiple departments located on different network segments, and each department needs to access the Internet. Users are now required to access the external network through layer-3 switches and routers, and layer-3 switches are required to serve as the user’s gateway. Here we take Huawei switches as an example.
Use the following ideas to configure:
1. Configure the switch as the gateway for users, and realize mutual access between users across network segments through the VLANIF interface.
2. Configure the switch as a DHCP server to assign IP addresses to users.
3. Configure the router to pass NAT conversion, so that users can access the external network.
3. Switch configuration
Configure the switch
# Configure the interface connecting users and the corresponding VLANIF interface.
# Configure the interface connected to the router and the corresponding VLANIF interface.
# Configure DHCP server.
2. Configure the router
# Configure the IP address corresponding to the interface connected to the switch.
# Configure the IP address corresponding to the interface connected to the public network.
# Configure the default route and return route.
# Configure the NAT function so that intranet users can access the external network.
4.Check the configuration results
Set the IP address of PC1 to 192.168.1.2/24 and the gateway to 192.168.1.1; the IP address of PC2 to 192.168.2.2/24 and the gateway to 192.168.2.1.
Configure the IP address of the PC on the external network as 18.104.22.168/24 and the gateway as 22.214.171.124.
After the configuration is complete, both PC1 and PC2 can ping the IP 126.96.36.199/24 of the external network, and both PC1 and PC2 can access the Internet.
Add here: What is vlanif? The difference between it and vlan?
Many friends have asked about this vlanif interface many times, here is the addition:
vlanif is used when creating a layer-3 interface. It is a virtual interface and can be configured with an IP address; vlan is a purely layer-2 vlan ID identifier, which is equivalent to labeling data.
After VLANs are divided, users in the same VLAN can communicate with each other, but users in different VLANs cannot communicate directly. In order to realize inter-VLAN communication, it can be realized by configuring a logical Layer 3 interface (VLANIF interface).
When a switch needs to communicate with devices at the network layer, a VLAN-based VLANIF interface can be created on the switch for communication. Therefore, multiple vlanifs are configured in this article, and it is easier to understand if you can imagine vlanif as a port of a router.