Score:1

How to make network interface changes permanent?

cn flag

I have this "script" on every startup(cron)[That is not working cause i have to login and its a headless server so i dont really log in to it.], how do i make these changes permanent?

#!/bin/bash
sudo ip addr flush dev enp2s0
sudo ip addr add 192.168.100.5/24 dev enp2s0
sudo ip link set enp2s0 up
sudo ip route add default via 192.168.100.1

I have created this but i does not work:

server@serverlaptop:~$ cat /etc/network/interfaces 
auto enp2s0
    iface enp2s0 inet dhcp  
Pilot6 avatar
cn flag
What is the OS? For Ubuntu set it by netplan.
cn flag
Ubuntu server 20.04.05 lts
Pilot6 avatar
cn flag
https://netplan.io/
cn flag
Thank you! It is what i was looking for.
Score:5
cn flag

The /etc/network/interfaces mechanism is deprecated in all recent Ubuntu versions. Networking on servers is configured in netplan. I suggest that you delete the faulty file.

You will have a yaml file in /etc/netplan. I suggest that you amend it to:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp2s0:
      addresses:
        - 192.168.100.5/24
      nameservers:
        addresses: [192.168.100.1]
      routes: 
        - to: default
          via: 192.168.100.1

After making this change, follow with:

sudo netplan generate
sudo netplan apply

You should be all set.

cn flag
Thank you! It solved my problem.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.