The method of configuring static ip in Ubuntu 18.04.2 LTS is different from its previous variants. Previously it was to configure in /etc/network/interfaces file, however in Ubuntu 18.04.2 LTS, it is setup in /etc/netplan/50-cloud-init.yaml file.
1 2 |
root@ubuntu:/etc/netplan# ls 50-cloud-init.yaml |
Content of this file is
1 2 3 4 5 6 7 8 9 10 11 12 |
root@ubuntu:/etc/netplan# cat 50-cloud-init.yaml # This file is generated from information provided by # the datasource. Changes to it will not persist across an instance. # To disable cloud-init's network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: ens160: addresses: [] dhcp4: true version: 2 |
I have edited this file like below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
root@ubuntu:/etc/netplan# cat 50-cloud-init.yaml # This file is generated from information provided by # the datasource. Changes to it will not persist across an instance. # To disable cloud-init's network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: ens160: addresses: [10.10.23.202/24] gateway2: 10.10.23.1 dhcp4: no nameservers: addresses: [8.8.8.8,8.8.4.4] version: 2 |
And apply configuration
1 |
sudo netplan apply |
Comment Policy:
Your words are your own, so be nice and helpful if you can. Please, only use your real name, not your business name or keywords. Using business name or keywords instead of your real name will lead to the comment being deleted. Anonymous commenting is not allowed either. Limit the amount of links submitted in your comment. We accept clean XHTML in comments, but don't overdo it please.