The network configuration file has moved. Find out where to define settings for the network interfaces.
- [Instructor] Normally, when we set up a server we specify the network parameters during set up. Otherwise, we wouldn't be able to download updates, host services, or even connect to it once it's set up. It's important for a server to have a static IP address. We want the IP address of the server to be the same all the time so we can reliably connect to it. And if you're hosting services like DNS, it's critical for the address to stay the same. Otherwise other services and hosts won't be able to find your server. There's two ways of making sure that a server gets the same address time and again.
We can either specify it manually like we did during the set up of this course or we can take the network interfaces MAC address. The hexadecimal number that nearly uniquely identifies a network interface and tell our router or DHCP server to always assign the same address to that interface. Personally, this is how I prefer to set addresses on my network. But on cloud services you don't always have that flexibility. There are also times where we need to change the static address of a server in case the network configuration changes or the server simply needs to be moved.
Starting with version 17.10 Ubuntu uses software called Netplan to manage the network connections. While in earlier versions, we'd make changes to the networking configuration in ETC network interfaces, now we make changes to files in the ETC netplan folder. Depending on your system, the name of the file where we'll set the configurations may be different. Here in my system it's called 50-cloud-init.yaml.
I'll open it up. This file and other files for Netplan and for the broader cloud-init configurations are written in yaml, which stands for, yet another markup language. If you'd like to learn more about yaml we have videos that describe the structure and syntax. One of the nice things about yaml is that it makes sense if you look at it for a little bit. So, let's dive in. Here at the top level we have network. And inside that ethernets. You can define more than one ethernet interface in this block. That's why it's called ethernets. There's also options for wifi and other media.
My interface name enp0s3, is inside the ethernets block. And that has addresses. In this case, just one. But again, you can set more than one should your set up require it. Gateway4 is the IPV4 default gateway or router. And nameservers are the DNS servers the system will use. I can see that my static address is set here. And if I wanted to I could change it. Sometimes, servers need additional network interfaces like when they're in a DMZ or for other more advanced configurations.
And those can be defined here as well. I like my set up right now and I don't need to make any changes. If I did, I would save the file and then run netplan apply. I wanted to make sure to point out where the network settings have moved to. If you'd like to explore Netplan more, be sure to check out the man page for it.
- Installing Ubuntu Server
- Configuring remote access with SSH
- Configuring the firewall
- Configuring networking with Netplan
- Managing users
- Configuring for scale
- Securing an HTTP server with TLS
- Hosting an application
- Setting up a forwarding DNS server
- Sending email with Postfix