

# Appendix: Configuring Linux to Recognize Ethernet Devices for Multiple Network Interfaces
<a name="hana-ops-appendix"></a>

Follow these steps to configure the Linux operating system to recognize and name the Ethernet devices associated with the new elastic network interfaces created for logical network separation, which were discussed [earlier in this paper](hana-ops-networking.md#hana-ops-config).

1. Use SSH to connect to your SAP HANA host as `ec2-user`, and `sudo` to root.

1. Remove the existing `udev` rule; for example:

   ```
   hanamaster:# rm -f /etc/udev/rules.d/70-persistent-net.rules
   ```

1. Create a new `udev` rule that writes rules based on MAC address rather than other device attributes. This will ensure that on reboot, `eth0` is still `eth0`, `eth1` is `eth1`, and so on. For example:

   ```
   hanamaster:# cat <<EOF >/etc/udev/rules.d/75-persistent-net- generator.rules
   # Copyright (C) 2012 Amazon.com, Inc. or its affiliates. # All Rights Reserved.
   #
   # Licensed under the Apache License, Version 2.0 (the "License").
   # You may not use this file except in compliance with the License.
   # A copy of the License is located at #
   #	    https://aws.amazon.com/apache2.0/ #
   # or in the "license" file accompanying this file. This file is # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
   # OF ANY KIND, either express or implied. See the License for the
   # specific language governing permissions and limitations under the
   # License.
   # these rules generate rules for persistent network device naming
   SUBSYSTEM!="net", GOTO="persistent_net_generator_end" KERNEL!="eth*", GOTO="persistent_net_generator_end" ACTION!="add", GOTO="persistent_net_generator_end" NAME=="?*", GOTO="persistent_net_generator_end"
   
   # do not create rule for eth0
   ENV{INTERFACE}=="eth0", GOTO="persistent_net_generator_end" # read MAC address
   ENV{MATCHADDR}="\$attr{address}" # do not use empty address
   ENV{MATCHADDR}=="00:00:00:00:00:00",
   GOTO="persistent_net_generator_end"
   # discard any interface name not generated by our rules ENV{INTERFACE_NAME}=="?*", ENV{INTERFACE_NAME}=""
   # default comment
   ENV{COMMENT}="elastic network interface" # write rule IMPORT{program}="write_net_rules"
   # rename interface if needed ENV{INTERFACE_NEW}=="?*", NAME="\$env{INTERFACE_NEW}"
   LABEL="persistent_net_generator_end" EOF
   ```

1. Ensure proper interface properties. For example:

   ```
   hanamaster:# cd /etc/sysconfig/network/
   
   hanamaster:# cat <<EOF >/etc/sysconfig/network/ifcfg-ethN
   BOOTPROTO='dhcp4'
   MTU="9000"
   REMOTE_IPADDR=''
   STARTMODE='onboot'
   LINK_REQUIRED=no
   LINK_READY_WAIT=5
   EOF
   ```

1. Ensure that you can accommodate up to seven more Ethernet devices or network interaces, and restart `wicked`. For example:

   ```
   hanamaster:# for dev in eth{1..7} ; do
   ln -s -f ifcfg-ethN /etc/sysconfig/network/ifcfg-${dev} done
   
   hanamaster:# systemctl restart wicked
   ```

1. Create and attach a new network interface to the instance.

1. Reboot.

1. Modify `/etc/iproute2/rt_tables`.
**Important**  
Repeat the following for each ENI that you attach to your instance.

   For example:

   ```
   hanamaster:# cd /etc/iproute2
   hanamaster:/etc/iproute2 # echo "2 eth1_rt" >> rt_tables
   hanamaster:/etc/iproute2 # ip route add default via 172.16.1.122 dev eth1 table eth1_rt
   
   hanamaster:/etc/iproute2 # ip rule
   0:	from all lookup local
   32766:	from all lookup main
   32767:	from all lookup default
   
   hanamaster:/etc/iproute2 # ip rule add from <ENI IP Address>
   lookup eth1_rt prio 1000
   
   hanamaster:/etc/iproute2 # ip rule 0:	from all lookup local
   1000:	from <ENI IP address> lookup eth1_rt
   32766:	from all lookup main
   32767:	from all lookup default
   ```