HCIP notes

HCIA review

OSI reference model----OSI/RM

application layer

presentation layer

session layer

Transport layer (port number: 0-65535; 1-1023 is the indicated port)

Network layer (IP address)

data link layer

physical layer

ARP protocol

Forward ARP --- Obtain the destination MAC address through the IP address

First, the host sends an ARP request in the form of a broadcast, requesting a MAC address based on a known IP address. All devices in the broadcast domain can receive the request packet, and all devices that receive the data packet will record the correspondence between the source IP address and the source MAC address in the data packet and store it in the local ARP cache table. After that, look at the requested IP address. If it is a local IP address, an ARP response will be made and the local MAC address will be notified. If it is not a local IP address, the packet will be discarded directly. Afterwards, when sending data, first check the local ARP cache table. If there is a record in the table, the information will be sent directly according to the record. If there is no record, then send the ARP request packet to obtain the MAC address.

Reverse ARP --- Get the target IP address through the target MAC address

Free ARP - use the principle of forward ARP to request your own IP address

1. Self-introduction

2. Detect address conflicts

 

TCP/IP

Four-layer model----TCP/IP standard model

Five-layer model----TCP/IP peer-to-peer model

PDU---protocol data unit 

L1PDU

L2PDU

...

L7PDU

Application layer----data message

Transport layer - data segment

Network layer - data packet

Data link layer ---- data frame

Physical layer - bit stream

Encapsulation and Decapsulation 

Application layer - there is an encapsulation process, depending on different applications

Transport layer----TCP, UDP (port number)

Network layer - encapsulation of IP address

Data link layer --- encapsulation MAC address

Physical layer----data has become an electrical signal, there is no encapsulation

Cross-Layer Encapsulation of TCP/IP 

Purpose: Improve the speed of encapsulation and decapsulation, and speed up the transmission efficiency

Cross-four-layer encapsulation ( STP protocol used between directly connected switches )----After the data encapsulation of the application layer is completed, the data of the network layer is directly encapsulated    

Applied between directly connected routing devices

Layer-3 and layer-4 encapsulation ( directly connected routers in the SPF protocol use layer-4 encapsulation ) --- Encapsulate layer-2 data directly after application layer encapsulation

Applied between directly connected switching devices

   

SOF --- frame delimiter ( equivalent to the preamble )

MAC sublayer - media access control layer - 802.3

LLC sublayer----logical link control layer----802.2

DSAP: identifies the module that the upper layer of the receiver processes data packets

SSAP: the module that identifies the upper layer of the sender to sort out data packets

Control: The module that determines how our data is transferred

1. No connection mode

2. Connection-oriented mode - control fragmentation, reorganization, sorting

IP address 

IPv4 version --- 32-bit binary --- dotted decimal: divide 32-bit binary into 4 parts, each part is 8 bits, and convert binary to decimal

IPv6 version --- 128-bit binary --- hexadecimal

Network bit: the same network bit means they are in the same broadcast domain

Host bits: In the same broadcast domain, use host bits to distinguish different hosts

Mask: Consisting of consecutive 1s and consecutive 0s, 1 represents network bits and 0 represents host bits.

IPv4 address classification (classful addressing) 

       Unicast address---one-to-one communication

Features: It can be used as both source IP address and destination IP address

Multicast address---one-to-many

Broadcast address---one-to-all (used only as destination IP address)

A: Mask: 255.0.0.0

B: Mask: 255.255.0.0

C: mask: 255.255.255.0

D---Multicast address----can only be used as the target IP address, not as the source IP

E --- reserved address

IP address classification principle: Classify according to the first eight digits of the binary IP address

A:0XXX XXXX-----0-127

B:10XX XXXX-----128-191

C:110X XXXX-----192-223

D:1110 XXXX-----224-239

E:1111 XXXX-----240-255

special IP address

1. 127.0.0.1-127.255.255.254----loopback address----local test

2. 255.255.255.255---restricted broadcast address

3. The host bits are all 1 --- 192.168.1.255/24 --- direct broadcast address

Difference: Restricted broadcast addresses are not forwarded by routers, while direct broadcast addresses are forwarded.

4. The host bits are all 0---192.168.1.0/24----network

5. 0.0.0.0----represents no IP address, or represents all IP addresses

6. 169.254.0.0/16----link-local address/automatic private address

Note: This IP address cannot communicate across network segments----Ethernet environment

VLSM----variable length subnet mask    idea: borrow bits from host bits to network bits.

192.168.1.0/24

192.168.1.0 000 0000/25---192.168.1.0/25

192.168.1.1 000 0000/25---192.168.1.128/25

CIDR----classless inter-domain routing    idea: take the same, go different

192.168.0.0/24

192.168.1.0/24

192.168.2.0/24

192.168.3.0/24

192.168.0000 0000.0

192.168.0000 0001.0

192.168.0000 0010.0

192.168.0000 0011.0

192.168.0.0/22----Supernet

172.16.0.0/24

172.16.1.0/24

172.16.2.0/24

172.16.3.0/24

172.16.0.0/22----subnet summary

DHCP service ---Dynamic Host Configuration Protocol

DHCP Discover---Broadcast

The forwarding principle of the switch:

After the switch receives the electrical signal, it converts the electrical signal into binary, and then intercepts the data frame.

Check the source MAC address of the data frame, and then record the corresponding relationship between the address and the interface where the data enters in the local MAC address table---300s.

After that, look at the destination MAC address in the data frame, and query the local MAC address table based on the destination MAC address. If there is a record relationship in the table, it will be forwarded according to the record; if there is no record relationship in the table, it will be flooded (the switch will send the data to Send once from all interfaces except the incoming interface)

Three cases of switch flooding:

1. Encountered a broadcast frame

2. Encountered a multicast frame

3. Unknown unicast address encountered

DHCP ack message----broadcast/unicast

DNS service ---Domain Name Resolution Protocol

URL---resource delimiter, it is different from domain name

Agreement + website domain name information + file path

Purpose: Obtain the corresponding IP address through the domain name

DNS port number ------53---TCP/UDP

DNS query process

Router forwarding principle

Principle: The router will query the local routing table based on the destination IP address in the data packet. If the record is saved in the routing table, it will be unconditionally followed by the record

Forward; if there is no record, the packet will be discarded directly.

Get information about unknown network segments

1. Directly connected routing: The router generates routing entries for directly connected network segments with available interfaces by default.

2. Static routing: manually configured by the network administrator

3. Dynamic routing: All routers run the same routing protocol, and then routers communicate with each other to calculate routing information for unknown network segments

Conditions for generating direct routes

1. Interface double UP

Physical layer UP: indicates that the link is normal

UP at the protocol level: means having a communication protocol

2. The interface must be configured with an IP address

HTTP protocol - hypertext transfer protocol

TCP---80

Hypertext --- contains text marked with hyperlinks and multimedia elements

TCP protocol

It is a connection-oriented reliable transport protocol

reliability

Confirmation mechanism: transmission confirmation, each time a data segment is received, a confirmation is required

Retransmission mechanism: the optimal mechanism to ensure reliability. When a packet in a data segment is lost, it will remind you to retransmit the message

Sorting mechanism: When a data segment is transmitted, it is divided into multiple packets, so that they are transmitted through different paths, and the order of the final destination will be disrupted, so reordering is required. According to the sequence number field in the TCP packet.

Flow control mechanism: sliding window mechanism - adjust the window size to control the flow

MSS=MTU-TCP header-IP header (in the option field of the TCP protocol)

PMTU----Path MTU Discovery Protocol

In the IP header, there is a field called DF, which indicates whether the IP packet is allowed to be fragmented. After the PMTU function is enabled, this field will be set to 1, indicating that fragmentation is not allowed.

At this time, when fragmentation is required, if the packet is found to be unfragable, the device will discard the packet, and send an ICMP packet (data unreachable) to the sender, and at the same time record the MTU value of the current device interface.

After receiving the ICMP message, the sender will resend the data due to the TCP retransmission mechanism, but will also generate a new message for transmission according to the new MTU value.

TCP connection-oriented

three handshake

1XX---100---notification information

2XX----200---Success

3XX----300---redirection

4XX---403---Customer Error

5XX---500---Server Error--503

static route

Advantages of static routing:

1. Reasonable route selection, manually configured by the network administrator ( selected by a person, with comprehensive consideration )

2. Security , the calculation of dynamic routing protocols requires the exchange of data packets between routers

3. No need to occupy additional device resources

Disadvantages of static routing:

1. Large amount of configuration

2. Cannot automatically converge based on topology changes

Basic Static Routing Configuration

Method 1: [r1]ip route-static 23.0.0.0 24 12.0.0.2- ---- Need to recursively find the outbound interface 

Method 2:  [r3]ip route-static 12.0.0.0 24 GigabitEthernet 0/0/0  needs to activate proxy ARP

          Solution: enable the ARP proxy function on the incoming interface of the next router

[r2-GigabitEthernet0/0/1]arp-proxy enable 

Proxy ARP idea: After receiving the ARP packet, the router will check the local routing table, if there is a destination IP address in the local router

At this time, the router will pretend to be the destination IP address to answer the ARP message.

Method 3: [r1]ip route-static 192.168.2.0 24 GigabitEthernet 0/0/1 12.0.0.2   No need for recursive search

Method 4: [r3]ip route-static 192.168.1.0 24 12.0.0.1   needs to pave the way for all routing items in the recursive routing search process in advance.

Extended configuration of static routing

Load balancing  : When a router has multiple paths with similar costs when accessing the same target, the traffic can be split and then go through multiple paths at the same time to achieve the effect of superimposing bandwidth

Manual summary  : When the router can access multiple consecutive subnets, if they all pass the same next hop, these network segments can be summarized and counted.

For calculation, just write a static route to the summary network segment directly. It can reduce the number of routing table entries and improve forwarding efficiency.

Routing black hole: In the summary, if a network segment that does not actually exist in the network is included, it may cause traffic to go without return, wasting link resources. Reasonable division and aggregation can reduce the generation of routing black holes

Default route: a route that does not limit the destination. When looking up the table, if none of the routes match, the default route will be matched.

Empty interface routing:

To prevent the route black hole from meeting the default route and going out of the loop, configure a route on the black hole router that reaches the summary network segment and points to an empty interface.

1. NULL0---If the outbound interface of a routing entry points to a null interface, the datagram matching this routing information will be discarded

        2. The matching principle of the routing table---the longest matching principle (exact matching principle)

Floating static routing: By modifying the default priority of static routing, the effect of backup is achieved

Static route and BFD association

   

BFD: Bidirectional forwarding detection is a unified detection mechanism for the entire network, which is used to quickly detect and monitor the forwarding connectivity status of links or IP routes in the network .

Static routes require a large amount of configuration, but cannot be automatically converged. In the figure, R1 configures a static route to reach the loopback of R4. Originally, load balancing should be configured, but here it is configured as a floating static route. Normally, the left link is used, and the right link is used when a fault occurs.

