Set Static IP Address / Static route

ifupdown2

First install the ifupdown2 package:

sudo apt install ifupdown2

It will generate the file /etc/network/interfaces if it doesn't exist.

Then edit /etc/network/interfaces and add the following:

auto eth0 iface eth0 inet static address 172.16.1.20/24 gateway 172.16.1.1 nameserver 172.16.1.1

Adjust the interface name, here eth0, to your configuration.

Finally enable the interface by running:

ifup eth0

Sourced from wiki.debian.org/NetworkConfiguration

Static route

To show static routes:

ip route

To add a static route run:

ip route add <network>/<netmask> via <gateway>

Example: ip route add 10.205.0.0/24 gw 10.0.0.3

Static route for LXC

To add a persistent static route for a Linux Container add the following line to the interface that should automatically add the route in /etc/network/interfaces:

up route add -net <network>/<netmask> gw <gateway-ip>

Example: up route add -net 10.205.0.0/24 gw 10.0.0.3

→ tested with a Proxmox CT

Sourced from forum.proxmox.com LXC Container and static route