Find DHCP Lease & DNS Info In 18.04 LTS

I'm relatively new to Linux and Ubuntu, so please bear with me. I'm setting up a Ubuntu 18.04 LTS VM that will act as a mail relay via postfix. I have that installed, and have configured those settings to match the old existing relay server that was set up years ago, at least as much as I can determine. My issues is, the connection from this new relay server is timing out, which I can see in the /var/log/mail.log file. This server is set up to obtain an IP via DHCP because of the way our network is set up. I work for a group that is affiliated with a university, but we're not directly part of the IT staff, so my group has their own IT department, of which I'm a part. In order to get anything on the University's network, we have to register the MAC address of the device, then once that registration is complete with the uni, they assign an IP address and the device gets a lease.

What I can't figure out is two-fold: first, how to look up what my lease information is. Second, in conjunction with that, how I can see what DNS servers are included with that lease. I've used a number of commands to try and look that information up, or glean it from Ubuntu in some way, but to no avail. I also have the Ubuntu desktop installed, as that was something the previous mail relay server had, just so I could be as 1:1 with my setup as possible, and I can't find any info via the Network section of the system settings either. I looked through http://manpages.ubuntu.com/manpages/bionic/en/man1/ for anything with 'dhcp' or 'dns' in the list, but couldn't seem to find a command I could throw at it to determine the answer to my question.

The other curious thing is, my network interface is labeled 'ens160' instead of 'eth0', which I thought was odd. In any event, I'm trying to determine what my DHCP and DNS info is, because I can ping some hostnames inside and outside the network, but I might be missing some internal DNS server entries, in which case, I'll need to know how to add those, but I also want to make sure I can clearly see what my setup is. Unfortunately, ifconfig doesn't return much more than the IP, MAC, and interface name info. Anyway, sorry for the novella, but I'm just trying to figure out how to see the full networking details on my new server, so I can better troubleshoot the issue at hand.


This question has an accepted answer, but I wanted to add some details that stumped me and that might help others when applying this info to Ubuntu 18.04 Server.

While 18.04 desktop (and perhaps some other offshoots) use NetworkManager as covered in the other answer, the server release uses a mix of systemd-networkd and dhclient.

(netplan is a higher-level system, and is what calls either NetworkManager or systemd - so it is relevant regardless of which type of Ubuntu your running)

As noted in a different SE question (https://superuser.com/q/1338510/312285) you can pull a high level log of DHCP activity by using a systemd dumping tool called, journalctl.

On my system a journalctl | grep -Ei 'dhcp' gives output that looks like this:

[...]
Jan 10 23:26:35 ip-10-215-153-240 dhclient[576]: Internet Systems Consortium DHCP Client 4.3.5
Jan 10 23:26:35 ip-10-215-153-240 dhclient[576]: For info, please visit https://www.isc.org/software/dhcp/
Jan 10 23:26:35 ip-10-215-153-240 dhclient[576]: DHCPDISCOVER on ens5 to 255.255.255.255 port 67 interval 3 (xid=0x13d08672)
Jan 10 23:26:35 ip-10-215-153-240 dhclient[576]: DHCPREQUEST of 10.215.153.240 on ens5 to 255.255.255.255 port 67 (xid=0x7286d013)
Jan 10 23:26:35 ip-10-215-153-240 dhclient[576]: DHCPOFFER of 10.215.153.240 from 10.215.153.193
Jan 10 23:26:35 ip-10-215-153-240 dhclient[576]: DHCPACK of 10.215.153.240 from 10.215.153.193
Jan 10 23:26:37 ip-10-215-153-240 systemd-networkd[594]: ens5: DHCPv4 address 10.215.153.240/26 via 10.215.153.193
[...]

Then, as noted by doug-smythies, a netplan ip leases can be run on the interfaces listed to get the lower level data.

So for above, a netplan ip leases ens5 gives:

# This is private data. Do not parse.
ADDRESS=10.215.153.240
NETMASK=255.255.255.192
ROUTER=10.215.153.193
SERVER_ADDRESS=10.215.153.193
BROADCAST=10.215.153.255
MTU=9001
T1=1800
T2=3150
LIFETIME=3600
DNS=10.215.152.2
DOMAINNAME=ec2.internal
HOSTNAME=ip-10-215-153-240
CLIENTID=xxxxx

18.04 has changed to use netplan, and many network related things are different than previous releases.

You should be able to manually find your dhcp lease information, which should also include your DNS information, under /var/lib/NetworkManager. Example for a computer with an interface name of ens5:

$ ls -l /var/lib/NetworkManager
total 24
-rw-r--r-- 1 root root  918 May 22 07:41 dhclient-e1b925e7-2196-3d00-9556-64ba0a6834f1-ens5.lease
-rw-r--r-- 1 root root 2322 May 22 07:41 dhclient-ens5.conf
-rw-r--r-- 1 root root  939 Apr 20 11:57 NetworkManager-intern.conf
-rw-r--r-- 1 root root   68 May 22 07:40 NetworkManager.state
-rw------- 1 root root   32 Apr 20 11:57 secret_key
-rw-r--r-- 1 root root   61 May 22 07:41 timestamps

$ cat /var/lib/NetworkManager/dhclient-e1b925e7-2196-3d00-9556-64ba0a6834f1-ens5.lease
lease {
  interface "ens5";
  fixed-address 192.168.111.31;
  option subnet-mask 255.255.255.0;
  option dhcp-lease-time 86400;
  option routers 192.168.111.1;
  option dhcp-message-type 5;
  option dhcp-server-identifier 192.168.111.1;
  option domain-name-servers 192.168.111.1;
  option broadcast-address 192.168.111.255;
  option domain-name "smythies.com";
  renew 3 2018/05/23 00:34:42;
  rebind 3 2018/05/23 11:29:07;
  expire 3 2018/05/23 14:29:07;
}
lease {
  interface "ens5";
  fixed-address 192.168.111.31;
  option subnet-mask 255.255.255.0;
  option routers 192.168.111.1;
  option dhcp-lease-time 85668;
  option dhcp-message-type 5;
  option domain-name-servers 192.168.111.1;
  option dhcp-server-identifier 192.168.111.1;
  option broadcast-address 192.168.111.255;
  option domain-name "smythies.com";
  renew 3 2018/05/23 01:43:25;
  rebind 3 2018/05/23 11:30:37;
  expire 3 2018/05/23 14:29:06;
}