Manually Configuring secondary Elastic network interface on Red hat ami- 7.5

╄→尐↘猪︶ㄣ 提交于 2019-12-25 02:16:13

问题


I am really having tough time manually configuring ENI on RHEL instance. I am following the following blogpost.

https://www.internetstaff.com/multiple-ec2-network-interfaces-on-red-hat-centos-7/#comment-11600

Based upon the above blog ,can someone please help me to understand --

  1. If my vpc cidr is 10.0.0.0/26 , is the default vpc gateway 10.0.0.1 ?
  2. What is a subnet netmask ? Is it the IPV4 CIDR of the subnet in which the ENI is launched ?
  3. Do i have to mention IPV4 CIDR of the subnet in which the ENI is launched in the "from" of rule-ethX ?

If there is any other way to do it more efficiently or if you know of any other online source , please let me know.


回答1:


Here's one way to manually configure a Red Hat AMI:

/etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
BOOTPROTO=dhcp
ONBOOT=yes
IPADDR=10.xx.0.xx
NETMASK=255.255.255.xxx
TYPE=Ethernet
USERCTL=yes
PEERDNS=yes
IPV6INIT=no
PERSISTENT_DHCLIENT=yes
DEFROUTE=no
EC2SYNC=yes

Add these routes. Here 10.0.0.X is the default gateway. Most times, it's the first IP of your EMI's subnet:

ip route add default via 10.0.0.x dev eth0 tab 1
ip route add default via 10.0.0.x dev eth1 tab 2

Add these rules. This uses the ENI's IP:

ip rule add from 10.xx.0.xx/32 tab 1 priority 500
ip rule add from 10.xx.0.xx/32 tab 2 priority 600

Run ip rule show. You should get something like this:

# ip rule show
0: from all lookup local
500: from 10.xx.0.xx lookup 1
600: from 10.xx.0.xx lookup 2
32766: from all lookup main
32767: from all lookup default

Note that these routes and rules will not persist across reboots.



来源:https://stackoverflow.com/questions/52044907/manually-configuring-secondary-elastic-network-interface-on-red-hat-ami-7-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!