Questo contenuto non è disponibile nella lingua selezionata.
Chapter 22. Reusing the same IP address on different interfaces
With Virtual routing and forwarding (VRF), administrators can use multiple routing tables simultaneously on the same host. For that, VRF partitions a network at layer 3. This enables the administrator to isolate traffic using separate and independent route tables per VRF domain. This technique is similar to virtual LANs (VLAN), which partitions a network at layer 2, where the operating system uses different VLAN tags to isolate traffic sharing the same physical medium.
One benefit of VRF over partitioning on layer 2 is that routing scales better considering the number of peers involved.
				Red Hat Enterprise Linux uses a virtual vrt device for each VRF domain and adds routes to a VRF domain by adding existing network devices to a VRF device. Addresses and routes previously attached to the original device will be moved inside the VRF domain.
			
Note that each VRF domain is isolated from each other.
22.1. Permanently reusing the same IP address on different interfaces
You can use the virtual routing and forwarding (VRF) feature to permanently use the same IP address on different interfaces in one server.
To enable remote peers to contact both VRF interfaces while reusing the same IP address, the network interfaces must belong to different broadcasting domains. A broadcast domain in a network is a set of nodes, which receive broadcast traffic sent by any of them. In most configurations, all nodes connected to the same switch belong to the same broadcasting domain.
Prerequisites
- 
							You are logged in as the rootuser.
- The network interfaces are not configured.
Procedure
- Create and configure the first VRF device: - Create a connection for the VRF device and assign it to a routing table. For example, to create a VRF device named - vrf0that is assigned to the- 1001routing table:- nmcli connection add type vrf ifname vrf0 con-name vrf0 table 1001 ipv4.method disabled ipv6.method disabled - # nmcli connection add type vrf ifname vrf0 con-name vrf0 table 1001 ipv4.method disabled ipv6.method disabled- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enable the - vrf0device:- nmcli connection up vrf0 - # nmcli connection up vrf0- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Assign a network device to the VRF just created. For example, to add the - enp1s0Ethernet device to the- vrf0VRF device and assign an IP address and the subnet mask to- enp1s0, enter:- nmcli connection add type ethernet con-name vrf.enp1s0 ifname enp1s0 master vrf0 ipv4.method manual ipv4.address 192.0.2.1/24 - # nmcli connection add type ethernet con-name vrf.enp1s0 ifname enp1s0 master vrf0 ipv4.method manual ipv4.address 192.0.2.1/24- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Activate the - vrf.enp1s0connection:- nmcli connection up vrf.enp1s0 - # nmcli connection up vrf.enp1s0- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
- Create and configure the next VRF device: - Create the VRF device and assign it to a routing table. For example, to create a VRF device named - vrf1that is assigned to the- 1002routing table, enter:- nmcli connection add type vrf ifname vrf1 con-name vrf1 table 1002 ipv4.method disabled ipv6.method disabled - # nmcli connection add type vrf ifname vrf1 con-name vrf1 table 1002 ipv4.method disabled ipv6.method disabled- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Activate the - vrf1device:- nmcli connection up vrf1 - # nmcli connection up vrf1- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Assign a network device to the VRF just created. For example, to add the - enp7s0Ethernet device to the- vrf1VRF device and assign an IP address and the subnet mask to- enp7s0, enter:- nmcli connection add type ethernet con-name vrf.enp7s0 ifname enp7s0 master vrf1 ipv4.method manual ipv4.address 192.0.2.1/24 - # nmcli connection add type ethernet con-name vrf.enp7s0 ifname enp7s0 master vrf1 ipv4.method manual ipv4.address 192.0.2.1/24- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Activate the - vrf.enp7s0device:- nmcli connection up vrf.enp7s0 - # nmcli connection up vrf.enp7s0- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
22.2. Temporarily reusing the same IP address on different interfaces
You can use the virtual routing and forwarding (VRF) feature to temporarily use the same IP address on different interfaces in one server. Use this procedure only for testing purposes, because the configuration is temporary and lost after you reboot the system.
To enable remote peers to contact both VRF interfaces while reusing the same IP address, the network interfaces must belong to different broadcasting domains. A broadcast domain in a network is a set of nodes which receive broadcast traffic sent by any of them. In most configurations, all nodes connected to the same switch belong to the same broadcasting domain.
Prerequisites
- 
							You are logged in as the rootuser.
- The network interfaces are not configured.
Procedure
- Create and configure the first VRF device: - Create the VRF device and assign it to a routing table. For example, to create a VRF device named - bluethat is assigned to the- 1001routing table:- ip link add dev blue type vrf table 1001 - # ip link add dev blue type vrf table 1001- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enable the - bluedevice:- ip link set dev blue up - # ip link set dev blue up- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Assign a network device to the VRF device. For example, to add the - enp1s0Ethernet device to the- blueVRF device:- ip link set dev enp1s0 master blue - # ip link set dev enp1s0 master blue- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enable the - enp1s0device:- ip link set dev enp1s0 up - # ip link set dev enp1s0 up- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Assign an IP address and subnet mask to the - enp1s0device. For example, to set it to- 192.0.2.1/24:- ip addr add dev enp1s0 192.0.2.1/24 - # ip addr add dev enp1s0 192.0.2.1/24- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
- Create and configure the next VRF device: - Create the VRF device and assign it to a routing table. For example, to create a VRF device named - redthat is assigned to the- 1002routing table:- ip link add dev red type vrf table 1002 - # ip link add dev red type vrf table 1002- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enable the - reddevice:- ip link set dev red up - # ip link set dev red up- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Assign a network device to the VRF device. For example, to add the - enp7s0Ethernet device to the- redVRF device:- ip link set dev enp7s0 master red - # ip link set dev enp7s0 master red- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enable the - enp7s0device:- ip link set dev enp7s0 up - # ip link set dev enp7s0 up- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Assign the same IP address and subnet mask to the - enp7s0device as you used for- enp1s0in the- blueVRF domain:- ip addr add dev enp7s0 192.0.2.1/24 - # ip addr add dev enp7s0 192.0.2.1/24- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
- Optional: Create further VRF devices as described above.