Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of configuring the elastic network card after attaching the elastic network card to the ECS instance

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to configure an elastic Nic after attaching it to an ECS instance. The editor thinks it is very practical, so I hope you can get something after reading this article.

Configure the elastic Nic of the ECS instance

If your instance uses the following images, you do not need to configure the elastic Nic (ENI) manually:

CentOS 7.364 bit

CentOS 6.8 64-bit

Windows Server 2016 data Center Edition 64-bit

Windows Server 2012 R2 data Center Edition 64-bit

If your instance does not use these images, but you want to attach an ENI to the instance, you need to configure the ENI manually. Taking the CentOS 7.264-bit system as an example, this paper introduces how to configure the elastic network card attached to the Linux instance so that it can be recognized by your system.

prerequisite

You have attached the ENI to the ECS instance.

Operation steps

You should follow these steps to configure the elastic Nic:

Use the DescribeNetworkInterfaces interface or on the ECS console to obtain the primary private IP address, mask address, default route, and MAC address for each Nic. The following are the steps on the ECS console:

Log in to the ECS Management console.

Find the primary private IP address, mask address, default route, and MAC address for each Nic. Examples are as follows:

Eth2 10.0.0.20/24 10.0.0.253 00:16:3e:12:e7:27eth3 10.0.0.21/24 10.0.0.253 00:16:3e:12:16:ec

Remotely log in to the ECS instance.

Generate the Nic configuration file: run cat / etc/sysconfig/network-scripts/ifcfg- [Nic name].

Description

You need to pay attention to the correspondence between the name of the network card and the MAC address.

The default route needs to be configured as DEFROUTE=no. Other distributions are similar, be careful not to configure the network card to cause ifup to change the default route of the current activity of the system.

Examples are as follows:

# cat / etc/sysconfig/network-scripts/ifcfg-eth2 DEVICE=eth2BOOTPROTO=dhcpONBOOT=yesTYPE=EthernetUSERCTL=yesPEERDNS=noIPV6INIT=noPERSISTENT_DHCLIENT=yesHWADDR=00:16:3e:12:e7:27DEFROUTE=no

Start the elastic Nic:

Run the command ifup [Network Card name] to start the dhclient process and initiate a DHCP request. Examples are as follows:

# ifup eth2# ifup eth3

After the request is returned, run the command ip a to check the network card IP allocation and pay attention to whether it matches the network card information provided on the console. Examples are as follows:

# ip a1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft forever2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000link/ether 00:16:3e:0e:16:21 brd ff:ff:ff:ff:ff:ffinet 10.0.0.19/24 brd 10.0.0.255 scope global dynamic eth0valid_ Lft 31506157sec preferred_lft 31506157sec3: eth2: mtu 1500 qdisc pfifo_fast state UP qlen 1000link/ether 00:16:3e:12:e7:27 brd ff:ff:ff:ff:ff:ffinet 10.0.0.20/24 brd 10.0.0.255 scope global dynamic eth2valid_lft 31525994sec preferred_lft 31525994sec4: eth3: mtu 1500 qdisc pfifo_fast state UP qlen 1000link/ether 00:16:3e:12:16:ec brd ff:ff:ff:ff:ff:ffinet 10.0.0.21/ 24 brd 10.0.0.255 scope global dynamic eth3valid_lft 31526009sec preferred_lft 31526009sec

Plan the default route metric value of each Nic in the routing table as needed. In this example, suppose you want to configure the metric values for eth2 and eth3 as follows.

Eth2: gw: 10.0.0.253 metric: 1001eth3: gw: 10.0.0.253 metric: 1002

Run the following command to plan the metric value.

# ip-4 route add default via 10.0.0.253 dev eth2 metric 100 percent ip-4 route add default via 10.0.0.253 dev eth3 metric 1002

Run the command route-n to check that the configuration is successful.

# route-nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 10.0.0.253 0.0.0.0 UG 00 0 eth00.0.0.0 10.0.0.253 0.0.0.0 UG 1001 00 eth20.0.0.0 10.0.0.253 0.0.0.0 UG 1002 00 eth310.0.0.0 0.0.0.0 255.255.0 U 00 eth010.0.0.0 0.0.0.0 255.255.255.0 U 00 0 eth210.0.0.0 0.0.0.0 255.255.255.0 U 00 0 eth3169.254.0.0 0.0.0.0 255.255.0.0 U 1002 00 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 1003 00 eth2169.254.0.0 0.0.0.0 255.255.0.0 U 1004 00 eth3

Create a routing table:

Description

It is recommended that you keep the routing table name consistent with the planned metric value.

Run the following command to create the routing table.

# ip-4 route add default via 10.0.0.253 dev eth2 table 100 percent ip-4 route add default via 10.0.0.253 dev eth3 table 1002

Run the following command to check that the routing table is created successfully.

# ip route list table 1001default via 10.0.0.253 dev eth2# ip route list table 1002default via 10.0.0.253 dev eth3

Configure policy routing.

Run the following command to create a policy route.

# ip-4 rule add from 10.0.0.20 lookup 100 rule add from ip-4 rule add from 10.0.0.21 lookup 1002

Run the command ip rule list to view the routing rules.

# ip rule list0: from all lookup local32764: from 10.0.0.21 lookup 100232765: from 10.0.0.20 lookup 100132766: from all lookup main32767: from all lookup default

At this point, you have completed the configuration of the ENI.

This is the way to configure the ENI after attaching the ENI to the ECS instance. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report