route.8
来自「Linux下网络相关工具源代码。」· 8 代码 · 共 325 行
8
325 行
.TH ROUTE 8 "8 August 1997" "net-tools" "Linux Programmer's Manual".SH NAMEroute \- show / manipulate the IP routing table.SH SYNOPSIS.B route.RB [ \-CFvnee ].TP.B route .RB [ \-v ].RB [ \-Afamily] .B add .RB [ \-net | \-host ] target .RB [ netmask Nm] .RB [ gw Gw] .RB [ metric N] .RB [ mss M] .RB [ window W] .RB [ irtt I].RB [ reject ].RB [ mod ].RB [ dyn ] .RB [ reinstate ] .RB [[ dev ] If].TP.B route .RB [ \-v ] .RB [ \-Afamily].B del .RB [ \-net | \-host ] target .RB [ gw Gw] .RB [ netmask Nm] .RB [ metric N] .RB [[ dev ]If].TP.B route .RB [ \-V ] .RB [ \-\-version ].RB [ \-h ].RB [ \--help ].SH DESCRIPTION.B Routemanipulates the kernel's IP routing table. Its primary use is to setup static routes to specific hosts or networks via an interface afterit has been configured with the.BR ifconfig (8)program..SH OPTIONS.TP.B \-vselect verbose operation..TP.B \-A familyUse the specified address family (eg `inet', `inet6')..TP.B \-nshow numerical addresses instead of trying to determine symbolic hostnames. This is useful if you are trying to determine why the route to yournameserver has vanished..TP.B \-euse.BR netstat (8)-formatfor displaying the routing table..B \-ee will generate a very long line with all parameters from the routing table..TP.B \-netthe.B targetis a network..TP.B -hostthe.B target is a host..TP .B -Fdisplays the kernel FIB routing table. The layout can be changed with.B \-eand.B \-ee..TP .B -Cdisplays the kernel's route cache. .TP.B deldeletes a route..TP .B add adds a route..TP.B targetThe destination network or host. You can provide IP addresses in dotteddecimal or host/network names..TP.B netmask Nmmodifier specifies the netmask of the route to be added..TP.B gw GwAny IP packets for the target network/host will be routed through the specified gateway. .B NOTE:The specified gateway must be reachable first. This usually means thatyou have to set up a static route to the gateway beforehand. If you specifythe address of one of your local interfaces, it will be used to decide aboutthe interface to which the packets should be routed to. This is a BSDismcompatibility hack..TP.B metric MSet the metric field in the routing table (used by routing daemons) to M..TP .B mss MSet the TCP Maximum Segment Size (MSS) for connections over this routeto M bytes. This is normally used only for fine optimisation ofrouting setups. The default is 536..TP .B window W Set the TCP window size for connections over this route to Wbytes. This is typically only used on AX.25 networks and with driversunable to handle back to back frames..TP.B irtt ISet the initial round trip time (irtt) for TCP connections over thisroute to I milliseconds (1-12000). This is typically only used onAX.25 networks. If omitted the RFC 1122 default of 300ms is used..TP.B rejectInstall a blocking route, which will force a route lookup to fail.This is for example used to mask out networks before using the defaultroute. This is NOT for firewalling..TP.B mod, dyn, reinstateInstall a dynamic or modified route. Both flags are generally onlyset by a routing daemon. This is only for diagnostic purpose..TP.B dev IfForces the route to be associated with the specified device, as thekernel will otherwise try to determine the device on its own (bychecking already existing routes and device specifications, and wherethe route is added to). In most normal networks you won't need this.If .B dev Ifis the last option on the command line, the word .B devmay be omitted, as it's the default. Otherwise the order of the routemodifiers (metric - netmask - gw - dev) doesn't matter..SH EXAMPLES.TP.B route add -net 127.0.0.0adds the normal loopback entry, using netmask 255.0.0.0 (class A net,determined from the destination address) and associated with the "lo" device (assuming this device was prviously set up correctly with.BR ifconfig (8)). .TP .B route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0adds a route to the network 192.56.76.x via "eth0". The Class C netmask modifier is not really necessary here because192.* is a Class C IP address. The word "dev" can be omitted here. .TP.B route add default gw mango-gwadds a default route (which will be used if no other route matches).All packets using this route will be gatewayed through "mango-gw". Thedevice which will actually be used for that route depends on how wecan reach "mango-gw" - the static route to "mango-gw" will have to beset up before. .TP.B route add ipx4 sl0Adds the route to the "ipx4" host via the SLIP interface (assuming that"ipx4" is the SLIP host)..TP.B route add -net 192.57.66.0 netmask 255.255.255.0 gw ipx4This command adds the net "192.57.66.x" to be gatewayed through the formerroute to the SLIP interface..TP.B route add 224.0.0.0 netmask 240.0.0.0 dev eth0This is an obscure one documented so people know how to do it. This setsall of the class D (multicast) IP routes to go via "eth0". This is thecorrect normal configuration line with a multicasting kernel. .TP.B route add 10.0.0.0 netmask 255.0.0.0 rejectThis installs a rejecting route for the private network "10.x.x.x.".LP.SH OUTPUTThe output of the kernel routing table is organized in the following columns.TP.B Destination The destination network or destination host..TP.B GatewayThe gateway address or '*' if none set..TP.B Genmask The netmask for the destination net; '255.255.255.255' for a host destinationand '0.0.0.0' for the .B defaultroute..TP.B Flags Possible flags are.br.B U(route is.BR up ).br.B H(target is a.BR host ).br.B G(use.BR gateway ).br.B R.RB ( reinstateroute for dynamic routing).br.B D.RB ( dynamicallyinstalled by daemon or redirect).br.B M.RB ( modifiedfrom routing daemon or rederict).br.B !.RB ( rejectroute).TP.B Metric The 'distance' to the target (usually counted in hops). It is not used byrecent kernels, but may be needed by routing daemons..TP.B Ref Number of references to this route. (Not used in the Linux kernel.).TP.B UseCount of lookups for the route. Depending on the use of -F and -C this willbe either route cache misses (-F) or hits (-C)..TP.B IfaceInterface to which packets for this route will be sent..TP.B MSS Default maximum segement size for TCP connections over this route..TP.B Window Default window size for TCP connections over this route..TP.B irttInitial RTT (Round Trip Time). The kernel uses this to guess about the bestTCP protocol parameters without waiting on (possible slow) answers..TP.B HH (cached only)The number of ARP entries and cached routes that refer to the hardwareheader cache for the cached route. This will be \-1 if a hardwareaddress is not needed for the interface of the cached route (e.g. lo)..TP.B Arp (cached only)Whether or not the hardware address for the cached route is up to date..LP.SH FILES.I /proc/net/ipv6_route.br.I /proc/net/route.br.I /proc/net/rt_cache.LP.SH SEE ALSO.I ifconfig(8), netstat(8), arp(8), rarp(8).LP.SH HISTORY.B Routefor Linux was originally written by Fred N. van Kempen,<waltje@uwalt.nl.mugnet.org> and then modified by Johannes Stille andLinus Torvalds for pl15. Alan Cox added the mss and window options forLinux 1.1.22. irtt support and merged with netstat from Bernd Eckenfels..SH AUTHORCurrently maintained by Phil Blundell <Philip.Blundell@pobox.com>.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?