Question

How to configure internet access to ubuntu server?

  • 23 August 2022
  • 3 replies
  • 1814 views

Badge +2
  • Do Gooder (Employee)
  • 4 replies

My remote cloud customer would like to configure not dhcp address but the static ip address to Ubuntu Linux box

How this can be done? 

Also that connection should recognize all the names like www.google.fi when you use pinging only a name

Br

Simo Kallio

 


3 replies

Userlevel 7
Badge +21

Hi @SimoK ,

Name resolution will be done by the DNS server you setup in your static IP config.
 

To set a static IP, you would need delete all existing yaml files except for the 01-netcfg.yaml and make your changes in there. 

Steps are below,
1.    cd /etc/netplan
2.    Delete all XX-netcfg.yaml files except 01-netcfg.yaml
3.    vi /etc/netplan/01-netcfg.yaml
4.    Copy the sample below.
5.    Update for correct IP and Gateway address
6.    Save
7.    Run “netplan apply”


Sample:
network:
  version: 2
  ethernets:
    eth0:
      dhcp4: false
      addresses:
      - <Server ADDR>/24
      gateway4: <Gateway ADDR for VLAN>
      nameservers:
       addresses:
       - <DNS IP Addr>
       search:
       - <Search Domain>

 

Cheers

Badge +2

What this means? No matter what ever DNS server address i give it says the same invalid YAML error


root@ifstestcloud01:/etc/netplan# nano 01-netcfg.yaml
root@ifstestcloud01:/etc/netplan# sudo netplan apply
/etc/netplan/01-netcfg.yaml:10:1: Invalid YAML: tabs are not allowed for indent:
        addresses: [10.20.10.2, 10.20.10.11]
^
root@ifstestcloud01:/etc/netplan# nano 01-netcfg.yaml
root@ifstestcloud01:/etc/netplan# sudo netplan apply
/etc/netplan/01-netcfg.yaml:10:1: Invalid YAML: tabs are not allowed for indent:
        addresses: [10.20.10.11]
^
root@ifstestcloud01:/etc/netplan# ^C
root@ifstestcloud01:/etc/netplan# nano 01-netcfg.yaml
root@ifstestcloud01:/etc/netplan# sudo netplan apply
/etc/netplan/01-netcfg.yaml:10:1: Invalid YAML: tabs are not allowed for indent:
        addresses: [8.8.8.8. 8.8.4.4]
^
root@ifstestcloud01:/etc/netplan# cat 01-netcfg.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses: [10.20.14.29/24]
      gateway4: 10.20.14.1
      nameservers:
        addresses: [8.8.8.8. 8.8.4.4]
        search: [insta.fi]
 

Badge +2

Hi

There was some trash in the 01-netcfg.yaml file. I open the vi editor and did go all the lines true one by one. Then apply command worked

br

Simo Kallio

Reply