I have followed many articles available on serverfault but i am not able to manage outbound traffic through 2nd nics in ubuntu 16.04.
other than serverfault i followed - https://kindlund.wordpress.com/2007/11/19/configuring-multiple-default-routes-in-linux/
https://aws.amazon.com/premiumsupport/knowledge-center/ec2-ubuntu-secondary-network-interface/
https://msazure.club/configure-ubuntu-to-support-multiple-nics-in-azure/
My configuration - tried on AWS and Azure
Two ips
1st Nic - 172.31.29.87,
2nd nic - 172.31.17.222
Create route table
bash -c "echo '1 eth1route' >> /etc/iproute2/rt_tables"
Create eth1 nic file
/etc/network/interfaces.d/eth1.cfg
auto eth1
iface eth1 inet dhcp
post-up ip route add 172.31.16.0/20 dev eth1 src 172.31.17.222 table eth1route
post-up ip route add default via 172.31.16.1 dev eth1 table eth1route
post-up ip rule add from 172.31.17.222/32 table eth1-rt
post-up ip rule add to 172.31.17.222/32 table eth1-rt
then ifdown eth1 and ifup eth1
ip r
default via 172.31.16.1 dev eth0
172.31.16.0/20 dev eth0 proto kernel scope link src 172.31.29.87
172.31.16.0/20 dev eth1 proto kernel scope link src 172.31.17.222
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.31.16.1 0.0.0.0 UG 0 0 0 eth0
172.31.16.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0
172.31.16.0 0.0.0.0 255.255.240.0 U
0 0 0 eth1
ip rule show
0: from all lookup local
32765: from 72.31.17.222 lookup 1000
32766: from all lookup main
32767: from all lookup default
after all above configuration i can connect to both ips( incoming on both nics) but outgoing traffic only from eth0.
Could you please help me how can enable outbound traffic on both NICs ?