How can I change /etc/network/interfaces with ip commands (persistent)?

jsterr

Well-Known Member
Jul 24, 2020
684
163
53
32
I would like to modify the file without using the web-ui and without sed commands, is there a way to do this with ip commands?
ip add etc. seems to be not persistent on reboot.
 
Hi,

is there a way to do this with ip commands?
to put it simply: no.

ip (from the iproute2) does not have anything to do with the persistent network configuration, done using ifupdown2. ip can only manipulate the running system.
If you really want to use these commands for some reason, you could create a cronjob/service that runs on boot and executes these commands directly or via a separate script file. But I would not recommend that.

Edit: Just to mention it for the sake of it: You can also create your own, separate file under /etc/network/interfaces.d/ and source it from /etc/network/interfaces, which e.g. the SDN integration does too. That way you would have control over the exact contents of the whole file.

IOW, what are you trying to achieve exactly simply by not using /etc/network/interfaces?
 
Last edited:
  • Like
Reactions: jsterr
We want to automate network creation via scripting so we dont need to use ui.
So like create config for corosync, webui, create a vmbr0, some bonds etc.
So no manual file editing via cli
 
Last edited:
What about pvesh and PVE API to change the config via CLI/script?
did not look into this, are there commands to add / modifiy network? will check
 
Thanks! How can I set the IP-Address, theres no "address" field.

root@pve:~# pvesh set /nodes/pve/network/eno1 --address 10.10.10.1
400 Parameter verification failed.
netmask: missing property - 'address' requires this property
type: property is missing and it is not optional

My first steps with the pve api, cool :)

EDIT: Got it:
root@pve:~# pvesh set /nodes/pve/network/vmbr1 --type bridge --address 10.10.10.10 --netmask 255.255.255.0
 
Last edited:
  • Like
Reactions: Dunuin

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!