Su Debian Jessie, per aggiungere una rotta statica (static route), ovvero inoltrare le richieste verso alcuni IP ad un gateway differente da quello di default, si può intervenire nel file /etc/network/interfaces.
Se ad esempio la configurazione è:allow-hotplug eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 10.109.70.60
netmask 255.255.255.0
network 10.109.70.0
dns-nameservers 10.109.70.100 10.109.70.200
brodcast 10.109.70.255
auto eth1
allow-hotplug eth1
iface eth1 inet static
address 34.23.14.132
netmask 255.255.255.248
network 34.23.14.128
gateway 34.23.14.129
broadcast 34.23.14.135
dns-nameservers 8.8.8.8
Si vede che il gateway di default è 34.23.14.129 e quindi quello che non è diretto verso la rete 10.109.70.x andrà sul gateway di default.
Se si vuole che qualsiasi richiesta verso la rete 10.x.x.x.x passi per il gateway 10.109.70.1 e quello diretto verso la rete 10.109.67.x passi per il gateway 10.109.70.249, basterà aggiungere sotto la definizione della relativa eth, le direttive post-up.
Avremo quindi una cosa del genere:
allow-hotplug eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 10.109.70.60
netmask 255.255.255.0
network 10.109.70.0
dns-nameservers 10.109.70.100 10.109.70.200
brodcast 10.109.70.255
post-up /sbin/route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.109.70.1 dev eth0
# oppure, nel vecchio formato
post-up /sbin/route add -net 10.109.67.0 netmask 255.255.255.0 gw 10.109.70.249 dev eth0
auto eth1
allow-hotplug eth1
iface eth1 inet static
address 34.23.14.132
netmask 255.255.255.248
network 34.23.14.128
gateway 34.23.14.129
broadcast 34.23.14.135
dns-nameservers 8.8.8.8
enjoy!
Ti interessa acquistare un dominio a prezzi ultraconvenienti? clicca qui
Se hai trovato utili le informazioni su questo blog,
Fai una donazione!
Clicca sul bottone qui sotto o almeno clicca sul banner pubblicitario 🙂
Commenta