The gateway address (or default gateway) is a router interface connected to the local network that sends packets out of the local network. The gateway has a physical and a logical address. Logical gateway address The gateway operates at the network layer (Layer 3) of the OSI Model. The gateway is used when transmitting packets. When packets are sent over a network, the destination IP address is examined. If the destination IP is outside of the network, then the packet goes to the gateway for transmission outside of the network. The gateway is on the same network as end devices. The gateway address must have the same subnet mask as host devices. Each host on the network uses the same gateway. The gateway should have a static address, as changing the address would cause packets not to be delivered. The gateway is typically assigned either the highest or lowest network address. This is not a requirement, but many organizations use a consistent addressing scheme to facilitate network planning. Physical gateway address The gateway also operates at the data link layer (Layer 2) of the OSI network model. The physical gateway address is called the media access control(MAC) address or burned in address (BIA). The physical address is assigned when the device is manufactured, and cannot be changed. When a frame is sent to a device not on the local network, the gateway's MAC address is used in the frame header. The gateway address must be configured on each host. The network host IP interface binds the gateway address to the MAC address of the physical gateway by broadcasting IP datagrams and caching the MAC address of the reply from the gateway in an ARP table stored on the host. The gateway address may be added manually. On Windows computers, the gateway address is configured using the TCP/IP Properties. The gateway address can be automatically determined using Dynamic Host Configuration Protocol (DHCP). DHCP allows a host to obtain network information from a server. The host contacts the server to obtain an IP address and Default Gateway address. DHCP Servers are normally provided by Internet Service Providers (ISPs). Bad Gateway (502 error) The Bad Gateway 502 error message is a HTTP status code. This occurs when the server was unable to forward the users request, as all queries are forwarded via gateways on the internet. It could mean that the target server