Skip to content

Instantly share code, notes, and snippets.

@garronej
Last active February 20, 2019 17:17
Show Gist options
  • Save garronej/ff2c5444d00251315125f436beed65ce to your computer and use it in GitHub Desktop.
Save garronej/ff2c5444d00251315125f436beed65ce to your computer and use it in GitHub Desktop.
Setup EC2 instance with two network interfaces.
>>> See comments
src: https://unix.stackexchange.com/questions/4420/reply-on-same-interface-as-incoming
Detailed infos: http://irp.nain-t.net/doku.php/100iproute:020_iproute2
@garronej
Copy link
Author

garronej commented Mar 3, 2018

For deploy semasim !

On instances:

/etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto eth0
iface eth0 inet dhcp
#172.31.21.X - access only via VPN

  #Add route to the VPN gateway
  up ip route add 10.8.0.0/24 via 172.31.19.1 dev eth0

iface eth1 inet dhcp
  #172.31.20.X - interface dedicated to running semasim instances
  #This interface cannot access internet.

  # We route all trafic originated from this interface to the
  # load balancer except for local trafic that we route normaly.
  # [/etc/iproute2/rt_ables ] 200 t_eth1
  up ip rule add from 172.31.20.0/24 table t_eth1
  up ip route add default via 172.31.19.1 dev eth1 table t_eth1
  up ip route add 172.31.16.0/20 dev eth1  proto kernel  scope link  table t_eth1

iface eth2 inet dhcp
iface eth3 inet dhcp
iface eth4 inet dhcp
iface eth5 inet dhcp
iface eth6 inet dhcp
iface eth7 inet dhcp

/etc/iproute2/rt_tables

#
# reserved values
#
255     local
254     main
253     default
0       unspec
#
# local
#
#1      inr.ruhep
#
200 t_eth1

@garronej
Copy link
Author

garronej commented Mar 4, 2018

Pour savoir dans quelle ordre sont évaluer les tables on fait ip rule list le nombre gauche représente la prio, évaluer dans l'ordre croissant.
Pour changer la priorité d'une table quand on fait ip rule add from ... table .... prio XXXX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment