2

I want to add static Ip to ubunto server , but I can not . when I use " ip addr" : enter image description here

and there is no "network" service . how can I setup static IP ? I am beginner at linux, please guide me A-Z thanks in advance

1 Answer 1

4

You're probably trying to follow obsolete instructions.

ens160 is a new-style network device name, while eth0is old-style.

Also, modern Ubuntu uses netplan to configure network settings: you should create (or edit, if one already exists) a simple *.yaml file describing your desired network configuration in /etc/netplan/ directory, and then run sudo netplan apply to make it take effect.

For example, to set IP address 10.10.10.2 with netmask 255.255.255.0 (i.e. prefix /24), default gateway 10.10.10.1, DNS server 10.10.10.1 and 1.1.1.1 with default DNS search domains mydomain.example and otherdomain.example, you would write this into e.g. /etc/netplan/99_config.yaml:

network:
  version: 2
  renderer: networkd
  ethernets:
    ens160:
      addresses:
        - 10.10.10.2/24
      gateway4: 10.10.10.1
      nameservers:
          search: [mydomain.example, otherdomain.example]
          addresses: [10.10.10.1, 1.1.1.1]

Note that in YAML, correct indentation is an important part of the syntax.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .