diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py
index d9166d2ef32146351f0f153e37550f296ca8f141..518b78cd0743705f47d5dcec1120692b7af14c52 100644
--- a/tests/functional/conftest.py
+++ b/tests/functional/conftest.py
@@ -82,6 +82,7 @@ def session(db, request):
 
     Rollback any transaction to always leave the database clean
     """
+    factories.InterfaceFactory.reset_sequence()
     connection = db.engine.connect()
     transaction = connection.begin()
     session = common.Session
diff --git a/tests/functional/factories.py b/tests/functional/factories.py
index 523103ed31db5bf8ae409d27f96f89556d5a1c56..b3479238338abe3bd577f76f3980a6e7f91e4b94 100644
--- a/tests/functional/factories.py
+++ b/tests/functional/factories.py
@@ -139,7 +139,10 @@ class NetworkFactory(factory.alchemy.SQLAlchemyModelFactory):
     def last_ip(self):
         net = ipaddress.ip_network(self.address)
         hosts = list(net.hosts())
-        return str(hosts[-5])
+        try:
+            return str(hosts[-5])
+        except IndexError:
+            return str(hosts[-1])
 
 
 class InterfaceFactory(factory.alchemy.SQLAlchemyModelFactory):