Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

iproute(3) [plan9 man page]

IPROUTE(3)						     Library Functions Manual							IPROUTE(3)

NAME
iproute - Internet route table manager SYNOPSIS
bind -a #P /net /net/iproute /net/ipifc DESCRIPTION
The iproute device allows the specification of routes for families of IP addresses. It maintains a kernel-resident routing table for IP addresses used by TCP, IL and UDP. Each route consists of a destination IP address, an IP mask, and an IP gateway address. Every packet sent by the system is routed according to the route table. An address matches the route table entry when a packet's destination address matches the table destination address under the mask. When a match is found, the packet is sent to the gateway IP address. If there is no match, the packet is sent with the original destination address. If there are several matches, the one whose mask has the fewest leading zeros is chosen. (Because of the definition of IP masks, this mask preserves the largest portion of the address and is therefore the most specific.) This is forced by storing the routes in decreasing number of ones order and returning the first match. The default gateway has no ones in the mask and is thus the last matched. Reading iproute reports the current routes entered in the table. Writing control messages to iproute edits the table. Route entries are made by writing a string of format add ipdest mask ipgateway Entries are deleted by writing a string of format delete ipdest mask The whole table can be cleared by writing the string For example, to install a gateway address to accept all IP packets from a machine: % echo 'add 0.0.0.0 0.0.0.0 131.107.1.5' > /net/iproute % cat /net/iproute 0.0.0.0 & 0.0.0.0 -> 131.107.1.5 Reading ipifc reports the current IP interfaces being used, one line per interface, showing the device, the maximum transfer unit, the local address, the network mask, and the network address. SOURCE
/sys/src/9/port/deviproute.c SEE ALSO
ip(3), ipconfig(8) IPROUTE(3)

Check Out this Related Man Page

route(7)						 Miscellaneous Information Manual						  route(7)

NAME
route - Kernel packet forwarding database SYNOPSIS
#include <sys/socket.h> #include <net/if.h> #include <net/route.h> int family s = socket(PF_ROUTE, SOCK_RAW, family); DESCRIPTION
The UNIX operating system provides packet routing facilities. The kernel maintains a routing information database, which is used in selecting the appropriate network interface when transmitting packets. A user process (or possibly multiple cooperating processes) maintains this database by sending messages over a special kind of socket. Routing table changes may only be carried out by the superuser. The operating system may spontaneously emit routing messages in response to external events, such as receipt of a redirect, or failure to locate a suitable route for a request. Routing database entries are of two types: those for a specific host, and those for all hosts on a generic subnetwork (as specified by a bit mask and value under the mask). The effect of a wildcard or default route may be achieved by using a mask of all zeros. There may be hierarchical routes. When the system is booted and addresses are assigned to the network interfaces, each protocol family installs a routing table entry for each interface when it is ready for traffic. Normally the protocol specifies the route through each interface as a ``direct'' connection to the destination host or network. If the route is direct, the transport layer of a protocol family usually requests that the packet be sent to the host specified in the packet. Otherwise, the interface is requested to address the packet to the gateway listed in the routing entry (that is, the packet is forwarded). When routing a packet, the kernel first attempts to find a route to the destination host. Failing that, a search is made for a route to the network of the destination. Finally, any route to a default (wildcard) gateway is chosen. If no entry is found, the destination is declared to be unreachable, and an error message is generated if there are any listeners on the routing control socket described later in this section. A wildcard routing entry is specified with a zero destination address value. Wildcard routes are used only when the system fails to find a route to the destination host and network. The combination of wildcard routes and routing redirects can provide an economical mechanism for routing traffic. To open the channel for passing routing control messages, use the socket call shown in the SYNOPSIS section. The family parameter may be AF_UNSPEC which will provide routing information for all address families, or can be restricted to a specific address family by specifying which one is desired. There can be more than one routing socket open per system. Messages are formed by a header followed by a small number of sockaddrs (now variable length), interpreted by position, and delimited by the new length entry in the sockaddr. An example of a message with four addresses might be an ISO redirect: destination, netmask, gateway, and author of the redirect. The interpretation of which addresses are present is given by a bit mask within the header, and the sequence is least significant to most significant bit within the vector. Any messages sent to the kernel are returned, and copies are sent to all interested listeners. The kernel will provide the process ID for the sender, and the sender may use an additional sequence field to distinguish between outstanding messages. However, message replies may be lost when kernel buffers are exhausted. The kernel may reject certain messages, and will indicate this by filling in the rtm_errno field. In the current implementation, all rout- ing process run locally, and the values for rtm_errno are available through the normal errno mechanism, even if the routing reply message is lost. A process may avoid the expense of reading replies to its own messages by issuing a setsockopt() call indicating that the SO_USELOOPBACK option at the SOL_SOCKET level is to be turned off. A process may ignore all messages from the routing socket by shutting down further input with the shutdown() function. If a route is in use when it is deleted, the routing entry will be marked down and removed from the routing table, but the resources asso- ciated with it will not be reclaimed until all references to it are released. User processes can obtain information about the routing entry to a specific destination by using a RTM_GET message, or by reading the /dev/kmem device. ERRORS
If messages are rejected, rtm_errno may be set to one of the following values: The entry to be created already exists. The entry to be deleted does not exist. Insufficient resources were available to install a new route. delim off route(7)
Man Page