If the link between R1 and LSW1 is broken or LSW1 fails, can it be switched to the link on the right? Can

If the link between R2 and LSW1 fails, it cannot be switched to the link on the right, how to solve it?

    R1 cannot perceive the link between R2 and LSW1, but can only perceive the link between LSW1 and R1 including LSW1. If the switch is broken, then LSW1

The 0/0/1 interface of R1 will be down, and the 0/0/0 interface of R1 will be down, and R1 will know. For example, the 0/0/0 interface of R2 hangs up, only LSW1

0/0/2 will become down, which cannot affect the link between LSW1 and R1. R1 cannot detect the link between R2 and LSW1, and cannot switch to the right link. That

Is there any way to perceive it? Using BFD, BFD detection mechanism: The detection mechanism of BFD is that two systems establish a BFD session and follow the path between them

Periodically send BFD control packets, if one party does not receive BFD control packets within a predetermined time, it is considered that a fault has occurred on the path. OSPF protocol uses

The hello packet ensures the existence of neighbors. Send an empty message to the neighbor, and the reply will exist. If there is no reply, it will be fine. It can also detect faults, so why do we need BFD and OSFP?

Linkage, let BFD help?

    OSPF 10S sends a hello packet to keep alive, but if the OSPF network suddenly has a sudden structural change after the convergence is completed, at least DR/BR must be elected.

Even in a point-to-point network, it takes a few seconds to collect topology information, and then it takes time to complete the topology calculation. However in some areas

domain, requires fast convergence, reduces the impact of equipment failures on services, and improves network reliability.

Communication failure, so that measures can be taken in time to ensure the continuation of business. The minimum sending time of OSPF hell packet is changed to 1s, but BFD can implement ms convergence

 The configuration in the picture:

[R1]ip route-static 10.9.9.0 24 10.1.12.1

[R1]ip route-static 10.9.9.0 24 10.1.23.1 preference 90

[R2]ip route-static 0.0.0.0 0 10.1.134.3

[R3]ip route-static 0.0.0.0 0 10.1.134.3

    [R4]ip route-static 10.1.12.0 24 10.1.134.1

[R4]ip route-static 10.1.23.0 24 10.1.134.2

R2 closes the 0/0/0 interface, checks the table, and R1 does not switch to the right link

First delete [R1]ip route-static 10.9.9.0 24 10.1.12.1 , and then configure BFD

BFD configuration

[R1]bfd //Start the BDF protocol

[R1]bfd aa bind peer-ip  10.1.12.1 (peer IP address ) --- create a bfd session, the session name is aa (only local meaning)  

[R1-bfd-session-aa] discriminator local 20 --- session local identifier                                      

[R1-bfd-session-aa]discriminator remote 10  ---Session peer identifier 

[R1-bfd-session-aa]commit -- the configuration must be submitted, otherwise it will not take effect 

[R1]ip route-static 10.9.9.0 24 10.1.12.1 track bfd-session aa link static routing and BFD

[R1]display bfd session all  View all BFD sessions

BFD needs to be configured on both sides, the configuration of R2:

[R2]bfd

[R2]bfd bb bind peer-ip 10.1.12.2

[R2-bfd-session-bb]discriminator local 10

[R2-bfd-session-bb]discriminator remote 20

[R2-bfd-session-bb]commit

Grab the 0/0/0 interface of R2 and find that sending a BFD packet does not even take 1S

Check to see if it can be switched: LSW1-GigabitEthernet0/0/2]shutdown

 It means that the BFD status is down

[R1]display bfd session all View all BFD sessions

At this time, the route with priority 90 is loaded, and R1 switches to the link on the right                              

How to judge that R1 and R2 are really unable to communicate and switch routes?

By default (that is, by default), the bfd session sends a message every 1000ms (can be modified), and when there is no response to the message for three consecutive times (can be modified), the state of the bfd session is disconnected, thereby causing linkage Agreement lapsed.

[ R 1-bfd-session-bb]min-rx-interval 10 --- Configure the interval for receiving BFD packets as 10 milliseconds

[ R1 -bfd-session-bb]min-tx-interval 10 --- Configure the BFD packet sending interval to 10 milliseconds

[ R 1-bfd-session-bb]detect-multiplier 10  ---Configure the local detection multiplier to 10 (changeable range 3-50) , that is, if the BFD message is not received ten times, it will be considered a failure

Network type and data link layer protocol

The network type is divided according to the protocols and rules run by our data link layer.

Classification of Network Types

P2P----point to point---point to point

MA---multipoint access network

BMA---Broadcast Multipoint Access Network

NBMA - non-broadcast multipoint access network

Data Link Layer Protocol

MA network

ethernet protocol

Features: Need to use MAC address to distinguish and identify our equipment

Reason: (Why Ethernet needs to use MAC address for physical addressing)

A Layer 2 network established using the Ethernet protocol can contain multiple interfaces, and each Ethernet interface can exchange Ethernet data frames for communication. If there is no MAC address, the corresponding received data cannot be found. Frame device.

Type------BMA

The construction method of the Ethernet network ----- use the Ethernet cable to connect the Ethernet interface of the device, and the formed network is called the Ethernet network.

The protocol is the Ethernet protocol.

Features of Ethernet - can provide a huge transmission rate - frequency division technology

P2P network

Definition: When only two devices can exist in a network, and the third device is not allowed to join, such a network is called a P2P network.

The construction of P2P network - use the serial port cable to connect the serial interface of the device to form a network

Serial cable----a relatively ancient cable, one of the main cables used in the early days

Serial port standard:

E1----2.048M/bps

T1----1.544M/bps

HDLC 

High-Level Data Link Control----High-Level Data Link Control Protocol

standard:

HDLC protocol that meets industry standards--ISO organization (IBM Corporation--SDLC--is a bit-oriented synchronous data link control protocol--transmits data in units of frames)

Does not meet the HDLC protocol marked by the industry --- various manufacturers modify the HDLC according to the ISO standard

Note: Standard HDLC and non-standard HDLC are not compatible with each other. (Cisco, Ruijie)

HDLC network construction

[ R 1-Serial4/0/0]link-protocol hdlc //Modify the network type to HDLC

Address: The unicast is written, which means there is no content to fill in, because the point-to-point network actually does not need an IP address to communicate, and the reason for configuring the IP address is only to serve the upper layer protocol.

Control: It was originally used for some strategies, but this field is not reserved in the current serial network, and it is filled with 0

protocol: Indicates the type of the upper layer encapsulation protocol, similar to the type field in the Ethernet protocol

HDLC interface address borrowing

[ R 1-Serial4/0/0]ip address unnumbered interface LoopBack 0  -- borrow the IP address of loopback 0

[ R 1]ip route-static 12.0.0.0 24 Serial 4/0/0 --- The reason for not writing the next hop is that 1. If the next hop is written, recursive routing is required; 2. Because the interface does not have IP address, so a direct route to the next hop cannot be generated.

In the end, it is necessary to supplement the static routing information of the peer device on both devices to ensure that the data can be forwarded through table lookup .

Configure the IP address of the loopback interface as the address on the same network segment as the IP address of the peer interface, and set the mask to 32 .

PPP - point to point protocol 

Advantages of PPP agreement 

1. Compared with HDLC, PPP protocol has good compatibility. Unified standard protocol (any serial interface or serial cable, as long as it can support full-duplex communication, it can support PPP protocol)

2. It has good portability. ----PPPoE

3. Authentication and authorization can be completed.

4. No retransmission mechanism, low overhead and fast speed

  Establishment of PPP session

The PPP protocol needs to go through three stages to establish a session

Link establishment phase ---- LCP protocol

Certification stage ---------- PPP certification (optional)

Network layer protocol negotiation phase ---- NCP negotiation

PPP link establishment phase

Dead stage ---- known as the physical layer unavailable stage

When the two ends of the communication detect that the physical link is activated, they will transition from the dead phase to the Establish phase.

Establish phase ---- LCP parameter negotiation will be carried out

At this stage, when the LCP parameters are negotiated successfully, it will enter the opened state, indicating that the underlying link has been established.

Authenticate phase----In most cases, the devices at both ends of the link need to go through the authentication phase before entering the network layer protocol negotiation phase.

By default, PPP links do not require authentication

If authentication is required, an authentication protocol must be specified during the link establishment phase.

The authentication mode is negotiated during the link establishment phase of both parties.

Network phase----PPP link for NCP negotiation

A network layer protocol is selected and configured through NCP negotiation, and parameters of the network layer protocol are negotiated.

Only after the negotiation of the corresponding network layer protocol is successful, the network layer protocol may be sent through this PPP link.

After the NCP protocol is successful, the PPP link will remain in the communication state

If the physical link is disconnected, the authentication fails, the timer expires, the connection is manually closed, etc. during the operation of PPP, the link will enter the Terminate stage.

Terminate phase ---- the phase of link closure

If all link resources have been released at this time, both communication parties will return to the initial state of Dead until the two parties re-establish the PPP connection.

PPP data frame structure

      LCP protocol ----- link control protocol --- is mainly used to complete the first phase negotiation process of PPP session establishment

NCP protocol-----Network Control Protocol------is a general term for a series of protocols, which is carried out for the network layer protocol when the third phase of PPP session establishment is completed.

negotiate. The protocols used by the network layer are different, and the corresponding NCP protocols are different.

LCP has three message types

Link configuration message----important

link termination message

Terminate-Request: terminate the request

Terminate-ACK: Terminate acknowledgment

link maintenance message

echo-request------echo request

echo-reply---------- echo reply

LCP established

1. MRU value: the maximum data unit allowed in a PPP data frame, unit byte, default 1500

2. Authentication method: Judging according to the second-stage authentication, if there is authentication, the authentication method needs to be negotiated; if there is no authentication, no negotiation is required.

3. Magic word: used to detect whether there is a loop in the link, it is a string randomly generated by the local device (device serial number, hardware address)

OSPF basics

 OSPF seven state machines

down --- closed state --- once the OSPF protocol is started, the hello packet is sent and enters the next state

init----initialization state----in the received hello packet, if there is its own RID value, it will enter the next state

2-way--two-way communication status----- the sign of the establishment of neighbor relationship .

Condition matching: If the match is successful, it will enter the next stage, if it is not successful, it will stay in 2-way

exstart----pre-start state----use the DBD package without information to carry out the master-slave relationship election, and the one with the larger RID is the master

exchange-----quasi-exchange state--use DBD message carrying directory information for directory sharing

loading------loading status-----neighbors use LSR/LSU/LSAck three kinds of messages to obtain complete TOPO information

full----forwarding status----repair is a positive result------ marks the establishment of the adjacency relationship

condition match

     device interface name

     DR---designated router

     BDR---Backup Designated Router

    DRother----other routers

