diff --git a/generate.py b/generate.py
index 9e1ffa66f340aa2980fbf58218d5925bb45a4f3c..16f040252f1cfc6c509ef6e676ae7fca88afafe4 100644
--- a/generate.py
+++ b/generate.py
@@ -4,6 +4,8 @@ import sys
 import yaml
 import jinja2
 
+from modules.network_parser import add_networks
+
 if (len(sys.argv) != 2):
     print ("Error: Expecting 1 argument (yml file).")
     sys.exit();
@@ -26,17 +28,20 @@ def do_mapping(name, command_type):
 
 def add_formated_command(key, value):
     if (key in vagrant_mappings['string']):
-        devices[host['name']].append('device.' + str(do_mapping(key, 'string')) + ' = \"' + str(value) + '\"')
+        devices[host['name']].append(
+                'device.' + str(do_mapping(key, 'string'))
+                + ' = \"' + str(value) + '\"')
     elif (key in vagrant_mappings['integer']):
-        devices[host['name']].append('device.' + str(do_mapping(key, 'integer')) + ' = ' + str(value))
+        devices[host['name']].append(
+                'device.' + str(do_mapping(key, 'integer'))
+                + ' = ' + str(value))
     elif (key in vagrant_mappings['boolean']):
-        devices[host['name']].append('device.' + str(do_mapping(key, 'boolean')) + ' = ' + str(value).lower())
+        devices[host['name']].append(
+                'device.' + str(do_mapping(key, 'boolean'))
+                + ' = ' + str(value).lower())
 
-def find_ip(name):
-    for net_mapping in yml['net_mappings']:
-        if (net_mapping['host'] == name):
-            return net_mapping['ip']
 
+# Building "devices" structure that will be passed to Jinja2
 devices = {}
 
 for host in yml['hosts']:
@@ -44,18 +49,13 @@ for host in yml['hosts']:
     for key, value in host.items():
         if (key != 'name'):
             add_formated_command(key, value)
-    if (yml['net_mappings']):      
-        devices[host['name']].append('device.vm.network :private_network, ip: \"' + str(find_ip(host['name'])) + '\"')
+    add_networks(host['name'], yml, devices)
+
 
+# Generating output via Jinja2
 templateLoader = jinja2.FileSystemLoader(searchpath="templates")
 templateEnv = jinja2.Environment(loader=templateLoader, trim_blocks=True)
 baseTemplate = templateEnv.get_template("base")
 output = baseTemplate.render(devices = devices)
-print (output.encode('utf-8'))
-
-#vagrantfile = open('Vagrantfile','w')
-#vagrantfile.write(output)
-
-
-
+print (output)
 
diff --git a/modules/network_parser.py b/modules/network_parser.py
new file mode 100644
index 0000000000000000000000000000000000000000..9b412d01a8724bba6b16e3e5f866ac41e18b5b52
--- /dev/null
+++ b/modules/network_parser.py
@@ -0,0 +1,28 @@
+def _find_ip(hostname, net_mappings):
+    for net_mapping in net_mappings:
+        if (net_mapping['host'] == hostname):
+            return net_mapping['ip']
+
+def _add_ip(hostname, net_mappings, devices):
+    devices[hostname].append(
+            'device.vm.network :private_network, ip: \"'
+            + str(_find_ip(hostname, net_mappings)) + '\"')
+
+def _add_netmask(hostname, my_network, networks, devices):
+    for network in networks:
+        if (network['name'] == my_network):
+            address, mask = network['cidr'].split('/')
+            devices[hostname][-1] += (', netmask: ' + mask)
+
+def add_networks(hostname, yml, devices):
+
+    if (not yml['net_mappings']):
+        return
+
+    for mapping in yml['net_mappings']:
+        if (mapping['host'] == hostname):
+            _add_ip(hostname, yml['net_mappings'], devices)
+            if (yml['networks']):
+                _add_netmask(hostname, mapping['network'], yml['networks'], devices)
+                
+