Skip to content

Instantly share code, notes, and snippets.

@tsuchm
Created March 12, 2020 00:46
Show Gist options
  • Save tsuchm/96269d54e521c68c276489f345ab9d53 to your computer and use it in GitHub Desktop.
Save tsuchm/96269d54e521c68c276489f345ab9d53 to your computer and use it in GitHub Desktop.
An example of /etc/network/interfaces for a dual-homed host
auto lo
iface lo inet loopback
# The 1st network of this host is 192.0.2.0/24.
# This host mainly uses the 1st network to communicate the Internet.
allow-hotplug eth0
iface eth0 inet static
address 192.0.2.30
netmask 255.255.255.0
network 192.0.2.0
broadcast 192.0.2.255
gateway 192.0.2.1
dns-nameservers 192.0.2.11 192.0.2.12
dns-search example.net
# The 2nd network of this host is 198.51.100.0/24.
# Although this host does not directly connect to the 3rd network, 203.0.113.0/24,
# the router of the 2nd network knows the routing to the 3rd network.
# The IP address of the router of the 2nd network is 198.51.100.1.
allow-hotplug eth1
iface eth1 inet static
address 198.51.100.50
netmask 255.255.255.0
network 198.51.100.0
broadcast 198.51.100.255
post-up /sbin/ip route add 203.0.113.0/24 via 198.51.100.1 src 198.51.100.50
pre-down /sbin/ip route del 203.0.113.0/24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment