Skip to content

Instantly share code, notes, and snippets.

@guoguojin
Last active July 2, 2024 20:00
Show Gist options
  • Save guoguojin/c88c5bdc8a9f4467afd99a3031e3acb3 to your computer and use it in GitHub Desktop.
Save guoguojin/c88c5bdc8a9f4467afd99a3031e3acb3 to your computer and use it in GitHub Desktop.
Ubuntu server 20.04 static IP configuration
# /etc/netplan/00-installer-config.yaml
network:
ethernets:
enp0s3: # This is the device name and may be different on each machine
dhcp4: false
addresses: [192.168.1.80/24] # The static IP address to use for the device
gateway4: 192.168.1.254
nameservers:
addresses: [8.8.8.8,8.8.4.4,1.1.1.1,192.168.1.254] # array of DNS nameservers
version: 2
@ArmanAvag
Copy link

sudo netplan apply

** (generate:2135): WARNING **: 12:13:27.061: gateway4 has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.
WARNING:root:Cannot call Open vSwitch: ovsdb-server.service is not running.

** (process:2133): WARNING **: 12:13:27.326: gateway4 has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

** (process:2133): WARNING **: 12:13:27.412: gateway4 has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

** (process:2133): WARNING **: 12:13:27.412: gateway4 has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

@Crzek
Copy link

Crzek commented Jul 2, 2024

network:
  version: 2
    ethernets:
      enp0s3:  # This is the device name and may be different on each machine
        dhcp4: false
        dhcp6: false
        addresses: 
          - 192.168.1.80/24    # The static IP address to use for the device
        routes:
          - to: default
           via: 192.168.1.254
        nameservers:
                addresses: [8.8.8.8,8.8.4.4,1.1.1.1,192.168.1.254] # array of DNS nameservers

Hello @ArmanAvag check the indentation. you can find more information on official ubunto Server : https://ubuntu.com/server/docs/configuring-networks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment