Default Gateway
   HOME

TheInfoList



OR:

A default gateway is the
node In general, a node is a localized swelling (a "knot") or a point of intersection (a vertex). Node may refer to: In mathematics *Vertex (graph theory), a vertex in a mathematical graph *Vertex (geometry), a point where two or more curves, lines, ...
in a
computer network A computer network is a set of computers sharing resources located on or provided by network nodes. The computers use common communication protocols over digital interconnections to communicate with each other. These interconnections are ...
using the
Internet protocol suite The Internet protocol suite, commonly known as TCP/IP, is a framework for organizing the set of communication protocols used in the Internet and similar computer networks according to functional criteria. The foundational protocols in the suit ...
that serves as the forwarding host ( router) to other networks when no other route specification matches the destination
IP address An Internet Protocol address (IP address) is a numerical label such as that is connected to a computer network that uses the Internet Protocol for communication.. Updated by . An IP address serves two main functions: network interface ident ...
of a packet.


Role

A gateway is a network node that serves as an access point to another network, often involving not only a change of addressing, but also a different networking technology. More narrowly defined, a router merely forwards packets between networks with different
network prefix An Internet Protocol address (IP address) is a numerical label such as that is connected to a computer network that uses the Internet Protocol for communication.. Updated by . An IP address serves two main functions: network interface Identi ...
es. The networking software stack of each computer contains a
routing table In computer networking, a routing table, or routing information base (RIB), is a data table stored in a router or a network host that lists the routes to particular network destinations, and in some cases, metrics (distances) associated with tho ...
that specifies which interface is used for transmission and which router on the network is responsible for forwarding to a specific set of addresses. If none of these forwarding rules is appropriate for a given destination address, the default gateway is chosen as the router of last resort. The default gateway can be specified by the
route Route or routes may refer to: * Route (gridiron football), a path run by a wide receiver * route (command), a program used to configure the routing table * Route, County Antrim, an area in Northern Ireland * ''The Route'', a 2013 Ugandan film * Ro ...
command to configure the node's routing table and
default route In computer networking, the default route is a configuration of the Internet Protocol (IP) that establishes a forwarding rule for packets when no specific address of a next-hop host is available from the routing table or other routing mechanisms ...
. In a home or small office environment, the default gateway is a device, such as a DSL router or cable router, that connects the local network to the Internet. It serves as the default gateway for all network devices. Enterprise network systems may require many internal
network segment A network segment is a portion of a computer network. The nature and extent of a segment depends on the nature of the network and the device or devices used to interconnect end stations. Ethernet According to the defining IEEE 802.3 standards ...
s. A device wishing to communicate with a host on the public Internet, for example, forwards the packet to the default gateway for its network segment. This router also has a default route configured to a device on an adjacent network, one hop closer to the public network.


Examples


Single router

The following example shows IP addresses that might be used with an office network that consists of six hosts plus a router. The six hosts addresses are: * 192.168.4.3 * 192.168.4.4 * 192.168.4.5 * 192.168.4.6 * 192.168.4.7 * 192.168.4.8 The router's inside address is: * 192.168.4.1 The network has a
subnet mask A subnetwork or subnet is a logical subdivision of an IP network. Updated by RFC 6918. The practice of dividing a network into two or more networks is called subnetting. Computers that belong to the same subnet are addressed with an identical ...
of: * 255.255.255.0 (/24 in
CIDR Classless Inter-Domain Routing (CIDR ) is a method for allocating IP addresses and for IP routing. The Internet Engineering Task Force introduced CIDR in 1993 to replace the previous classful network addressing architecture on the Internet. Its g ...
notation) The address range assignable to hosts is from 192.168.4.1 to 192.168.4.254. TCP/IP defines the addresses 192.168.4.0 (network ID address) and 192.168.4.255 (broadcast IP address). The office's hosts send packets to addresses within this range directly, by resolving the destination IP address into a
MAC address A media access control address (MAC address) is a unique identifier assigned to a network interface controller (NIC) for use as a network address in communications within a network segment. This use is common in most IEEE 802 networking techno ...
with the
Address Resolution Protocol The Address Resolution Protocol (ARP) is a communication protocol used for discovering the link layer address, such as a MAC address, associated with a given internet layer address, typically an IPv4 address. This mapping is a critical function ...
(ARP) sequence and then encapsulates the IP packet into a MAC frame addressed to the destination host. A packet addressed outside of this range, for this example, addressed to 192.168.12.3, cannot travel directly to the destination. Instead it must be sent to the default gateway for further routing to their ultimate destination. In this example, the default gateway uses the IP address 192.168.4.1, which is resolved into a MAC address with ARP in the usual way. The destination IP address remains 192.168.12.3, but the next-hop MAC address is that of the gateway, rather than of the ultimate destination.


Multi-router

In another example, a network with three routers and three hosts is connected to the Internet through Router1. The hosts' addresses are: * PC1 10.1.1.100, default gateway 10.1.1.1 * PC2 172.16.1.100, default gateway 172.16.1.1 * PC3 192.168.1.100, default gateway 192.168.1.96 Router1: * Interface 1 5.5.5.2 (
public IP An Internet Protocol address (IP address) is a numerical label such as that is connected to a computer network that uses the Internet Protocol for communication.. Updated by . An IP address serves two main functions: network interface identi ...
) * Interface 2 10.1.1.1 Router2: * Interface 1 10.1.1.2 * Interface 2 172.16.1.1 Router3: * Interface 1 10.1.1.3 * Interface 2 192.168.1.96 Network mask in all networks: 255.255.255.0 (/24 in
CIDR Classless Inter-Domain Routing (CIDR ) is a method for allocating IP addresses and for IP routing. The Internet Engineering Task Force introduced CIDR in 1993 to replace the previous classful network addressing architecture on the Internet. Its g ...
notation). If the routers do not use a
routing protocol A routing protocol specifies how routers communicate with each other to distribute information that enables them to select routes between nodes on a computer network. Routers perform the traffic directing functions on the Internet; data packets ...
to discover which network each router is connected to, then the
routing table In computer networking, a routing table, or routing information base (RIB), is a data table stored in a router or a network host that lists the routes to particular network destinations, and in some cases, metrics (distances) associated with tho ...
of each router must be set up. Router1 Router2 Router3 Router2 manages its attached networks and default gateway; router 3 does the same; router 1 manages all routes within the internal networks. ; Accessing internal resources : If PC2 (172.16.1.100) needs to access PC3 (192.168.1.100), since PC2 has no route to 192.168.1.100 it will send packets for PC3 to its default gateway (router2). Router2 also has no route to PC3, and it will forward the packets to its default gateway (router1). Router1 has a route for this network (192.168.1.0/24) so router1 will forward the packets to router3, which will deliver the packets to PC3; reply packets will follow the reverse path back to PC2. ; Accessing external resources : If any of the computers try to access a webpage on the Internet, like https://en.wikipedia.org/, the destination will first be resolved to an IP address by using
DNS The Domain Name System (DNS) is a hierarchical and distributed naming system for computers, services, and other resources in the Internet or other Internet Protocol (IP) networks. It associates various information with domain names assigned to ...
-resolving. The IP-address could be 91.198.174.2. In this example, none of the internal routers know the route to that host, so they will forward the packet through router1's gateway or
default route In computer networking, the default route is a configuration of the Internet Protocol (IP) that establishes a forwarding rule for packets when no specific address of a next-hop host is available from the routing table or other routing mechanisms ...
. Every router on the packet's way to the destination will check whether the packet's destination IP-address matches any known network routes. If a router finds a match, it will forward the packet through that route; if not, it will send the packet to its own default gateway. Each router encountered on the way will store the packet ID and where it came from so that it can pass the response packet back to the sender. The packet contains source and destination, not all router hops. At last the packet will arrive back to router1, which will check for matching packet ID and route it accordingly through router2 or router3 or directly to PC1 (which was connected in the same network segment as router1). ; The packet doesn't return : If router1 routing table does not have any route to 192.168.1.0/24, and PC3 tries to access a resource outside its own network, then the outgoing routing will work until the reply is fed back to router1. Since the route is unknown to router1, it will go to router1's default gateway, and never reach router3. In the logs of the resource they will trace the request, but the requestor will never get any information. The packet will die because the
TTL TTL may refer to: Photography * Through-the-lens metering, a camera feature * Zenit TTL, an SLR film camera named for its TTL metering capability Technology * Time to live, a computer data lifespan-limiting mechanism * Transistor–transistor lo ...
-value decreased to less than 1 when it was traveling through the routers, or the router will see that it has a private IP and discard it. This could be discovered by using the
Microsoft Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
utility PathPing or MTR on Unix-like operating systems, since the ping will stop at the router which has no route or a wrong route. (Note that some routers will not reply to pinging).


Utilities

Various
utility software Utility software is software designed to help analyze, configure, optimize or maintain a computer. It is used to support the computer infrastructure - in contrast to application software, which is aimed at directly performing tasks that benefit ord ...
can show the default gateway. On Windows,
ipconfig ipconfig (standing for "Internet Protocol configuration") is a console application program of some computer operating systems that displays all current TCP/IP network configuration values and refreshes Dynamic Host Configuration Protocol (DHCP) an ...
may be used, while on
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
systems,
ifconfig ifconfig (short for ''interface config'') is a system administration utility in Unix-like operating systems for network interface configuration. The utility is a command-line interface tool and is also used in the system startup scripts of man ...
or
netstat In computing, netstat (''network statistics'') is a command-line network utility that displays network connections for Transmission Control Protocol (both incoming and outgoing), routing tables, and a number of network interface (network interfa ...
may be used. On Linux netstat has been superseded by
iproute2 iproute2 is a collection of userspace utilities for controlling and monitoring various aspects of networking in the Linux kernel, including routing, network interfaces, tunnels, traffic control, and network-related device drivers. iproute2 ...
.{{Cite web, title=Deprecated Linux networking commands and their replacements, url=https://dougvitale.wordpress.com/2011/12/21/deprecated-linux-networking-commands-and-their-replacements/, date=2011-12-21, website=Doug Vitale Tech Blog, access-date=2020-05-18


References


External links


The Linux Documentation Project
Routing