Vous êtes sur la page 1sur 23

o specify a RIP version to send on an interface basis, use the ip rip send version command in

interface configuration mode. Use the no form of this command to follow the global version rules.

ip rip send version [1] [2]

no ip rip send version


Syntax Description

(Optional) Sends only RIP Version 1 packets out the interface.

(Optional) Sends only RIP Version 2 packets out the interface.

Defaults

The software behaves according to the router version command.


Command Modes

Interface configuration
Command History
Release

Modification

11.1

This command was introduced.

Usage Guidelines

Use this command to override the default behavior of RIP as specified by the router version
command. This command applies only to the interface being configured.

The following example configures the interface to send both RIP Version 1 and Version 2 packets
out the interface:

ip rip send version 1 2

The following example configures the interface to send only RIP Version 2 packets out the
interface:

ip rip send version 2

Related Commands
Command

Description

ip rip receive version

Specifies a RIP version to receive on an interface basis.

version

Specifies a RIP vesrion used globally by the router.

ip split-horizon (RIP)

To enable the split horizon mechanism, use the ip split-horizon command in interface configuration
mode. To disable the split horizon mechanism, use the no form of this command.

ip split-horizon

no ip split-horizon
Syntax Description

This command has no arguments or keywords.


Defaults

Default behavior varies with media type.


Command Modes

Interface configuration
Command History
Release

Modification

10.0

This command was introduced.

Usage Guidelines

For all interfaces except those for which either Frame Relay or SMDS encapsulation is enabled, the
default condition for this command is ip split-horizon; in other words, the split horizon feature is
active. If the interface configuration includes either the encapsulation frame-relay or encapsulation
smds commands, then the default is for split horizon to be disabled. Split horizon is not disabled by
default for interfaces using any of the X.25 encapsulations.

Note For networks that include links over X.25 PSNs, the neighbor router configuration command
can be used to defeat the split horizon feature. You can as an alternative explicitly specify the no ip
split-horizon command in your configuration. However, if you do so you must similarly disable
split horizon for all routers in any relevant multicast groups on that network.

Note If split horizon has been disabled on an interface and you want to enable it, use the ip split-
horizon command to restore the split horizon mechanism.
Note In general, changing the state of the default for the ip split-horizon command is not
recommended, unless you are certain that your application requires a change in order to properly
advertise routes. If split horizon is disabled on a serial interface (and that interface is attached to a
packet-switched network), you must disable split horizon for all routers and access servers in any
relevant multicast groups on that network.

The following simple example disables split horizon on a serial link. The serial link is connected to
an X.25 network:

interface serial 0

encapsulation x25

no ip split-horizon

Related Commands
Command

Description
neighbor (RIP)

Defines a neighboring router with which to exchange routing information.

neighbor (RIP)

To define a neighboring router with which to exchange routing information, use this form of the
neighbor command in router configuration mode. To remove an entry, use the no form of this
command.

neighbor ip-address

no neighbor ip-address
Syntax Description

ip-address

IP address of a peer router with which routing information will be exchanged.

Defaults
No neighboring routers are defined.
Command Modes

Router configuration
Command History
Release

Modification

10.0

This command was introduced.

Usage Guidelines

This command permits the point-to-point (nonbroadcast) exchange of routing information. When it
is used in combination with the passive-interface router configuration command, routing
information can be exchanged between a subset of routers and access servers on a LAN.

Multiple neighbor commands can be used to specify additional neighbors or peers.


Examples

In the following example, RIP updates are sent to all interfaces on network 10.108.0.0 except
interface Ethernet 1. However, in this case a neighbor router configuration command is included.
This command permits the sending of routing updates to specific neighbors. One copy of the
routing update is generated per neighbor.

router rip

network 10.108.0.0

passive-interface ethernet 1
neighbor 10.108.20.4

Related Commands
Command

Description

passive-interface

Disables sending routing updates on an interface.

network (RIP)

To specify a list of networks for the Routing Information Protocol (RIP) routing process, use this
form of the network command in router configuration mode. To remove an entry, use the no form of
this command.

network network-number

no network network-number
Syntax Description

