Large-scale disaster management applications are among the several realistic applications of the IoT. Fire detection and earthquake early warning applications are just two examples. Several IoT devices are used in such applications e.g., sensors and robots. These sensors and robots are usually heterogeneous. Moreover, in disaster scenarios, the existing communication infrastructure may become completely or partially destroyed, leaving mobile ad-hoc networks the only alternative to provide connectivity. Utilizing these applications raises new challenges such as the need for dynamic, flexible, and distributed gateways which can accommodate new applications and new IoT devices. Network Functions Virtualization (NFV) and Software Defined Networking (SDN) are emerging paradigms that can help to overcome these challenges. This paper leverages NFV and SDN to propose an architecture for on-the-fly distributed gateway provisioning in large-scale disaster management. In the proposed architecture, the gateway functions are provisioned as Virtual Network Functions (VNFs) that are chained on-the-fly in the IoT domain using SDN. A prototype is built and the performance results are presented.