OSPF calls the condition of adjacency

   Point-to-point - no need to elect DR and BDR - directly start to establish adjacency relationship (method to speed up convergence)

   MA network----In a network, there is no limit to the number of nodes (DR and BDR will be elected)

election rules

    Interface priority ----->0-255---->The greater the priority, it is DR, and the next level is BDR (Huawei defaults to 1)

    RID - the bigger the priority

   Election scope----a broadcast for a conditional match between roles

In a broadcast domain, all devices maintain adjacency, and there will be a large number of repeated updates, so DR/BDR elections are required, and all non-DR/BDR devices only need to maintain neighbor relationships

   DR and DRother---->Adjacency

   DR and BDR---->Adjacency

   BDR and DRother---->Adjacency

   DRother and DRother---->neighbor relationship

1. In a broadcast domain, if DR and BDR are available, at least four routers are required to see the neighbor relationship

2. The designated router is selected for a broadcast domain, so it is actually an interface concept

   non-preemptive election mode

electoral process

1. The election of DR and BDR is implemented through Hello packets, and the election process occurs after the 2-way state

2. The router fills in the "DR Priority" field in the hello packet with the DR priority of its own interface

3. You can modify the DR priority in the interface view (if the DR priority is changed to 0, it means that you are not eligible for DR and BDR elections)

4. When the router interface activates OSPF, it first checks whether there is a DR device on the network, and if it exists, it will accept the DR role. if not

exists, the device with the highest DR priority is called DR (RID)

5. The BDR election process is the same as the DR election process, but after the DR election is successful.

The DR device uses multicast 224.0.0.5 to send messages to the MA network.

And DR and BDR use 224.0.0.6 to monitor the news of the MA network.

DROther uses 224.0.06 to send its own LSU message

 

Exists in NBMA network types.

On an NBMA network, if OSPF needs to be enabled, neighbors need to be specified manually; otherwise, hello packets will not be sent.

If no hello message is sent, the neighbor state is in the attempt state

 1. Start OSFP After the configuration is complete, OSPF will multicast 224.0.0.5 to all local interfaces running the OSPF protocol to send hello packets; the hello packets carry the local RID and the locally known neighbor RID; then generate a neighbor table.

2. After the neighbor relationship is established, conditional matching is performed; if the match fails, it stays in the neighbor relationship; only the hello message is kept alive

 3. Neighbors that match successfully will start to establish adjacency.  

4. First use the DBD message without data to carry out the master-slave relationship election; then use the DBD message with data to share the database directory; then use the LSR/LSU/LSACK message locally to obtain unknown LSA information;

5. Complete the establishment of the local database --- generate database tables.

6. After that, the directed graph and the shortest path tree are generated locally based on the database, and then the shortest path to all unknown network segments in the local topology is calculated.

 7. Path, and add it to the routing table.

The convergence is complete, and the hello packets are periodically kept alive. Periodically updated every 30 minutes   

Structural mutation

1. Adding a new network segment - use the LSU to update directly on the interface of the adjacency relationship, and tell the content to the neighbors. And need the neighbor's ACK confirmation.

2. Disconnect the network segment - use the LSU to update directly on the interface of the adjacency relationship, and tell the content to the neighbors. And need the neighbor's ACK confirmation.

3. Unable to communicate----dead time----four times the hello time.

1. Start the OSPF process [r1] ospf 1 router-id 1.1.1.1 //The process ID only has local meaning, manually configure the RID method

2. Create area [r1-ospf-1]area 0

