3

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.

  • 1
    Your interface name is because of the "predicable interface names" change a few years ago. I think you should be able to check lease information with netplan ip leases ens160, however it is currently broken for dhcp. 18.04 changed to netplan, and all of this stuff is different. – Doug Smythies May 22 '18 at 15:03
  • Looks like I actually got some results with netplan ip leases ens160 so thanks for that. If I need to add additional DNS servers for this system to use, will that still be in /etc/network/interfaces or is there a different location for that in 18.04 LTS? And if I specify the servers that are already in there, but I place my own internal DNS ahead of that in the file, will it prefer the DHCP DNS entries, or the order of the servers I create in that file? – J. Dieckmann May 22 '18 at 16:07
  • well, /etc/network/interfaces is used by ifup and ifdown, which are no longer supposed to be used on 18.04. The yet to be published network updates to the Ubuntu Serverguide does not have a dhcp DNS override example. See if the DNS setting examples here for static can be applied to a dhcp yaml config file. – Doug Smythies May 22 '18 at 16:34
2

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;
}
  • Thank you for your reply! However, when I run ls -l /var/lib/NetworkManager all I see are the NetworkManager-intern.conf and NetworkManager.state files, nothing more. When I cat either, they don't give me anything more to go on. Is that unusual? – J. Dieckmann May 22 '18 at 16:03
  • i don't know. This stuff is all new to me. I did my answer based on an Ubuntu Desktop 18.04. I'll try my 18.04 Ubuntu server VM. – Doug Smythies May 22 '18 at 16:20
  • 1
    O.K. on my server VM, there is no /var/lib/NetworkManager at all. netplan ip leases ens3 does work, but doesn't say how much time is left on a lease, as far as i can tell. I do not know where the raw lease data is. – Doug Smythies May 22 '18 at 17:44
  • For me, netplan ip leases enp0s3 just throws an exception. – HDave Jul 6 '18 at 14:54
  • @DougSmythies thank you, I was wondering why my did new wlxxx interface always getting disconnected for every a few minutes, and was looking for the config file. Mine was /var/lib/NetworkManager/dhclient-wlx20e0170adf20.conf. – Ade Malsasa Akbar Oct 1 '18 at 14:31
2

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 Unbutu 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
  • 2
    Thanks Mike, spot on helpful. I don't use NetworkManager because I'm on a server. I had a syntax error in my dhcp.conf and didn't see that reported elsewhere. It showed up with journalctl beautifully. – jpa57 Jan 17 at 22:52

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.