network-number

IP address of the network of directly connected networks.

Defaults

No networks are specified.


Command Modes

Router configuration
Command History
Release

Modification

10.0

This command was introduced.

Usage Guidelines

The network number specified must not contain any subnet information. There is no limit to the
number of network commands you can use on the router. RIP routing updates will be sent and
received only through interfaces on this network.

RIP sends updates to the interfaces in the specified networks. Also, if an interface's network is not
specified, it will not be advertised in any RIP update.
Examples

The following example defines RIP as the routing protocol to be used on all interfaces connected to
networks 10.99.0.0 and 192.168.7.0:

router rip

network 10.99.0.0

network 192.168.7.0

Related Commands
Command

Description

router rip

Configures the Routing Information Protocol (RIP) process.

offset-list

To add an offset to incoming and outgoing metrics to routes learned via RIP, use the offset-list
command in router configuration mode. To remove an offset list, use the no form of this command.

offset-list {access-list-number | name} {in | out} offset [type number]

no offset-list {access-list-number | name} {in | out} offset [type number]


Syntax Description

access-list-number | name

Standard access list number or name to be applied. Access list number 0 indicates all access lists. If
offset is 0, no action is taken. For IGRP, the offset is added to the delay component only.

in

Applies the access list to incoming metrics.

out

Applies the access list to outgoing metrics.

offset

Positive offset to be applied to metrics for networks matching the access list. If the offset is 0, no
action is taken.
type

(Optional) Interface type to which the offset-list is applied.

number

(Optional) Interface number to which the offset-list is applied.

Defaults

This command is disabled by default.


Command Modes

Router configuration
Command History
Release

Modification

10.0

This command was introduced.

10.3

The type and number arguments were added.

11.2

The name argument was added.

Usage Guidelines

The offset value is added to the routing metric. An offset-list with an interface type and interface
number is considered extended and takes precedence over an offset-list that is not extended.
Therefore, if an entry passes the extended offset-list and the normal offset-list, the extended offset-
list's offset is added to the metric.
Examples

In the following example, the router applies an offset of 10 to the router's delay component only to
access list 21:

offset-list 21 out 10

In the following example, the router applies an offset of 10 to routes learned from Ethernet interface
0:

offset-list 21 in 10 ethernet 0

output-delay

To change the interpacket delay for RIP updates sent, use the output-delay command in router
configuration mode. To remove the delay, use the no form of this command.

output-delay delay

no output-delay [delay]
Syntax Description

delay

Delay, in milliseconds, between packets in a multiple-packet RIP update. The range is 8 to 50


milliseconds. The default is no delay.

Defaults

0 milliseconds
Command Modes

Router configuration
Command History
Release

Modification

10.0

This command was introduced.

Usage Guidelines

Consider using this command if you have a high-end router sending at high speed to a low-speed
router that might not be able to receive at the high speed. Configuring this command will help
prevent the routing table from losing information.
Examples

The following example sets the interpacket delay to 10 milliseconds:

output-delay 10

router rip

To configure the Routing Information Protocol (RIP) routing process, use the router rip command in
global configuration mode. To turn off the RIP routing process, use the no form of this command.
router rip

no router rip
Syntax Description

This command has no arguments or keywords.


Defaults

No RIP routing process is defined.


Command Modes

Global configuration
Command History
Release

Modification

10.0

This command was introduced.

Examples

The following example shows how to begin the RIP routing process:

router rip

Related Commands
Command

Description

network (RIP)

Specifies a list of networks for the Routing Information Protocol (RIP) process.

timers basic

To adjust RIP network timers, use the timers basic command in


#############################################################################
# name: main
# purpose: show regular expression usage
##############################################################################

# needed for regular expressions


import re

# matching (actually searching since match checks beginning only)


c = 'Someone, call 911.' # the string we want to match upon
mo = re.search(r'call',c) # mo is a match obj instance (or None)
s = mo.group(0) # s is 'call' - entire matched string
t = mo.span(0) # t is (9,13) - tuple of (start,end) pos
mo = re.search(r'Some(...)',c) # mo is a match obj instance (or None)
s = mo.group(1) # s is 'one' - mo.group(0) is 'Someone'
t = mo.groups() # t is ('one') - tuple of mo.group from 1 up
t = mo.span(1) # t is (4,7) - mo.span(0) is (0,7)
# global matching (get all found, like /g in perl)
i = re.finditer(r'.o.',c) # i is an iterator of all mo found
for mo in i: print mo.group(0) # will print 'Som' 'eon'
l = re.findall(r'.o.',c) # l is ['Som','eon'] - without mo, just strs
l = re.findall(r'o(.)(.)',c) # l is [('m','e'),('n','e')] - groups are ok

# substituting
g = "hello world" # the string we want to replace in
g = re.sub(r'hello','world',g) # g is now 'goodbye world'

# splitting
l = re.split(r'\W+',c) # l is ['Someone','call','911','']
l = re.split(r'(\W+)',c) # l is ['Someone',', ','call',' ','911','.','']
# pattern syntax (to make things short g0 is retval.group(0), g1 is group(1))
re.search(r'c.11',c) # . is anything but \n, g0 is 'call'
re.search(r'c.11',c,re.S) # S is singe-line, . will include \n, g0 is 'call'
re.search(r'911\.',c) # \ escapes metachars {}[]()^$.|*+?\, g0 is '911.'
re.search(r'o..',c) # matches earliest, g0 is 'ome'
re.search(r'g?one',c) # ? is 0 or 1 times, g0 is 'one'
re.search(r'cal+',c) # + is 1 or more times, g0 is 'call', * for 0 or more
re.search(r'cal{2}',c) # {2} is exactly 2 times, g0 is 'call'
re.search(r'cal{0,3}',c) # {0,3} is 0 to 3 times, g0 is 'call', {2,} for >= 2
re.search(r'S.*o',c) # matches are greedy, g0 is 'Someo'
re.search(r'S.*?o',c) # ? makes match non-greedy, g0 is 'So'
re.search(r'^.o',c) # ^ must match beginning of line, g0 is 'So'
re.search(r'....$',c) # $ must match end of line, g0 is '911.'
re.search(r'9[012-9a-z]',c)# one of the letters in [...], g0 is '91'
re.search(r'.o[^m]',c) # none of the letters in [^...], g0 is 'eon'
re.search(r'\d*',c) # \d is digit, g0 is '911'
re.search(r'S\w*',c) # \w is word [a-zA-Z0-9_], g0 is 'Someone'
re.search(r'..e\b',c) # \b is word boundry, g0 is 'one', \B for non-boundry
re.search(r' \D...',c) # \D is non-digit, g0 is ' call', \W for non-word
re.search(r'\s.*\s',c) # \s is whitespace char [\t\n ], g0 is ' call '
re.search(r'\x39\x31+',c) # \x is hex byte, g0 is '911'
re.search(r'Some(.*),',c) # (...) extracts, g1 is 'one', g0 is 'Someone,'
re.search(r'e(one|two)',c) # | means or, g0 is 'eone', g1 is 'one'
re.search(r'e(?:one|tw)',c)# (?:...) does not extract, g0 is 'eone', g1 is None
re.search(r'(.)..\1',c) # \1 is memory of first brackets, g0 is 'omeo'
re.search(r'some',c,re.I) # I is case-insensitive, g0 is 'Some'
re.search(r'^Some',c,re.M) # M is multi-line, ^ will match start of each line

Standard IO

##############################################################################
# name: main
# purpose: show some basic IO and file handling
##############################################################################

# copy textual lines from input file to an output file


fin = None # init fin (so cleanup will not throw)
fout = None # init fout for same reason
try: # file IO is "dangerous"
fin = open("input.txt","r") # open input.txt, mode as in c fopen
fout = open("output.txt","w") # open output.txt, mode as in c fopen
first = fin.readline() # read line with "\n" at end, "" (False) on EOF
print "First line:", line
for line in fin: # implements iterator interface (readline loop)
fout.write(line) # writes a string to a file
except IOError, e: # catch IOErrors, e is the instance
print "Error in file IO: ", e # print exception info if thrown
if fin: fin.close() # cleanup, close fin only if open (not None)
if fout: fout.close() # cleanup, close fout only if open (not None)

