问题
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 --
- If my vpc cidr is 10.0.0.0/26 , is the default vpc gateway 10.0.0.1 ?
- What is a subnet netmask ? Is it the IPV4 CIDR of the subnet in which the ENI is launched ?
- 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