diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am
index 2aa4c4e..55db331 100644
--- a/libnm-util/Makefile.am
+++ b/libnm-util/Makefile.am
@@ -59,7 +59,7 @@ libnm_util_la_SOURCES=			\
 libnm_util_la_LIBADD = $(GLIB_LIBS) $(DBUS_LIBS) $(UUID_LIBS)
 
 libnm_util_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libnm-util.ver \
-	-version-info "2:0:1"
+	-version-info "3:0:2"
 
 if WITH_GNUTLS
 libnm_util_la_SOURCES += crypto_gnutls.c
diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver
index 17ce174..9614724 100644
--- a/libnm-util/libnm-util.ver
+++ b/libnm-util/libnm-util.ver
@@ -345,6 +345,7 @@ global:
 	nm_utils_ip4_addresses_to_gvalue;
 	nm_utils_ip4_netmask_to_prefix;
 	nm_utils_ip4_prefix_to_netmask;
+	nm_utils_ip4_get_default_netmask;
 	nm_utils_ip4_routes_from_gvalue;
 	nm_utils_ip4_routes_to_gvalue;
 	nm_utils_ip6_addresses_from_gvalue;
diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c
index 8ec872d..42fd749 100644
--- a/libnm-util/nm-utils.c
+++ b/libnm-util/nm-utils.c
@@ -21,7 +21,7 @@
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2005 - 2009 Red Hat, Inc.
+ * (C) Copyright 2005 - 2010 Red Hat, Inc.
  */
 
 #include <string.h>
@@ -1209,6 +1209,33 @@ nm_utils_ip4_prefix_to_netmask (guint32 prefix)
 }
 
 
+/**
+ * nm_utils_ip4_get_default_netmask:
+ * @ip: an IPv4 address (in network byte order)
+ *
+ * When the Internet was originally set up, various ranges of IP addresses were
+ * segmented into three network classes: A, B, and C.  This function will return
+ * a netmask that is associated with the IP address specified defining where it
+ * falls in the predefined classes.
+ *
+ * Returns: the default class netmask for the IP
+ **/
+/* The function is originally from ipcalc.c of Red Hat's initscripts. */
+guint32
+nm_utils_ip4_get_default_netmask (guint32 ip)
+{
+	guint32 mask;
+
+	if (((ntohl (ip) & 0xFF000000) >> 24) <= 127)
+		mask = htonl (0xFF000000);  /* Class A - 255.0.0.0 */
+	else if (((ntohl (ip) & 0xFF000000) >> 24) <= 191)
+		mask = htonl (0xFFFF0000);  /* Class B - 255.255.0.0 */
+	else
+		mask = htonl (0xFFFFFF00);  /* Class C - 255.255.255.0 */
+
+	return mask;
+}
+
 GSList *
 nm_utils_ip6_addresses_from_gvalue (const GValue *value)
 {
diff --git a/libnm-util/nm-utils.h b/libnm-util/nm-utils.h
index bbb304f..ddc0306 100644
--- a/libnm-util/nm-utils.h
+++ b/libnm-util/nm-utils.h
@@ -20,7 +20,7 @@
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2005 - 2008 Red Hat, Inc.
+ * (C) Copyright 2005 - 2010 Red Hat, Inc.
  */
 
 #ifndef NM_UTILS_H
@@ -192,6 +192,7 @@ void nm_utils_ip4_routes_to_gvalue (GSList *list, GValue *value);
 
 guint32 nm_utils_ip4_netmask_to_prefix (guint32 netmask);
 guint32 nm_utils_ip4_prefix_to_netmask (guint32 prefix);
+guint32 nm_utils_ip4_get_default_netmask (guint32 ip);
 
 GSList *nm_utils_ip6_addresses_from_gvalue (const GValue *value);
 void nm_utils_ip6_addresses_to_gvalue (GSList *list, GValue *value);
diff --git a/src/dhcp-manager/nm-dhcp-dhclient.c b/src/dhcp-manager/nm-dhcp-dhclient.c
index 478ac29..0c39186 100644
--- a/src/dhcp-manager/nm-dhcp-dhclient.c
+++ b/src/dhcp-manager/nm-dhcp-dhclient.c
@@ -245,11 +245,16 @@ nm_dhcp_client_get_lease_ip4_config (const char *iface, const char *uuid)
 
 		/* Netmask */
 		data = g_hash_table_lookup (hash, "option subnet-mask");
-		if (!data)
-			data = "255.255.255.0"; /* FIXME: assume class C? */
-		if (!inet_pton (AF_INET, data, &tmp)) {
-			g_warning ("%s: couldn't parse IP4 subnet mask '%s'", __func__, data);
-			goto error;
+		if (data) {
+			if (!inet_pton (AF_INET, data, &tmp)) {
+				g_warning ("%s: couldn't parse IP4 subnet mask '%s'", __func__, data);
+				goto error;
+			}
+		}
+		else {
+			/* Get default netmask for the IP according to appropriate class. */
+			guint32	ip_tmp = tmp.s_addr;
+			tmp.s_addr = nm_utils_ip4_get_default_netmask (ip_tmp);
 		}
 		prefix = nm_utils_ip4_netmask_to_prefix (tmp.s_addr);
 		nm_ip4_address_set_prefix (addr, prefix);
diff --git a/system-settings/plugins/ifcfg-rh/reader.c b/system-settings/plugins/ifcfg-rh/reader.c
index afe35bd..ce4bfa3 100644
--- a/system-settings/plugins/ifcfg-rh/reader.c
+++ b/system-settings/plugins/ifcfg-rh/reader.c
@@ -606,16 +606,10 @@ read_full_ip4_address (shvarFile *ifcfg,
 
 	/* Try to autodetermine the prefix for the address' class */
 	if (!nm_ip4_address_get_prefix (addr)) {
-		guint32 tmp_addr, prefix = 0;
-
-		tmp_addr = nm_ip4_address_get_address (addr);
-		if (((ntohl(tmp_addr) & 0xFF000000) >> 24) <= 127)
-			prefix = 8;
-		else if (((ntohl(tmp_addr) & 0xFF000000) >> 24) <= 191)
-			prefix = 16;
-		else
-			prefix = 24;
+		guint32 default_mask, prefix = 0;
 
+		default_mask = nm_utils_ip4_get_default_netmask (nm_ip4_address_get_address (addr));
+		prefix = nm_utils_ip4_netmask_to_prefix (default_mask);
 		nm_ip4_address_set_prefix (addr, prefix);
 
 		value = svGetValue (ifcfg, ip_tag, FALSE);
