Skip to content

Setting the IP address in Ubuntu

How to configure DHCP

Attention

Active DHCP services on external Ethernet interfaces are forbidden by the Terms and Conditions of services and the use of the site.

To get IP via DHCP, you need to create a new configuration file:

vi /etc/netplan/02-networkd.yaml

And edit the following way:

network:
   version: 2
   renderer: networkd
   ethernets:
       enp3s0:
           dhcp4: yes

All other parameters will be automatically caught up via DHCP.

To configure DNS for this interface manually, you must point additional parameters:

network:
   version: 2
   renderer: networkd
   ethernets:
       enp3s0:
           dhcp4: yes
           nameservers:
           addresses:
                - 8.8.8.8
                - 8.8.4.4

How to set up a static IP address

To set up a static IP address, you need to point the gateway for Internet access and DNS servers in the configuration file:

network:
   version: 2
   renderer: networkd
   ethernets:
       enp3s0:
           dhcp4: no
           addresses: [ 192.168.1.10/24 ]
           gateway4: 192.168.1.1
           nameservers:
           addresses: [ 8.8.8.8, 8.8.4.4 ]

Check and use of configuration

`bash sudo netplan apply