diff --git a/tools/ndn-autoconfig-server.cpp b/tools/ndn-autoconfig-server.cpp
index bc038e3..1a01061 100644
--- a/tools/ndn-autoconfig-server.cpp
+++ b/tools/ndn-autoconfig-server.cpp
@@ -26,46 +26,111 @@
 #include <ndn-cxx/face.hpp>
 #include <ndn-cxx/security/key-chain.hpp>
 
+namespace ndn {
 
-void
+const static Name AUTOCONFIG_PREFIX          = "/localhop/ndn-autoconf";
+const static Name LOCALHOP_HUB               = "/localhop/ndn-autoconf/hub";
+const static Name LOCALHOP_ROUTABLE_PREFIXES = "/localhop/ndn-autoconf/routable-prefixes";
+
+static void
 usage(const char* programName)
 {
-  std::cout << "Usage:\n" << programName  << " [-h] [-V] Uri \n"
-            << "   -h  - print usage and exit\n"
-            << "   -V  - print version number and exit\n"
+  std::cout << "Usage:\n" << programName  << " [-h] [-V] [-p prefix] [-p prefix] ... Uri \n"
+            << "   -h        - print usage and exit\n"
+            << "   -V        - print version number and exit\n"
+            << "   -p prefix - the local prefix of the hub\n"
             << "\n"
             << "   Uri - a FaceMgmt URI\n"
             << std::endl;
 }
 
-using namespace ndn;
-
-class NdnAutoconfigServer
+class PrefixCollection : noncopyable
 {
 public:
-  explicit
-  NdnAutoconfigServer(const std::string& uri)
-    : m_faceMgmtUri(uri)
+  bool
+  empty() const
   {
+    return m_prefixes.empty();
   }
 
   void
-  onInterest(const Name& name, const Interest& interest)
+  add(const Name& prefix)
   {
-    ndn::Data data(ndn::Name(interest.getName()).appendVersion());
-    data.setFreshnessPeriod(ndn::time::hours(1)); // 1 hour
+    m_prefixes.push_back(prefix);
+  }
 
-    // create and encode uri block
-    Block uriBlock = dataBlock(tlv::nfd::Uri,
-                               reinterpret_cast<const uint8_t*>(m_faceMgmtUri.c_str()),
-                               m_faceMgmtUri.size());
-    data.setContent(uriBlock);
-    m_keyChain.sign(data);
-    m_face.put(data);
+  template<bool T>
+  size_t
+  wireEncode(EncodingImpl<T>& encoder) const
+  {
+    size_t totalLength = 0;
+
+    for (std::vector<Name>::const_reverse_iterator i = m_prefixes.rbegin();
+         i != m_prefixes.rend(); ++i) {
+      totalLength += i->wireEncode(encoder);
+    }
+
+    totalLength += encoder.prependVarNumber(totalLength);
+    totalLength += encoder.prependVarNumber(tlv::Content);
+    return totalLength;
+  }
+
+  Block
+  wireEncode() const
+  {
+    Block block;
+
+    EncodingEstimator estimator;
+    size_t estimatedSize = wireEncode(estimator);
+
+    EncodingBuffer buffer(estimatedSize);
+    wireEncode(buffer);
+
+    return buffer.block();
+  }
+
+private:
+  std::vector<Name> m_prefixes;
+};
+
+class NdnAutoconfigServer : noncopyable
+{
+public:
+  NdnAutoconfigServer(const std::string& hubFaceUri, const PrefixCollection& routablePrefixes)
+  {
+    KeyChain m_keyChain;
+
+    // pre-create hub Data
+    m_hubData = make_shared<Data>(Name(LOCALHOP_HUB).appendVersion());
+    m_hubData->setFreshnessPeriod(time::hours(1)); // 1 hour
+    m_hubData->setContent(dataBlock(tlv::nfd::Uri,
+                                    reinterpret_cast<const uint8_t*>(hubFaceUri.c_str()),
+                                    hubFaceUri.size()));
+    m_keyChain.sign(*m_hubData);
+
+    // pre-create routable prefix Data
+    if (!routablePrefixes.empty()) {
+      m_routablePrefixesData = make_shared<Data>(Name(LOCALHOP_ROUTABLE_PREFIXES).appendVersion());
+      m_routablePrefixesData->setContent(routablePrefixes.wireEncode());
+      m_routablePrefixesData->setFreshnessPeriod(time::seconds(5)); // 5s
+      m_keyChain.sign(*m_routablePrefixesData);
+    }
   }
 
   void
-  onRegisterFailed(const ndn::Name& prefix, const std::string& reason)
+  onHubInterest(const Name& name, const Interest& interest)
+  {
+    m_face.put(*m_hubData);
+  }
+
+  void
+  onRoutablePrefixesInterest(const Name& name, const Interest& interest)
+  {
+    m_face.put(*m_routablePrefixesData);
+  }
+
+  void
+  onRegisterFailed(const Name& prefix, const std::string& reason)
   {
     std::cerr << "ERROR: Failed to register prefix in local hub's daemon (" <<
               reason << ")" << std::endl;
@@ -73,29 +138,46 @@
   }
 
   void
-  listen()
+  afterPrefixRegistered()
   {
-    m_face.setInterestFilter("/localhop/ndn-autoconf/hub",
-                             ndn::bind(&NdnAutoconfigServer::onInterest, this, _1, _2),
-                             ndn::RegisterPrefixSuccessCallback(),
-                             ndn::bind(&NdnAutoconfigServer::onRegisterFailed, this, _1, _2));
+    BOOST_ASSERT(AUTOCONFIG_PREFIX.isPrefixOf(LOCALHOP_HUB));
+    m_face.setInterestFilter(LOCALHOP_HUB,
+                             bind(&NdnAutoconfigServer::onHubInterest, this, _1, _2));
+
+    if (static_cast<bool>(m_routablePrefixesData)) {
+      BOOST_ASSERT(AUTOCONFIG_PREFIX.isPrefixOf(LOCALHOP_ROUTABLE_PREFIXES));
+      m_face.setInterestFilter(LOCALHOP_ROUTABLE_PREFIXES,
+                               bind(&NdnAutoconfigServer::onRoutablePrefixesInterest,
+                                    this, _1, _2));
+    }
+  }
+
+  void
+  run()
+  {
+    m_face.registerPrefix(AUTOCONFIG_PREFIX,
+                          bind(&NdnAutoconfigServer::afterPrefixRegistered, this),
+                          bind(&NdnAutoconfigServer::onRegisterFailed, this, _1, _2));
+
     m_face.processEvents();
   }
 
 private:
-  ndn::Face m_face;
-  KeyChain m_keyChain;
-  std::string m_faceMgmtUri;
+  Face m_face;
 
+  shared_ptr<Data> m_hubData;
+  shared_ptr<Data> m_routablePrefixesData;
 };
 
 int
 main(int argc, char** argv)
 {
-  int opt;
   const char* programName = argv[0];
 
-  while ((opt = getopt(argc, argv, "hV")) != -1) {
+  PrefixCollection routablePrefixes;
+
+  int opt;
+  while ((opt = getopt(argc, argv, "hVp:")) != -1) {
     switch (opt) {
     case 'h':
       usage(programName);
@@ -103,6 +185,9 @@
     case 'V':
       std::cout << NFD_VERSION_BUILD_STRING << std::endl;
       return 0;
+    case 'p':
+      routablePrefixes.add(Name(optarg));
+      break;
     default:
       usage(programName);
       return 1;
@@ -113,11 +198,12 @@
     usage(programName);
     return 1;
   }
-  // get the configured face management uri
-  NdnAutoconfigServer producer(argv[optind]);
+
+  std::string hubFaceUri = argv[optind];
+  NdnAutoconfigServer instance(hubFaceUri, routablePrefixes);
 
   try {
-    producer.listen();
+    instance.run();
   }
   catch (const std::exception& error) {
     std::cerr << "ERROR: " << error.what() << std::endl;
@@ -125,3 +211,11 @@
   }
   return 0;
 }
+
+} // namespace ndn
+
+int
+main(int argc, char** argv)
+{
+  return ndn::main(argc, argv);
+}