3. Declare

      [r1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0 //Accurate declaration

      [r1-ospf-1-area-0.0.0.0]network 12.0.0.0 0.0.0.255 //declare the network segment

      Declare the use of the unmasked form

     OSPF announcements use reverse masks to achieve accurate announcements, that is, to announce the specific interface IP address to activate the specified interface, or to announce the directly connected network segment to activate the interface.

  32-bit binary, expressed in dotted decimal notation. Continuous 0+ continuous 1; and 0 means immutable; 1 means variable

 

 

 

In the Huawei system, the priority is 10;

OSPF COST====reference bandwidth (100Mbps)/actual bandwidth

[r1-ospf-1]bandwidth-reference 1000 //Modify the reference bandwidth-----all devices need to be modified

The cost of an OSPF path is equal to the sum of the inbound interface costs of all devices along the path from the destination to the local router .

OSPF packet format

OSPF packet header

Version (Version)

For OSPFv2, the value of this field is always 2

type

     Describes the type of OSPF packet

     Hello------1

     DBD-------2

     LSR--------3

     LSU--------4

     LSACK----5

Packet Length

       The length of the entire OSPF message ----- unit byte

router-id

        The RID value of the router that sent the packet

area ID

       The ID value of the area to which the interface sending the packet belongs

checksum

        Verify the validity of OSPF overall data packets

authentication type

        Indicates the type of authentication used by the message

        No authentication ---0; simple authentication ---1; MD5 authentication ---2;

authentication data

      The content to be compared for message authentication

      If the authentication type is not authenticated, this field is filled with 0

The authentication function of OSPF exists in all data exchange processes, and any kind of data packet needs to be authenticated.

During the authentication process, two fields need to be compared, and the authentication type field is first compared.

     If they are the same, the authentication data fields will be compared.

Network Mask

     This field is filled with the netmask that sends the message

     If two OSPF routers are directly connected through Ethernet interfaces , the directly connected interfaces on both sides must be configured with the same network mask.

  (Point-to-point network does not need to compare this parameter)

     Note: The need to compare the subnet mask information for OSPF to establish a neighbor relationship is unique to Huawei, and other manufacturers do not have this requirement .

Hello Interval

The two directly connected routers need to ensure that the Hello intervals       of the directly connected interfaces are the same; otherwise, the neighbor relationship cannot be established .

      By default, for P2P and BMA, it is 10S; for P2MP and NBMA, it is 30S.

Options

        This field has a total of 8 bits, and each bit is used to indicate a specific OSPF feature of the router.

        During the establishment of the OSPF neighbor relationship, some bits in this field will be checked, which may affect the establishment of the OSPF neighbor relationship. (marking of special areas)

router priority

     [r2-GigabitEthernet0/0/0]ospf dr-priority ? //Modify the DR priority of the OSPF interface

    INTEGER<0-255> Router priority value

Router Dead Time

         To establish an OSPF neighbor relationship between two directly connected routers, it is necessary to ensure that the dead time of the two interfaces is the same, otherwise the neighbor

         Relationships cannot be established normally.

         The default time is 4 times of hello.

designated router

        Interface IP address of the DR device on the network.

        If there is no DR or DR is not elected, fill in 0.0.0.0

Backup Designated Router

           Interface IP address of the network BDR device

           If there is no BDR or the election is not over, fill in 0.0.0.0

Neighbor

        Valid neighbors found on the direct link, filled here is the RID value of the neighbor, if multiple neighbors are found, it contains multiple

        neighbor field.

All multicast addresses in 224.0.0.X format are called link-local multicast, and the TTL value in the packet whose destination IP address is link-local multicast is set to 1 . All local link multicast will have a corresponding multicast MAC address, 01-00-5e- last 24 digits ( last 24 digits of multicast IP address )

 subnet mask

        

        

          

After modifying the netmask on R2, R2 will immediately change the state of R3 to Down. And R3 will switch state after 40S death time.

The reason is that after R2 modifies the mask of the IP address, it will think that the previous connection is interrupted and the connection needs to be re-established, so the state machine is reset.

 And R3 thinks it is unable to communicate. Therefore, it will wait for the death time to expire before switching the state.

Moreover, in this case, R3 can still forward data to R2 during the waiting period of 40S, and R2 can receive the data packet, but cannot reply

hello time
[r1-GigabitEthernet0/0/0]ospf timer hello 20
Dead time
[r1-GigabitEthernet0/0/0]ospf timer dead 120
Note: If you modify the hello time, the death time will change accordingly, but if only the death time is modified, the hello interval will remain unchanged .
OSPF special area marking
Same effect as modifying the mask.
authentication field
      Both need to wait for the death time to expire before switching from the full state to the down state.
DBD package
*Use DBD messages       without data for master-slave election
*Use DBD messages      carrying data for directory information sharing
*Use the DBD message      without data to confirm

★Interface maximum transmission unit (interface MTU) 

     Huawei sets the value to 0

      Huawei does not detect the MTU value by default

      [r1-GigabitEthernet0/0/0]ospf mtu-enable

      If this function is enabled on both sides, MTU detection will be performed, and when the detection is performed, if the two sides are different, the state will be stuck in the exstart state.

★I bit----master-slave relationship election

If this bit is 1, no LSA header will be carried.

★M bit----represents whether there are multiple DD messages in the follow-up

If it is set to 1, it means that there will be DD packets in the future

If it is set to 0, it means that the message is the last DD message

★MS bit----represents the master device

If the bit position is 1, it means Master

Before the election of the master-slave relationship is completed, each device will consider itself the master.

★DD serial number

    It is used to ensure the orderly and reliable transmission of DD packets. ----DD serial number increments by 1.

    The DD serial number must be determined by the Master router, and the slave device can only use the DD serial number sent by the Master device to send its own DD message. (implicit confirmation mechanism)

★LSA head

     When a router uses DD packets to describe its LSDB, the LSA header information is included.

     A DD packet can contain one or more LSA header information.

 LASCK bag

   

1. OSPF usually sends hello packets, LSU packets, and LSACK packets in multicast mode on BMA network interfaces . by
      Send DD packets and LSR packets in the form of unicast

2.  OSPF sends all protocol packets in multicast mode ( 224.0.0.5 ) on the interface whose network type is P2P . And OSPF will not elect DR and BDR in P2P network .

In the interface type information, the description information of DR priority, DR and BDR         seen in the BMA network is missing .

      [r2]display current-configuration configuration ospf // View all information about OSPF in the current configuration

3. Loopback interface (virtual interface)

   Type----P2P----- There is a specially defined Loopback type in Cisco as the type of loopback interface, but it is not defined in Huawei, and it is filled with P2P (meaningless).
    All the routing mask information of the loopback interface learned through OSPF is 32 bits, this is because the loopback interface is a simulated interface, it does not actually connect users, so no other IP addresses exist on the loopback interface Below, there is only one IP address available , so a 32 -bit mask is used to directly identify the loopback interface. Ensure the accuracy of routing information. ---- Avoid loops or routing black holes.

4. P2MP interface type

  

   1. On a P2MP interface, OSPF usually sends hello packets in multicast mode and other messages in unicast mode.

   2. The P2MP type cannot be automatically generated by the device and must be manually changed by the administrator.
   3. P2MP type network does not need to elect DR and BDR .
OSPF Irregular Areas
     non-backbone area away from the backbone 
  

 1. Use the tunnel tunnel: build a tunnel between R2 and R3, and then declare the tunnel to Area0, which is equivalent to legalizing the illegal ABR device R3.

2. Use vpn tunnels to solve the problem of irregular areas: poor route selection may occur/repeated updates may occur/because of the existence of virtual links, neighbors need to be established between R2 and R3. The periodic data maintained between them will pass through Area1, resulting in excessive resource consumption in the middle area.

3. Virtual link---Vlink

      A technology specially developed to solve OSPF irregular areas. It is a virtual and logical link.

      [r2-ospf-1-area-0.0.0.1]vlink-peer 3.3.3.3

      [r3-ospf-1-area-0.0.0.1]vlink-peer 2.2.2.2

     Configuration conditions of the virtual link: only one area can be traversed.

     In fact, all Vlink links use unicast packets to describe information.

     Vlink is regarded as an extension of the backbone area——vlink always belongs to Area0.

    Use vlink to solve the problem of irregular areas:

       1. Due to the existence of virtual links, neighbors need to be established between R2 and R3. The periodic data maintained between them will pass through Area1, resulting in excessive resource consumption in the middle area.

      2. Can only pass through one area. In fact, vlink is not only applied to the above two irregular areas, but also can be used to repair some suboptimal paths or unrobust problems in the backbone area.

4. Use multi-process two-way redistributing

     Redistribution: publish a routing information in another routing protocol.

    [r3-ospf-1]import-route ospf 2 --- import the route of OSPF process 2 to OSPF process 1

OSPF LSA Detailed Explanation
   LSA header
   

   

Link state aging time (Link-State Age)

16bit, unit S

When the LSA is generated by the originating router, the value is set to 0, and then the aging time gradually accumulates as the LSA is flooded in the network.

Maximum Aging Time--3600S-----When this time is reached, the LSA will be deleted by the local router.

On an OSPF network, only the originating router can age the LSA in advance and delete the LSA information on the entire network.

group pacing timer ----cisco----240S

optional

The content is the same as the hello package

Link State Type (Link-State Type)

Indicates the type of the LSA

Link State ID

Different types of LSAs used to identify LSAs have different definitions of this field.

advertising router

RID of the router that originated the LSA

link state serial number

32 bits, incremented one by one

Start: 0X80000001; End: 0X7FFFFFFF

serial number space

linear serial number space

circular sequence number space

lollipop serial number space

checksum

Will participate in the comparison of old and new relationships in LSA

Determine the old and new relationship of LSA

    Link state serial number, aging time, checksum

           1. LSA information with higher sequence number is better

           2. For LSAs with the same sequence number, select the LSA with the larger checksum

          3. With the same sequence number and checksum, if the aging time of an LSA is set to the maximum aging time, the LSA is considered to be the latest.

         4. With the same serial number and checksum, no aging time of any LSA is the maximum aging time, and the difference between the aging times of the two LSAs will be compared.

                 1. When the difference is greater than 15 minutes (MaxAge Diff: the longest time required for an LSA instance to be sent from the originating device until it is flooded to the entire AS boundary), the two LSAs will be considered different, and the smaller LSA will be selected

                2. When the difference is less than or equal to 15 minutes, the two LSAs will be considered the same, and a random one will be selected

             

             

Type-1 LSA----Router

              1. For a type of LSA, all devices in the network will send, and only one

             2. The interfaces that belong to the same area share a type-1 LSA information for description.     

               If there are multiple areas, the router will generate a type-1 LSA for each area, and each LSA only describes the interface connected to the area.

             

                

 Type-2 LSA----Network

          1. In a network, only one device is required to send
          2.该 LSA 仅存在于 MA 网络中,由 DR 设备产生
          3.链路状态ID DR 的接口 IP 地址
           

Type-3 LSA---Sum-Net
        1.通告者均为 ABR 设备
        2.每一条路由项都使用单独的一条 LSA 信息进行描述
        3.该 LSA 中的开销值,指的是通告者到达目的网段的开销值
        4.设备在接收到 3 LSA 之后,需要根据一类 LSA 和二类 LSA 计算的拓扑信息来寻找三 LSA  的通告者。
        5.如果,通告者是所在区域的 ABR 设备,那么自然而言,设备可以通过一类和二类 LSA 找到
通告者; 若不是本区域的ABR 设备通告的,则需要转换通告者。
         

Type-5 LSA----External

       1.通告者---ASBR

       2.LS ID----域外路由信息的目标网络号

       3.传播范围----整个OSPF域

      4.五类LSA中携带的是域外路由信息,通过重发布导入OSPF网络,因为不同协议对开销值的 算法标准不同,所以,在路由导入之后,将直接舍弃原本的开销值,之后给路由赋予一个规定值-----种子度量值

           OSPF的种子度量值为1

          [r4-ospf-1]import-route rip 1 cost 5

      5.E位

             * 示外部路由使用的度量值类型,OSPF定义了两种外部路由度量值类型,分别为Metric-Type-1(E=0)、Metric-Type-2(E=1)

             * Type-1:所有设备到达域外目的网段的开销值为本地到达ASBR的开销值+种子度量值

            * Type-2:域内所有设备到达域外目的网段的开销值等于种子度量值;OSPF默认使用类型                               2.

            *[r4-ospf-1]import-route rip 1 cost 5 type 1

6.外部路由标记

*一个只有外部路由才能携带的标记,经常被用于部署路由策略或策略路由。

*在华为路由器上,缺省时,该字段值被设置为1。

7.转发地址---FA

FA字段默认为0.0.0.0;则到达该外部网段的流量会被转发引入到发送这条LSA的ASBR设备。

而若FA字段不为0.0.0.0,则流量会被发送给这个FA字段所表示的地址。

作用:解决次优路径问题-----与ICMP中的重定向报文具有相同效果。

FA字段被设置为其余数值的条件:

*引入外部路由的ASBR在其连接外部网络的接口上激活了OSPF协议。

*该接口的网络类型为BMA或者NBMA。

*该接口的IP地址属于OSPF协议配置network命令范围。

*该接口没有被配置为静默接口

Type-4 LSA------ Sum-Asbr

  • 链路状态ID------ASBR的RID值
  • 度量值----填写的是该通告者到达ASBR的Cost值
  • 四类LSA的任务就是在辅助五类LSA完成验算过程,找到ASBR的位置,里面只携带一个开销 值。
Type-7 LSA----NSSA
     1. E位----表示允许洪泛五类LSA信息,如果做成特殊区域,则E位为0
     2.N位---属于opention字段,允许处理七类LSA
     3. P位---不属于opention字段,代表支持7转5操作。
     4.在7类LSA中,在不存在选路不佳的情况下,一般会使用通告者(ASBR)设备的环回接口地
址作为 转发地址。
                * 如果存在多个环回接口,则使用最先宣告的环回接口地址作为转发地址。
                *如果没有环回接口,则使用武力接口的地址作为转发地址。
                *华为逻辑-----cisco---选择最后一个宣告的IP。
路由撤销
      一类 LSA 撤销
            一类 LSA 实质是是在通过:序列号 +1 ;校验和不变;老化时间 =0 的新 LSA 来覆盖掉老的一              类  LSA
       二类 LSA 撤销
            与一类 LSA 玩法相同
       三类 LSA 撤销
            1.三类 LSA 的撤销方式: seq 不变,校验和不变,老化时间设置为 3600S
            2. 若采用 seq+1 ,校验和不变,老化时间不变的方式撤销,当需要撤销的三类 LSA 数量较大 时,会导 致路由器会消耗大量计算资源。
       五类与七类 LSA 撤销
           1.三类 LSA 的撤销方式: seq 不变,校验和不变,老化时间设置为 3600S
           2.若采用 seq+1 ,校验和不变,老化时间不变的方式撤销,当需要撤销的三类 LSA 数量较大 时,会导 致路由器会消耗大量计算资源。
OSPF优化
          主要目的 ---- 减少 LSA 的更新量以及数量。
             1. 路由汇总(减少骨干区域的 LSA 更新量)
             2. OSPF 特殊区域(减少非骨干区域的 LSA 更新量)
OSPF路由汇总(路由聚合)
       1. OSPF 路由汇总是由手工部署的
      2.  OSPF 的汇总称为 ---- 区域汇总,因为 OSPF 在区域之间才传递路由信息,并且是对路由进行 汇总而非 LSA信息。
                       域间路由汇总
                       域外路由汇总
域间路由汇总

[GS-R2-ospf-1-area-0.0.0.1] abr-summary 192.168.0.0 255.255.224.0
[GS-R3-ospf-1-area-0.0.0.2]abr-summary 192.168.32.0 255.255.224.0
只要站点内这条汇总路由所涵盖的所有明细路由中有一条是有效的,则ABR就会通告该汇总路由,而 当所有的明细路由全部失效时,ABR设备才不会继续通告该汇总路由。
汇总并不会影响ABR设备自身的明细路由。
汇总会抑制明细路由的发送。
域间路由汇总只能汇总ABR设备自身通过一类LSA和二类LSA信息学习到的路由条目。
域外路由汇总
     [r1-ospf-1]asbr-summary 10.1.0.0 255.255.0.0
5 LSA 汇总之后的开销值计算方法:
    Type-2------ 汇总网段的开销值等于所有明细路由开销值中的最大值 +1
    Type-1------ 汇总网段的开销值等于所有明细路由开销值中的最大值
OSPF的特殊区域

      第一大类-----1、不能是骨干区域;2、不能存在虚链路;3、不能存在ASBR设备

      末梢区域(Stub Area)
     
             1. 如果将一个区域配置成末梢区域,则这个区域将不再学习4类和 5 LSA 。----ABR设备将
  不会在给 该区域转发4类和5类LSA信息。
           2.该区域将拒绝学习域外路由信息,但是,其依然具有访问域外路由的需求,所以,由该                  区域 ABR设 备,会自动生成一条指向骨干区域的3类LSA缺省路由。
              [r5-ospf-1-area-0.0.0.2]stub
              [r1-ospf-1-area-0.0.0.2]stub
          注意:一旦做特殊区域,则所有区域内的设备都必须做特殊区域。
完全末梢区域(Totally Stub Area)
          在末梢区域的基础上,进一步拒绝学习3类LSA,仅保留3类缺省即可。
          [r1-ospf-1-area-0.0.0.2]stub no-summary 该命令仅需要在ABR设备上配置即可
第二大类特殊区域----1、不能是骨干区域;2、不能存在虚链路;3、存在ASBR设备。
非完全末梢区域(NSSA) 

      1. 如果将一个区域配置成非末梢区域,则这个区域将不再学习4类和5LSA-----ABR设备将  不会在给该区域转发4类和5LSA信息。

      2.该区域依然需要将域外路由信息导入,但因为该区域拒绝 5 LSA ,所以,只能以 7 LSA 的  形式来 继续传递域外路由信息。
             之后,在 7 LSA 信息离开 NSSA 区域后,需要再转换成 5 LSA 进行传输。
      3.该区域将拒绝学习域外路由信息,但是,其依然具有访问域外路由的需求,所以,由该区域  ABR 设 备,会自动生成一条指向骨干区域的7类 LSA 缺省路由。
     
 O_NSSA ------7 类域外路由信息的标记,默认优先级也是 150
完全的非完全末梢区域(Totally NSSA)
     在 NSSA 的基础上,进一步拒绝学习 3 LSA ,产生一条 3 类缺省 LSA
      [r1-ospf-1-area-0.0.0.2]nssa no-summary

NSSA环路问题
          NSSA 区域缺省路由配置错误可能会导致路由环路的产生
           
       [r3-ospf-1-area-0.0.0.1]nssa default-route-advertise
     * R4和R5无法下发OSPF缺省路由的原因是本地路由表中的静态缺省路由被R3发送的七类缺省  路由所替代。
     *当删除R3的下发命令后,R4和R5均会下发七类缺省路由,并学习对方的七类缺省路由,但是  并不会将 从对方学习到的七类缺省路由加入到路由表中。
1. NSSA区域的七类LSA实际上是需要ASBR或者ABR自己下发的。
2. 而如果多台设备均下发成功七类LSA缺省路由,则虽然都会收到LSA信息,但并不会将其余设    备的 LSA缺省信息加入到本地路由表中。因为始终相信自己的缺省路由是最好的。
3. 而对于第一台发布七类缺省路由的设备而言,会认为我身上已经有了一条去往外部区域的路        由,并 且本地作为通告者,那么当他接收到其他设备发送来的七类缺省路由,也不会进行学          习。-----华为 运用该逻辑解决Totally NSSA中的环路问题。
                     1. 华为为了解决环路问题,保留了NSSA区域由ABR产生的七类LSA缺省路由,这样  做的好处就 是使得设备相信自己产生的这条LSA,而对于其他设备传递来的七类 LSA,只接收到不使用。
                     2. 这样一来,ABR设备就不会具备指向NSSA区域内部的缺省路由,更不会将这个缺  省路由传递 给骨干区域,从而避免环路问题。
OSPF规定:在NSSA区域中,可能同时存在多个ABR或ASBR,为了防止路由环路产生,边界路由器 之间不计算对方发布的缺省路由。

  

NSSA 负载分担解决次优路径问题
OSPF 对进行 7 5 操作的规范:
          1. P 比特位用于告知路由器该 Type-7 LSA 是否需要转换
          2. 缺省情况下,转换路由器是 NSSA 区域中 RID 值最大的 ABR
          3. 只有 P 比特位和 FA 字段不为 0 Type-7LSA 才能被转换为五类。
           [r4-ospf-1-area-0.0.0.1]nssa suppress-forwarding-address //在进行7转5时,删除转发地址
           [r1-ospf-1-area-0.0.0.1]nssa translator-always //强制开启7转5操作,在ABR设备上配置
若本地存在两条LSA除了通告者不同外,只有FA字段的值不同,那么对于这两条五类或七类LSA而 言,FA字段不为0.0.0.0的LSA优先级更高。
NSSA区域如果没有FA字段,将会有很大的可能因为7转5操作出现次优路径

重发布和路由策略

重发布

   在同一个网络拓扑结构中,如果存在多种不同的路由协议,由于不同的路由协议对于路由项的处理机制不同,这就会导致在网络中造成路由信息的隔离。而在路由协议的边界设备上,将某种路由协议的路由信息引入另一种路由协议中,这个操作被称为路由引入(Route Importation )或者路由重发布 。---- 执行该操作的技术被称为重发布。
    作用:在一个网络中,若运行多种路由协议或相同路由协议的不同进程;协议之间不能直接沟通计 算,进程之间也是相互独立,所以需要使用重发布技术来实现路由的共享。
执行条件
     1. 必须存在一个边界设备 ------ 同时连接两种路由协议或两种进程,同时学习到两种来源的路由信息, 之后进行路由共享
    2. 关注种子度量值 ---- 起始度量值。
         A 协议和 B 协议的开销计算算法不同,无法直接使用。故将 A 协议发布到 B 协议时,边界设备将
不携带 A 协议的度量值,而是共享到 B 协议后,由边界设备在路由中添加一个起始度量值。
规则
  1. A 协议引入到 B 协议中,在边界设备中的 B 协议上配置。 ---- 表明重发布技术的配置位置。
  2. 将A 协议引入到 B 协议中,边界设备会将 所有通过 A 协议学习到的路由 以及 边界设备上宣告在 A 协议 中的所有直连路由 ,全部共享到 B 协议中。 ------表明重发布时发布的信息内容。
名词解释
   单点:两个协议或两个进程之间存在一个边界设备
   双点:两个协议或两个进程之间存在两个边界设备
   多点:两个协议或两个进程之间存在多个边界设备
   单向:仅将 A 协议路由共享到 B 协议中
   双向: A B 协议的路由均共享到对方
单点重发布
A--->B
       [r2-rip-1]import-route ospf 1
通过重发布技术将其他协议的路由信息导入到RIP中,RIP协议赋予其的种子度量值为0。
修改RIP种子度量值
     [r2-rip-1]default-cost 5 ----修改全局种子度量值
    [r2-rip-1]import-route ospf 1 cost 10 -----修改特定路由的种子度量值
    注意:两条命令同时执行时,将按照第二条执行。
静态--->B:
      [r2-rip-1]import-route static
      导入静态RIP赋予的种子度量值也是0
      重发布在导入的路由中无法将缺省路由引入。
直连--->B:
     [r2-rip-1]import-route direct
     除了R1的直连网段外,所有直连均会导入。
    若边界路由器进行A--->B的重发布以及直连--->B的重发布,并且两次包含相同的路由信息,则将会优先学习直连导入的路由信息。
双点重发布

  

       默认 RIP OSPF 协议进行双点重发布,由于两者的优先级不同,故第一台 ASBR 设备重发布动作结束 后,将影响其他ASBR 设备的路由表。使得路由可能被回传到源协议当中, 发生路由回馈-------A协议的路由重发布到B协议当中后,又被重发布回A协议。路由回馈可能会导致选路不佳,甚至是路由环路的出现
华为为了解决路由回馈问题,将 OSPF 的域外路由的优先级定义为 150 150 高于华为体系下所有 IGP 协 议的优先级),从而解决路由回馈问题。
在双点双向重发布中,虽然解决了路由回馈问题,但是多点重发布还是存在一个必然产生的问题 ---- 选路不佳。------ 原因在于重发布时清除了原先的开销值导致的。