# read binary records from a file


from struct import * # needed for struct.unpack function
fin = None # init fin (so cleanup will not throw)
try: # file IO is "dangerous"
fin = open("input.bin","rb") # open input.bin in binary read mode
s = f.read(8) # read 8 bytes (or less) into a string
while (len(s) == 8): # continue as long as we have full records
x,y,z = unpack(">HH<L", s) # parse 2 big-end ushorts, 1 little-end ulong
print "Read record: " \ # print a long line
"%04x %04x %08x"%(x,y,z) # formatting similar to c printf
s = f.read(8) # read another record
except IOError: # catch IOErrors, no instance
pass # just continue on problem
if fin: fin.close() # cleanup, close fin only if open (not None)

# print a line without automatic new-line at end


print "without a new line",

# read entire file to memory at once


data = fin.read()

# format strings sprintf-style (% is a basic property of any str)


s = "%s has %d eyes" % (name,2)

# serialize and deserialize complex objects into files


import pickle # needed for serialization logic
ages = {"ron":18,"ted":21} # create a complex data structure
pickle.dump(ages,fout) # serialize the map into a writable file
ages = pickle.load(fin) # deserialize the map from a readable file

# navigating the file system and listing files (dir modules for more info)
import os # needed for basic OS interaction
print os.getcwd() # get current directory
os.chdir('..') # change current directory
import glob # needed for file globbing with wildcards
lst = glob.glob('*.txt') # get a list of files according to wildcard
import shutil # needed for file management tasks
shutil.copyfile('a.py','a.bak') # copy a file from source to destination

Useful Functions and Modules

##############################################################################
# name: main
# purpose: show some basic functions and useful modules
# notes: dir() and help() modules to navigate them from the interpreter
##############################################################################

# builtin functions (module __builtins__)


b = len('hello') > len([1,2,3]) # b is True since 5 > 3 (returns length)
print 'a is',chr(ord('a')) # ord converts chr to num, chr is opposite
i = int('38')+int('0x3a',16) # i is 96 (integer), long() func similar
print repr(96) # repr is a formal (eval) string rep
print str(96) # str is for user rep (optional in print)
print hex(58) # prints '0x3a'
l = map(hex,[10,20]) # run hex() on list, l is ['0xa','0x14']
l = range(0,10,3) # create lists, l is [0,3,6,9]
i = reduce(lambda x,y:x+y,[1,2,3,4]) # runs func as list reduces 10=((1+2)+3)+4

# import a module (echo) from a package (Sound.Effects) to current namespace


import Sound.Effects.echo # in code: Sound.Effects.echo.echofilter()
from Sound.Effects import echo # in code: echo.echofilter()
reload(echo) # reload imported module
from Sound.Effects.echo import * # in code: echofilter()

import sys # system specific parameters and functions


sys.exit("bye") # exit the program (raises SystemExit)
sys.path.append('c:\\') # module search path, init from PYTHONPATH

import math # math related operations


print math.sqrt(9) # print 3

import random # generate pseudo-random numbers


f = random.random() # random float in range [0.0,1.0)
i = randint(1,10) # random int in range [1,10]
print random.choice(['a','b']) # returns a random member of the sequence

from datetime import date # date and calendar related functions


a = date.today()-date(1981,11,21) # supports date arithmetics
print age.days # how old am i in days?

import zlib # compression related functions


c = zlib.compress("hello world") # c is a byte string (shorter hopefully)
print zlib.decompress(c) # prints "hello world"

# command execution in runtime


exec('x=1') # interpret new python code in runtime
y = eval('x+1') # evaluate an python expression and ret it

import os # operating system interface


os.system('del *.txt') # run commands in the shell (blocking)
os.startfile("calc.exe") # run commands in the shell (nonblocking)
stdin,stdouterr = os.popen4('dir /b') # returns file handles for child comm.
print stdouterr.read() # print the output, popen3 gives 3 streams

Po

Vous aimerez peut-être aussi