Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:debian:static-ip-address-route [2024/12/27 14:56] – removed - external edit (Unknown date) 127.0.0.1linux:debian:static-ip-address-route [2024/12/27 22:22] (current) – [Static route] Zyzonix
Line 1: Line 1:
 +===== Set Static IP Address / Static route =====
  
 +==== ifupdown2 ====
 +
 +First install the ''ifupdown2'' package:
 +<code bash>sudo apt install ifupdown2</code>
 +It will generate the file ''/etc/network/interfaces'' if it doesn't exist.
 +
 +Then edit ''/etc/network/interfaces'' and add the following:
 +<code bash>
 +auto eth0
 +iface eth0 inet static
 +        address 172.16.1.20/24
 +        gateway 172.16.1.1 
 +        nameserver 172.16.1.1
 +</code>
 +Adjust the interface name, here ''eth0'', to your configuration.
 +
 +Finally enable the interface by running:
 +<code bash>ifup eth0</code>
 +
 +//Sourced from [[https://wiki.debian.org/NetworkConfiguration|wiki.debian.org/NetworkConfiguration]]//
 +
 +==== Static route ====
 +To show static routes:
 +<code bash>ip route</code>
 +
 +To add a static route run:
 +<code bash>ip route add <network>/<netmask> via <gateway></code>
 +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'':
 +
 +<code bash>
 +up route add -net <network>/<netmask> gw <gateway-ip>
 +</code>
 +Example:
 +''up route add -net 10.205.0.0/24 gw 10.0.0.3''
 +
 +//→ tested with a Proxmox CT//
 +
 +
 +//Sourced from [[https://forum.proxmox.com/threads/lxc-container-and-static-route.43411/|forum.proxmox.com  LXC Container and static route]]//