Ubuntu 22.04
Sponsored Link

Initial Settings : Network Settings2022/04/25

 
Change to static IP addres if you use Ubuntu as a server.
[1] The interface name [enp1s0] is different on each environment, replace it to your own one.
# rename to disable default setting

root@localhost:~#
mv /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.org

root@localhost:~#
vi /etc/netplan/01-netcfg.yaml
# create new

network:
  ethernets:
    # interface name
    enp1s0:
      dhcp4: false
      # IP address/subnet mask
      addresses: [10.0.0.30/24]
      # default gateway
      # [metric] : set priority (specify it if multiple NICs are set)
      # lower value is higher priority
      routes:
        - to: default
          via: 10.0.0.1
          metric: 100
      nameservers:
        # name server to bind
        addresses: [10.0.0.10,10.0.0.11]
        # DNS search base
        search: [srv.world,server.education]
      dhcp6: false
  version: 2

# apply changes

root@localhost:~#
netplan apply
root@localhost:~#
ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:ab:95:2c brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.30/24 brd 10.0.0.255 scope global enp1s0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:feab:952c/64 scope link
       valid_lft forever preferred_lft forever
[2] If you don't need IPv6, it's possible to disable it like follows.
root@localhost:~#
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf

root@localhost:~#
sysctl -p

net.ipv6.conf.all.disable_ipv6 = 1
root@localhost:~#
ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:ab:95:2c brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.30/24 brd 10.0.0.255 scope global enp1s0
       valid_lft forever preferred_lft forever
Matched Content