路由策略

      控制层流量 ----- 路由协议传递路由信息产生的流量
      数据层流量 ----- 设备访问目的地址是产生的流量
      所谓的路由策略-----在控制层面转发流量的过程中,截取流量,之后修改流量再转发或者不转发,最 终达到影响路由器路由表的生成,干涉选路的效果。
抓流量
       ACL 列表
      [r3-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.0
      因为ACL列表本身设计是为了抓取数据层流量的,所以,因为通配符的存在他可以灵活的匹配IP的数字特征,但是,没有办法匹配路由信息中的掩码特征。所以,ACL并不擅长控制层流量的抓取。
     如果需要在192.168.1.0/24、192.168.1.0/25、192.168.1.0/30中抓取到192.168.1.0/24,ACL是无能为力的,只能按照数字特征抓取,则意味着使用以上命令将同时抓取携带着三种路由信息的数据包。

前缀列表(IP-prefix)

        一个路由条目由目的网络地址(前缀)+掩码长度(前缀长度)共同标识
       

       IP前缀列表可以包含一条或多条语句,每条语句都使用一个序号(十进制)进行标识。

         

前缀列表的匹配规则:从上而下,逐条匹配,一旦匹配上则将按照该规则执行,不再向下匹配。末尾 隐含拒绝所有规则
  假设,有四条路由信息:172.16.0.0/16 172.16.0.0/24 172.16.0.0/30 172.16.1.1/32。
[r3]ip ip-prefix aa permit 172.16.0.0 24
该语句要求路由的目的网络地址的前24位比特位需要与172.16.0.0的前24位相同,并且路由的目
的网络掩码长度必须为24,因此该规则可以抓取172.16.0.0/24
[r3]ip ip-prefix aa permit 172.16.0.0 16 less-equal 24
该语句要求路由的目的网络地址的前16比特位与172.16.0.0的前16位相同,并且路由的目的网络
掩码长度必须大于或等于16,且小于或等于24。因为改规则可以抓取172.16.0.0/16、 172.16.0.0/24
[r3]ip ip-prefix aa permit 172.16.0.0 16 greater-equal 24
[r3]ip ip-prefix aa permit 172.16.0.0 16 greater-equal 24 less-equal 32
[r3]ip ip-prefix aa permit 172.16.0.0 16 greater-equal 24 less-equal 24
[r3]ip ip-prefix qq deny 172.16.0.0 30
[r3]ip ip-prefix qq permit 172.16.0.0 24
[r3]ip ip-prefix aa permit 0.0.0.0 0 less-equal 32
上述语句中,IP地址为0.0.0.0,这种形式的IP地址被称为通配地址,也即该地址能匹配任意形式的
目的网络地址。因此,该语句并不关系被匹配路由的目的网络地址,但是要求路由的目的网络掩码
长度必须大于等于0,小于等于32,实际上这条路由相当于“允许所有”。
[r3]ip ip-prefix ee deny 172.16.0.0 30
[r3]ip ip-prefix ee permit 0.0.0.0 0 less-equal 32
[r3]ip ip-prefix aa permit 0.0.0.0 0 greater-equal 32 less-equal 32
该语句将匹配掩码长度为32的任意路由,也就是所有的主机路由
[r3]ip ip-prefix aa permit 0.0.0.0 0
该语句允许的是默认路由0.0.0.0/0
[r3]ip ip-prefix hcip permit 172.16.4.0 22 greater-equal 24 less-equal 24

做策略

偏移列表-----Cisco

     偏移列表属于RIP这种距离矢量型协议专用的。
     抓流量
     [r1]ip ip-prefix huawei permit 23.0.0.0 24
     
     调用
     [r1-GigabitEthernet0/0/1]rip metricin ip-prefix huawei 5
    进入流量入方向接口,给其度量值增加5,metricin入;metricout出;出接口默认每次加1,如接
口默认不加。
该策略为逐跳行为,效果可以叠加操作;整段路径中流量经过的多个接口均配置了度量值增加,最终 的开销值为增加的总度量值。

过滤策略----Filter-Policy----路由过滤工具

分发列表----cisco
只能够对路由信息进行过滤,而无法对LSA进行过滤。
[r2-acl-basic-2000]rule deny source 34.0.0.0 0.0.0.0 ------过滤列表本身没有过滤能力,所以,
需要在抓取流量的时候使用拒绝动作。
[r2-acl-basic-2000]rule permit source any -----注意,在抓取流量的时候,末尾一定要放通所有
流量,否则将会把所有的流量均过滤掉,原因在于过滤策略是完全依照ACL表项进行工作的。
在过滤策略中调用
[r2-rip-1]filter-policy 2000 export GigabitEthernet 0/0/0 -----在进程中调用,选定入方向或出
方向的接口,若不选择接口,则为全局调用,会匹配所有接口
[r2]ip ip-prefix aa deny 34.0.0.0 24
[r2]ip ip-prefix aa permit 0.0.0.0 0 less-equal 32
[r2-rip-1]filter-policy ip-prefix aa export GigabitEthernet 0/0/0
注意:若使用ACL定义流量,正常华为为ACL末尾隐含允许所有,但是在过滤策略中一定要手工配置 允许所有。

注意,若此时没有在R1上进行过滤,而是等R1将域外的五类LSA发布仅OSPF后,在再R2的出方向或 入方向,有着或是R1的出方向调用过滤策略,则不会成功。必须要在R1将路由信息转换为LSA信息之前 进行调用,也就是在ASBR的入方向调用。
若在R2的入方向使用过滤策略限制192.168.2.0/24路由,则R2将不会具备该路由信息,因为是在R2 根据本地LSDB中的LSA信息计算出192.168.2.0/24路由后,拒绝将这条路由信息加入本地路由表中。而 R3此时还具备该路由信息,原因在于R3可以正常收到所有的LSA信息,并成功计算路由信息。
若将过滤策略使用在链路状态型协议中,必须使用入方向。

路由策略----Route-policy  

路由策略的匹配规则:自上而下,逐一匹配,一旦匹配上则将按照对应的规则来执行动作,不再向下 匹配。末尾隐含拒绝所有的规则

要求:192.168.1.0/24 -----过滤
           192.168.2.0/24 -----修改种子度量值10
           192.168.3.0/24 -----开销值类型修改为Type-1
           192.168.4.0/24 -----开销值类型修改为Type-1,tag=200
           12.0.0.0/24 -----不处理
抓取流量:
[r2]acl 2000
[r2-acl-basic-2000]rule permit source 192.168.1.0 0
[r2]acl 2001
[r2-acl-basic-2001]rule permit source 192.168.2.0 0
[r2]ip ip-prefix aa permit 192.168.3.0 24
[r2]ip ip-prefix bb permit 192.168.4.0 24
做策略:
[r2]route-policy hcip deny node 10 ----创建一个叫做hcip的route-policy列表,且序号为10
[r2-route-policy]if-match acl 2000 ----匹配ACL 2000
[r2]route-policy hcip permit node 20
[r2-route-policy]if-match acl 2001
[r2-route-policy]apply cost 10
[r2]route-policy hcip permit node 30
[r2-route-policy]if-match ip-prefix aa
[r2-route-policy]apply cost-type type-1
[r2]route-policy hcip permit node 40
[r2-route-policy]if-match ip-prefix bb
[r2-route-policy]apply cost-type type-1
[r2-route-policy]apply tag 200
[r2]route-policy hcip permit node 50
在重发布中调用:
[r2-ospf-1]import-route rip 1 route-policy hcip
[r2]display route-policy hcip -----查看路由策略内容
permit:
     1.指定该节点的匹配模式为允许,
     2.如果路由匹配的结果是满足该阶段的所有if-match语句,则该路由被视为允许通过,该节点的apply语言将被执行,且不再进入一下个节点。若该节点中有fi-match语句不满足,则进入下一个
节点继续匹配。
deny:
    1.指定节点的匹配模式为拒绝。
    2.如果节点的匹配模式为拒绝,则该节点的apply语句将不被执行。
   3.如果路由匹配的结果是满足该阶段的所有if-match语句,该路由策略的匹配过程直接结束。不会进入下一个阶段。而满足该节点条件的路由会被视为拒绝通过。
   4.若该节点中有fi-match语句不满足,则进入下一个节点继续匹配。
配置指南总结
1. 即便要拒绝一个流量,在抓取的时候也必须使用允许操作,之后在路由策略来拒绝。
2. 在一条规则中,若没有进行流量匹配,那么就是匹配所有流量。若没有apply那么仅对匹配的流量 进行当前大动作修改。
3. 配置时,注意路由策略的“与”和“或”关系。
BGP----- 边界网关协议
  AS----自治系统
       AS定义:由一个单一的机构或组织所管理的一系列IP网络及其设备所构成的集合。
AS划分的原因
        整个网络规模较大,伴随的是路由表中的路由数量进一步增加,路由表规模变大,路由收敛速度变慢,设备性能消耗加大。-----范围太大。
       AS之间可能是由不同的机构、公司,相互之间无法完全信任,使用IGP协议可能存在暴露AS内部的网络信息的风险。
不同的AS通过AS号进行区分,AS号存在16bit、32bit两种。IANA----互联网数字分配机构。
16位AS号,取值范围1-65534(其中0和65535保留),其中64512-65534为私有的AS号,可以自
行使用,公有的AS号为1-64511
保留AS号
     RFC4893标准,23456该AS号为保留AS号
     RFC5398标准
         16位AS号:64496-64511-----16个
         32位AS号:65536-65551-----16个  
BGP 协议介绍
      1 、首先 RIP 是基于 UDP 进行数据传输的,而 UDP 是一个不可靠的协议,他在传输过程中可能会丢失某些 数据。
      2 、缺省情况下, RIP 协议的路由更新报文的发送间隔是 30S ,而如果两个 AS 内部的路由表非常大, 30 秒的时间可能还不够将所有的路由信息传递给对方AS ,这样,整条链路完全就是为了 RIP 的通告报文服务,而不能转发数据流量。
解决方法:
         1.将 UDP 协议更换为 TCP 协议。不用担心数据丢失,并且 TCP 会预先建立连接,也就让路由器有一个 准备的时间而不是像RIP 一样毫无准备的接收大量更新数据。
         2.取消周期更新,改为触发更新。
              在第一次路由数据同步完成后,如果有路由增加,就发送通告路由增加的报文。如果路由删除,就发送一个通告路由删除的报文。
             如果路由信息发生改变,就先发送一个通告路由删除的报文,在发送一个通告路由增加的报文。
运行 BGP 协议之间的设备传递路由信息,原因在于若传递拓扑信息,会导致路由器负载过高,并且会让 对端AS 看到本端的拓扑信息,引发安全问题。
BGP 需要传递所有的通过 BGP 学习到的路由信息,并且运行了 BGP 协议的路由器,所维护的路由表是包 含了整个互联网的所有路由信息的。
BGP 特点
      BGP基于 TCP ,只要能够建立 TCP 连接,就可以建立 BGP 连接
      触发式更新,不再进行周期更新
       只传递路由信息,而不会暴露AS 内的拓扑信息
          不传递拓扑的原因
                    拓扑信息资源占用量大
                    会暴露 AS 内部的拓扑连接情况
      无类别的路径矢量型协议
          无类别 ----- 传递时携带真实子网掩码
          矢量 ----- 方向性,谁传递的路由,谁为下一跳
          距离矢量 ---- 将一个路由器看做一个单位计算距离
         路径矢量 ---- 将一个 AS 看做一个整体,从而计算一跳。
         IGP协议的主要任务是将 AS 内部的未知网段信息计算获取到,而 BGP 则主要是将 IGP协议计算出来的 路由信息进行搬运和传递,并不去计算路由。
 
BGP 的特征
    IGP 协议特点:1.选路佳   2.收敛快  3.占用资源少
 
可控性
      因为在重发布的过程中,由于会抹除原有度量值,会导致出现选路不佳的情况。而BGP为了弥补这个 不足点,直接舍弃了开销值。取而代之的是设计了很多的路径属性。
可靠性
BGP因为只有触发更新,而不存在周期更新。所以,需要确保其可靠性,使用TCP为传输层协议。
端口号179。-------BGP会话的建立是手工指定的(单播形式)。
IGP协议不选择使用TCP的原因:
    1.TCP传输效率低
    2.TCP传输占用资源大
    3.TCP协议只能实现单播,所以,无法通过组播或广播的形式发送数据,将导致IGP协议无法自
      动发现邻居关系,只能手工指定。
AS-BY-AS
     BGP将一个AS看做是一个整体。
     BGP协议不支持负载均衡。  

 

BGP 的对等关系
      BGP 因为传输层使用的是 TCP 协议,所以只要在 TCP 协议可以正常建立会话的基础上就可以完成 BGP 的 建邻工作。
      BGP 支持非直连建邻(网络可达) -----BGP 的非直连建邻是建立在 IGP (静态)之上的。
BGP 存在两种对等体关系类型: EBGP IBGP
EBGP 对等体关系
       位于不同自治系统的 BGP 路由器之间的 BGP 对等体关系。
       EBGP 对等体一般使用直连建立对等体 关系。 EBGP邻居之间的报文中TTL值被设置为1。
       两台路由器之间要建立EBGP对等体关系,需要满足如下条件:  
             两个路由器属于不同 AS
            在配置时, peer 命令所指定的对等体的 IP 地址必须路由可达, TCP 连接必须正常建立。
IBGP 对等体关系
         位于相同自治系统的 BGP 路由器之间的 BGP 对等体关系。
        IBGP 对等体一般使用非直连建邻。IBGP邻居之间的报文中 TTL 值被设置为 255。
        在 IBGP 对等体中,常使用环回接口地址作为源目 IP 地址。
               环回接口稳定
               并且可以借助 AS 内部的 IGP 和冗余拓扑来保证可靠性。
BGP 特点
1. 无类别路径矢量协议 -----AS-BY-AS
2. 使用单播更新来发送消息;基于 TCP 179 号端口工作。
3. 增量更新机制 ---- 仅触发更新,无周期更新
4. 具有丰富的路径属性来取代 IGP 中的度量值进行选路,可以由多个属性共同控制协议
5. 可以在流量的进出口实行路由策略 ---- 可控性
6. 默认不被用于负载均衡 ----- 会通过各种选路规则仅仅产生一条最佳路径
7. BGP 支持认证和聚合
BGP 的数据包

BGP报文头部 

 

 

Route-refresh包 -----路由刷新包
      作用:用来要求对等体重新发送指定地址族的路由信息。
      一般为本端修改了相关路由策略之后让对方重新发送更新报文,本端执行新的路由策略重新计算BGP 路由。
双方均支持路由刷新功能。
     OSPF中的 hello 报文 ------可以周期性的发现、建立和保活邻居关系。
Open包
      是TCP 连接建立之后发送的第一个报文,用于建立 BGP对等体之间的连接关系。
 Hold Time-----保活时间
BGP Identifier-----BGP的标识符(RID)
      与OSPF中的RID用法相同
     全网唯一。
     获取方式:手工配置>最大环回接口>最大物理接口
BGP需要协商的参数
 AS号
          BGP的open报文会携带本地的AS号,通过比较两端的AS号可以判断对端是否和本端处于相 
同 AS。
             不管这个AS号与本地的AS号是否相同,都不影响BGP对等体的建立。
        另外,如果对方的AS号和本地指定对等体时写的AS号不同,则会导致邻居关系无法建立。
              peer 12.0.0.2 as-number 100
RID
       通过对比open报文中的RID值,可以判断是否相同,若相同则会导致建邻失败。
认证字段
          BGP也可以进行认证,认证口令不同,则也会导致建邻失败。
          该字段永远以MD5值的方式保存在TCP的选项字段。
保活时间-----并不影响BGP对等体的建立。
         BGP在建立对等体关系时,需要协商该参数。
         如果在该时间内未收到对端发来的keepalive报文或者update报文,则认为BGP连接中断。-
---180S。
            报文更新时间----三分之一保活时间----60S。
        若双方保活时间不一致,则按照小的时间进行。
       该参数可以设置为0,若设置为0,则代表不发送keepalive报文。
路由刷新功能
keepalive包
作用:用来进行周期保活。
除了保活机制外,keepalive报文还在open报文协商参数时,临时充当确认报文-----确认open报文中 的参数是否认可。
update包---更新包
作用:用于在对等体之间传递路由信息,可以用于发布、撤销路由。-----携带需要传递的路由信息。
需要携带的参数主要就是目的网络号、子网掩码信息和路径属性。

 

 

Notification
纯粹的告警机制。当 BGP 检测到错误状态时(对等体关系建立时、建立之后都可能发送该报文),就 会向对等体发送该报文,告知对端错误原因。之后BGP 连接会 立即 中断。
BGP 的状态机
BGP 的角色
Speaker
      发送 BGP 报文的设备被称为 BGP Speaker (发言者)
      它接收或产生新的报文信息,并发布给其他 BGP Speaker Speaker 角色是针对具体报文发送
过程而言的,网络中每台 BGP 路由器均可称为自己发送 BGP 报文的 Speaker
Peer
      相互交换报文的 Speaker 之间互相称为 peer (对等体)
BGP的状态机仅描述的是对等体关系建立过程的状态变化。BGP可以将邻居建立过程和BGP路由收发 过程分开。

 

 

  IDLE-----空闲状态
        所有设备启动BGP进程后,首先进入该状态。
        进入该状态后,等待手工指定邻居。
        当手工指定邻居之后,将会进入到一个检查环节。需要检查手工指定的IP地址在本地全局路由 表中是否可达,只有可达,才可以正常建立TCP的会话,如果不可达,则邻居关系建立失败,停留在IDLE状态。
       若检查成功,则进入Connect状态。
Connect-----连接状态
      建立TCP会话连接
      在该状态下,会开启一个连接重传定时器。----32秒。
      如果成功建立TCP会话,会关闭连接重传定时器,并进入OpenSent状态。
      如果建立失败,则进入Active状态。
      如果重传定时器超时,BGP仍然没有收到对等体的响应,那么BGP会继续尝试与对等体建立
TCP会话,并一直处于Connect状态。
Active状态----尝试状态
      该状态是因为第一次TCP会话建立失败进入的,在该状态会重新尝试建立TCP会话。
      如果成功建立,则进入OpenSent状态,并会关闭连接重传定时器。
      如果失败,则停留在Active状态。
     与Connect状态共同使用同一个连接重传定时器。
OpenSent-----发出本地的Open报文
     也将收到对端发送的open报文,并会查看其中的参数,如果参数没有问题,则本地将发送 keepalive报文进行确认,之后进入openconfirm状态。
    如果发现收到的open报文中的参数不认可,那么BGP会发送notification报文给对等体,并进
入idle状态。
     对等体关系的指定是双向的,所以当双方都使用peer命令指定了对等体后,均会主动与对等
体建立TCP连接。但是这样就会建立两条TCP的双向连接,所以BGP会选择第一个TCP链接断
开。
OpenConfirm----等待确认状态
     在该状态机是,等待对方发送的keepalive报文。如果接收到对端发送的keepalive报文,则代
表参数协商通过,会进入最终状态。  
     如果收到的是notification报文,则转至idle状态。
Established------连接建立完成状态
      对等体关系建立完成的标志。
      在该状态下,BGP可以和对等体交互Update报文、keepalive报文、Route-refersh报文和
Notification报文。
BGP 的工作过程
1. 基于IGP协议或静态路由实现邻居IP可达
2. 启动BGP协议,并指定邻居关系
      1. 邻居之间单播传输报文,通过三次握手机制,建立TCP会话通道。
       2. 后续BGP所有的通讯都将基于TCP会话通道来传输。包括传输所需要的可靠性机制。
3. 使用open报文和keepalive报文进行对等体关系的建立。open报文用来携带建立对等体关系时所需要使用的参数,keepalive报文用于参数的确认。最终完成对等体关系的建立。生成邻居表。
4. 使用update报文来共享路由信息。信息中将携带目标网络号、掩码及路径属性;之后,设备会将所 有的自己发送的以及接收的路由信息记录在一张表中-----BGP表。
5. 将BGP表中的最优路由信息(通过路径属性选择)加载到全局路由表中。
6. 此时路由收敛完成,将使用keepalive报文进行周期保活,默认保活时间为180S,周期发送时间默 认为保活时间的1/3,即60S。
7. 如果出现错误信息,则将使用notification报文进行告警
8. 如果出现结构突变,则将使用update报文进行触发更新
BGP的防环机制
      EBGP的水平分割
    AS_Path属性-----记录AS路径的一个属性
         
   当路由信息再一次传回本地AS时,路由器通过查看AS_Pathshux1,可以清楚的知晓该属性包含本地 AS号,故拒绝学习该路由信息。
    IBGP的水平分割

 

BGP规定,当路由器从一个IBGP对等体学习到某条BGP路由时,它将不能再把这条路由通告给任何 IBGP对等体。-----IBGP水平分割机制。
解决方案
   1. 构建全联的IBGP对等体关系
           1. 当AS内部设备数量巨大时,IBGP邻居关系会呈指数型增长,而非直连建邻之间传递的数据还 是要依靠物理链路,故全连接建邻会导致占据大量的链路资源,并且路由器维护大量的TCP和 BGP会话连接,需要消耗大量的设备资源。
           2. 网络的可扩展性差。
 2. 打破IBGP水平分割
          1. 联邦
          2. 路由反射器  

 BGP的路由黑洞

   由于 BGP 协议可以非直连建邻,所有导致 BGP 协议可能出现跨越未运行 BGP 协议的设备,导致 BGP 路 由传递后,控制层面可达。但是数据层面,流量流经未运行BGP 协议的设备时,无法通过,形成路由黑 洞。
      避免路由黑洞的方式-----BGP同步更新规则----当一台路由器从自己的IBGP对等体学习到一条BGP路由 时,它将不能使用该条路由或把这条路由信息通告给自己的EBGP对等体,除非它又从IGP协议学习到这 条路由,也就是要求IBGP路由与IGP路由同步。
在华为数通设备上,BGP同步更新规则缺省是被关闭的,并且华为也不允许开启BGP同步规则。
解决方案
    1. 让未运行BGP协议的设备运行BGP协议---建立全连接的IBGP环境。
    2. 物理或逻辑拓扑全联
    3. 在IGP协议中,重发布BGP协议的路由信息
    4. MPLS----多标签标记交换。
BGP 基本配置
    BGP 建邻的基本配置

 

 使用直连接口IP地址建立EBGP对等体关系

      1、启动BGP协议
         [r1]bgp 100 -----启动BGP进程,且标准本设备所在的AS号
    2、设置Rid
           [r1-bgp]router-id 1.1.1.1
   3、配置BGP对等体,并指定对等体所在的AS号
        [r1-bgp]peer 12.0.0.2 as-number 200
        [r1]display bgp peer ----查看BGP的邻居表  
IBGP对等体的建立
      由于直连接口建立对等体时,若链路终端,则会中断 BGP 会话。故在实际工程中,一个 AS 内部正常具 有较为复杂的网络拓扑结构,设备到设备之间存在大量的备份和负载均衡路径,因此建立IBGP 邻居关系时,建议使用双方的环回接口来作为源 / IP 地址
     [r2]bgp 200
     [r2-bgp]peer 3.3.3.3 as-number 200
     [r3]bgp 200
     [r3-bgp]router-id 3.3.3.3
     [r3-bgp]peer 2.2.2.2 as-number 200
手工建立邻居关系时,所指定的建邻的 IP 地址必须和收到的数据包中的源 IP 地址相同才能正常建立邻 居关系。否则,邻居关系建立失败
  [r2-bgp]peer 3.3.3.3 connect-interface LoopBack 0 -----将R2发送的数据包的源IP地址修改为
loopback 0接口的IP地址
 
抓包后会发现一个问题,就是BGP此时仅建立了一次TCP连接,就完成了BGP会话的建立。这也就意 味着,BGP会话的建立仅仅是依靠TCP会话,而并没有对这个TCP会话建立的方式有要求,该TCP会话是由谁发起的,谁是客户端,谁是服务端并不影响BGP对等体的建立。-------在BGP协议中,TCP会话建立 两次完全是多余的,而建立两次的原因也是因为双方路由器均会指定对等体(均将自己看做是客户端),从而发起建立连接请求。
      而在当下场景中,R3作为TCP会话的服务端,已经认知到了自己本地已经有接口3.3.3.3,与自己本地配置的对等体建立了连接,所以本地也不会在发送所谓的TCP连接建立请求。
    一般情况下,双方均要修改本地数据包的源IP地址。
使用环回接口IP地址建立EBGP对等体关系
       若EBGP对等体之间存在多条直连链路时,才可使用环回接口建立对等体关系。
      1、实现路由可达
       ip route-static 5.5.5.5 255.255.255.255 45.0.0.5
       ip route-static 4.4.4.4 255.255.255.255 45.0.0.4
      2、对等体配置
      [r4]bgp 200
      [r4-bgp]peer 5.5.5.5 as-number 300
      [r4-bgp]peer 5.5.5.5 connect-interface LoopBack 0
      [r5]bgp 300
      [r5-bgp]router-id 5.5.5.5
      [r5-bgp]peer 4.4.4.4 as-number 200
     [r5-bgp]peer 4.4.4.4 connect-interface LoopBack 0
      因为EBGP之间的数据包的TTL值为1,故此时虽然可以建立TCP连接和BGP会话,但是路由器会认为该连接和会话存在异常,在BGP对等体建立完成后,发送notification报文断开连接,从而会产生一个现象- ---状态机震荡。
解决方法:修改TTL值
      [r4-bgp]peer 5.5.5.5 ebgp-max-hop 2
       如果未标明参数值,则代表将TTL值修改为最大值255
       [r5-bgp]peer 4.4.4.4 ebgp-max-hop 2
       两边均要修改,不然无法建立对等体关系,还存在状态机震荡。
BGP的路由发布
通过network命令发布路由  
         路由发布----对于BGP而言,只要是路由表中存在的路由信息,都可以通过network命令发布。 [r1-bgp]network 1.1.1.1 32 目标网络号 路由表中的掩码信息
注意:BGP使用network命令宣告时,该路由信息必须与全局路由表中存在的路由项一致。
[r1-bgp]display bgp routing-table ---查看BGP表
  network-----目标网络号及掩码
nexthop-----下一跳,谁发送的路由信息,则下一跳就写谁;如果是本地发布的路由,则下一跳写0.0.0.0
状态码----
    *
    代表可用
    所有设备收到路由条目后,首先会根据下一跳属性中的参数来查询本地路由表,查看该地址的
可达性。如果本地路由表中可达,则代表该路由信息可用;若本地不可达,则代表该路由信息
不可用。
     如果该路由条目不可用,则将不会参与到路由信息的优选过程。
>
   代表优选
    当收到多条到达相同网段的路由信息时,并且都可用,则将依据属性在其中选择最优的路由信
息进行加表及传递。
i
    代表该路由信息是通过IBGP对等体学习到的
对于R3而言,R2传递来的路由信息是不可用且不优的,原因在于下一跳属性未修改,无法递归。
解决思路:
[r2-bgp]peer 3.3.3.3 next-hop-local
将路由传递给自己的3.3.3.3邻居时,将路由中的下一跳属性该为本地。
总结一下配置逻辑:
1. 完成所有路由器的IGP配置
2. 使用直连接口建立EBGP对等体关系
3. 使用环回接口建立IBGP对等体关系
4. 使用connect-interface命令修改IBGP建邻源IP地址,双方均修改
5. 使用next-hop-local命令修改路由传递的下一跳属性
6. 若存在使用环回接口建立EBGP对等体关系,则需要建立通讯条件,并且使用ebgp-max-hop命令修改TTL值
使用import命令引入路由
[r2-bgp]import-route ospf 1
ONG----起源码属性----标识一条路由信息的起源类型
      i----代表这条路由信息起源于AS内部使用network命令通告出来
            不限于IGP、静态、直连
     e-----代表这条路有信息起源于EGP协议----现在几乎看不到该标识
     ?-----除了以上两种方式,其他方式获取的路由信息都是该标识
BGP路由通告原则
      当一条BGP路由器发现了多条可以到达同一地址的路由条目,该设备会通过一个路由选择过程在这 些路由条目中选择一条最优的路由,将这条路由加入到全局路由表中,并且在向其他BGP对等体通 告该路由条目时,也只会通告最优的路由。
           通常情况下,路由器只会将最优的路由加载到路由表中,除了激活了负载均衡情况外。
      当一台路由器从EBGP邻居学习到了BGP路由时,缺省情况下,会将该路由条目通告给所有的IBGP 对等体以及EBGP对等体。
      当一台路由器从IBGP邻居学习到了BGP路由时,缺省情况下,不会将这条路由信息通告给其他的 IBGP对等体。
             因为IBGP水平分割原则
当一台路由器从自己的IBGP学习到BGP路由时,如果同步规则被激活,只有从IGP协议也学习到该 路由条目后,才会将BGP路由激活,并学习到本地,以及通告到EBGP对等体。如果同步规则被关 闭,即使没有从IGP学习到该路由,也会将BGP路由通告给EBGP对等体。
BGP的路由聚合

 

自动聚合
        该方法仅针对重发布的路由信息生效。
        华为设备默认关闭自动聚合功能
         [r1-bgp]summary automatic 开启自动聚合功能
        
自动聚合功能是以主类聚合的方式进行的。而主类聚合方式会导致一个结果就是产生路由黑洞。所以 也会生成一条去往空接口的防环路由。这也是华为设备关闭自动聚合功能的原因。
      状态码S-----代表抑制,被抑制的路由信息将不再加表和传递。
特点:
1. 缺点
          1. 自动聚合只能将明细路由汇总到主类
                 1. 会产生巨大的路由黑洞
          2. 自动聚合只能针对重发布的路由条目生效
2. 自动聚合会抑制明细路由条目
3. 黑洞路由器会在本地的路由表中,自动生成一条指向null口的汇总网段路由,防止环路
4. 聚合完成后,将会在本地的BGP表中发布一条新的下一跳指向127.0.0.1的汇总网段路由
 

 

 

 

[r3-bgp]aggregate 172.16.0.0 20
   手工聚合会生成一条指向空接口的防环路由,并且掩码可以随意汇总,但是手工聚合没有将明细路由进行抑制。
    手工聚合只有在所有明细路由均无效时,才会撤销。并且,手工聚合可以灵活调整掩码信息,只要还 存在一条明细路由,手工聚合后的路由就是可用且优的。
手工聚合命令在配置后,1、检测本地路由表中是否有聚合路由的可用明细路由。2、若有则在本地路 由表中发布一条指向空接口的防环路由;若无则该命令无效;3、将汇总的防环路由发布到BGP中
   BGP的手工聚合可以在非直连设备上进行,只要本地存在这些明细路由,且明细路由可用且优就可以 进行聚合操作。
    聚合路由不会继承明细路由的属性,导致AS_Path属性丢失,可能会引发环路问题。
    [r3-bgp]aggregate 172.16.0.0 20 detail-suppressed -----抑制所有明细路由
抑制策略,通告172.16.0.0/20的汇总路由时,将172.16.1.0/24的明细路由也通告出去。
在该策略中,会将路由策略中所允许的流量给抑制。也就是说,实际上是与路由策略的玩法相反。
1、抓流量
[r3]ip ip-prefix aa deny 172.16.1.0 24
[r3]ip ip-prefix aa permit 172.16.0.0 20 greater-equal 24 less-equal 24
2、配置策略
[r3]route-policy aa permit node 10
[r3-route-policy]if-match ip-prefix aa
3、调用
[r3-bgp]aggregate 172.16.0.0 20 suppress-policy aa ----策略名称即为路由策略的名称as-set -----汇总路由会继承明细路由的路径属性
[r3-bgp]aggregate 172.16.0.0 20 as-set
[r3-bgp]aggregate 172.16.0.0 20 as-set detail-suppressed
as-set属性在继承多个明细路由属性时,会将继承的不同的多个明细路由的AS_Path属性使用{}括起 来,在选路时,当做一个来看,而在防环时,将观察所有的AS号。
attribute-policy-----该参数可以设置聚合路由的大部分路径属性
[r1]route-policy bb permit node 10
[r1-route-policy]apply as-path 1 2 3 additive
[r1-route-policy]apply local-preference 10
[r1-route-policy]apply cost 100
[r1-route-policy]apply preferred-value 20
[r1-bgp]aggregate 172.16.0.0 20 detail-suppressed attribute-policy bb
origin-policy ----设置某些明细路由为汇总路由宣告的触发条件
[r1]ip ip-prefix aa permit 172.16.1.0 24
[r1]route-policy aa permit node 10
[r1-route-policy]if-match ip-prefix aa
[r1-bgp]aggregate 172.16.0.0 20 origin-policy aa
Atomic-Aggregate
    纯粹的预警属性,不承载任何信息
    当路由器收到的update报文中,携带该属性值,则认为这条路由信息可能存在属性丢失。
    该属性只有当所有的明细路由均被抑制时才会携带
Aggregator
   携带了汇总者的RID以及其所在的AS号
   用于标记聚合行为发生的位置
          那个AS,哪台BGP设备
路由反射器
IBGP水平分割:路由器无法将从IBGP对等体学习到的路由信息传递给其他IBGP对等体。
IBGP水平分割解决了AS内部环路的问题,但是产生了新的问题-----BGP路由在AS内部只能传递一跳,会 造成IBGP路由无法被正常传递,造成通讯障碍。

 

       
  路由反射器角色  
     RR---Route Reflector
           RR类似于一面镜子,可以把自己接收到的路由信息反射给其他人
     Client----RR客户端-----客户端可以存在多个或一个
     RR非客户端
     路由反射器的配置是在充当反射器的BGP路由器上完成的。而路由反射器的客户设备并不需要做任何 额外的配置,它甚至不知道自己成为了某个路由反射器的客户。
      路由反射器与所有的客户或非客户建立IBGP对等体关系,而客户之间则无需建立IBGP对等体关系。这 样就优化了网络中的IBGP对等体关系数量。
路由反射规则
1. 如果路由反射器从自己的非客户对等体学习到一条IBGP路由,则可以将这条路由传递给自己的客户
2. 如果路由反射器从自己的客户对等体学习到一条IBGP路由,则可以将这条路由传递给自己的客户和 非客户
3. 如果路由器学习到EBGP对等体发送的路由信息,则可以发送给所有的IBGP对等体
4. 当路由反射器执行路由反射时,它将只能使用自己最优的BGP路由进行反射。

[r3-bgp]peer 2.2.2.2 reflect-client -----1、指定2.2.2.2为自己的客户;2、并说明自己是RR
路由反射器角色可能会根据处于不同的反射簇时充当不同的角色。一般会设置传递路由信息的一方为RR 的客户端。
Origin-ID-----起源ID
  当一条BGP路由被路由反射器反射给其他路由器时,如果该条路由已经携带了起源ID属性,则保留该 属性,否则路由反射器为这条路由添加起源ID属性,并将该属性值设置为该路由在本地AS内的始发路由 器的RID值。              

 

当路由器从 BGP 对等体收到一条 IBGP 路由,并且该路由所携带的起源 ID 属性与自己的 BGP RID 相同 时,它将意识到该路由是从自己这里发送到本AS 内部的,且又被发送回来了,此时本地将忽略这条路由 的更新。如此消除环路隐患。
Cluster-List----- 簇列表
    当一条 BGP 路由被路由反射器执行反射时,如果该条路由已经存在 Cluster-List 属性,那么路由反射 器将本地的Cluster-ID 附加到路由的 Cluster-List 属性中,而如果该路由没有 Cluster-List 属性,那么路 由反射器为其创建,并将Cluster-ID 加入到 Cluster-List
   当一台路由反射器收到一条 BGP 路由后,若发现该路由携带 Cluster-List 属性,并且 Cluster-List 属性 中包含着自己的Cluster-ID 时,会忽略关于这条路由的更新 ----- 类似于 AS-Path 属性的防环原理

 

注意
   当路由反射器将一条从自己的 EBGP 对等体学习到的 BGP 路由通告给自己的客户时,他是不会创建 起源ID 和簇列表,因为这本质上是正常的通告行为
   起源 ID 和簇列表的传播范围是 AS 内部
路由反射器在反射路由时,不会修改除了起源 ID 和簇列表以外的路径属性,原因是因为 AS-BY-AS 原则。

Guess you like

Origin blog.csdn.net/m0_56763594/article/details/129383954
Recommended