Found 0 result in total
Content is empty
If you don't find the content you expect, please try another search term
Last updated:2021-08-04 11:26:31
This topic describes how to configure elastic network interfaces (ENIs) for your KEC instances after the ENIs are attached to the instances. After a secondary ENI is attached to a KEC instance that runs the Windows operating system, the KEC instance can be directly used without additional operations.
If a KEC instance uses the following versions of images, you can skip the manual configuration of ENIs and directly configure routes:
Open the configuration file of an ENI.
vi /etc/sysconfig/network-scripts/ifcfg-eth1
Press the I key to enter the edit mode and add the configuration information to the ENI configuration file. Example:
DEVICE=eth1 # The new ENI.
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
Press the Esc key, enter :wq
, and then press the Enter key to save the file and exit the edit mode.
Check the ENI configuration file and confirm the modification.
cat /etc/sysconfig/network-scripts/ifcfg-eth1
Start ETH1.
ifup eth1
If an error is reported, run the service network restart
command to restart the network service.
Open the configuration file of an ENI.
vi /etc/network/interfaces
Press the I key to enter the edit mode and add the configuration information to the ENI configuration file. Take ETH1 as an example:
auto eth0
iface eth0 inet dhcp
auto eth1 # The new ENI.
iface eth1 inet dhcp
Press the Esc key, enter :wq
, and then press the Enter key to save the file and exit the edit mode.
Check the ENI configuration file and confirm the modification.
cat /etc/network/interfaces
ifup eth1
Take ETH1 as an example.
Start ENIs.
i. Run the ifup [ENI name]
command to start the dhclient process and initiate a DHCP request.
ifup eth1
Set the metric parameter of the default route for each ENI in the route table as needed.
i. Set the metric parameter based on the gateway address of the subnet where the target ENI resides. You can query the gateway address of subnets in the VPC console or on the target KEC instance.
To query the gateway addresses of subnets on the target KEC instance, run the ip addr
command.
To query the gateway address of subnets in the VPC console, go to the Subnet page, as shown in the following figure.
ip -4 route add default via 10.1.2.1 dev eth1 metric 1001
Run the preceding commands to map the gateway address and metric parameter for ETH1. The mappings are as follows:
eth1: gw: 10.1.2.1 metric: 1001
ii. Check whether the values in the Gateway and Metric columns are the same as configured to verify whether the configuration is successful.
[root@ecshost~ ]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.253 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 10.1.2.1 0.0.0.0 UG 1001 0 0 eth1
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
Create route tables.
i. Create route tables.
ip -4 route add default via 10.1.2.1 dev eth1 table 1001
Note: We recommend that you keep the names of route tables the same as the metric values of the default routes for ENIs. In this example, 1001 is used.
ii. Check whether the route tables are created.
[root@ecshost~ ]# ip route list table 1001
default via 10.0.0.253 dev eth1
Create policy-based routes.
i. Create policy-based routes based on the private IP addresses of the ENI.
ip -4 rule add from 10.1.2.66 lookup 1001
ii. View the routing rules.
[root@ecshost~ ]# ip rule list
0: from all lookup local
32765: from 10.1.2.66 lookup 1001
32766: from all lookup main
32767: from all lookup default
Pure Mode