用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ffsshhttiikk/opencode-agents-skills --skill routing命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | routing |
| description | Network routing protocols and configuration |
| category | networking |
| difficulty | intermediate |
| tags | ["routing","bgp","ospf","network"] |
| author | OpenCode Community |
| version | 1 |
| last_updated | 2024-01-15T00:00:00.000Z |
I am Network Routing, the process of directing network traffic between different networks using routing protocols and configured routes. I enable communication between networks using interior gateway protocols (OSPF, EIGRP, IS-IS) for internal routing and exterior gateway protocols (BGP) for internet-wide routing. I implement route summarization, policy-based routing, and quality of service. I ensure optimal path selection through metrics, administrative distances, and route maps. I provide redundancy through multiple paths and fast convergence. I secure routing through authentication and route filtering.
# OSPF Routing Configuration
! Enable OSPF process
router ospf 1
router-id 1.1.1.1
auto-cost reference-bandwidth 10000
log-adjacency-changes
passive-interface default
no passive-interface GigabitEthernet0/0
no passive-interface GigabitEthernet0/1
! Route summarization
summary-address 10.1.0.0 255.255.0.0
! Default route injection
default-information originate always
! Area configuration
area 0 authentication message-digest
area 1 virtual-link 2.2.2.2 message-digest-key 1 md5 CISCO
! Route redistribution
redistribute connected metric 100 metric-type 1 subnets
redistribute bgp 65000 metric 100 metric-type 2 subnets
! Interface configuration
interface GigabitEthernet0/0
description Uplink to Core
ip address 10.0.0.1 255.255.255.252
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 CISCO
ip ospf cost 10
ip ospf dead-interval 40
ip ospf hello-interval 10
ip ospf priority 100
interface GigabitEthernet0/1
description LAN Interface
ip address 10.1.1.1 255.255.255.0
ip ospf authentication null
ip ospf cost 1
ip ospf dead-interval 40
ip ospf hello-interval 10
! Loopback for router ID
interface Loopback0
ip address 1.1.1.1 255.255.255.255
! Route map for filtering
route-map BLOCK_INTERNAL deny 10
match ip address 100
set local-preference 50
route-map BLOCK_INTERNAL permit 20
match interface GigabitEthernet0/0
! Access list for filtering
access-list 100 deny 10.2.0.0 0.0.255.255
access-list 100 permit any
# BGP Configuration for Juniper
system {
host-name edge-router;
root-authentication {
encrypted-password "HASHED_PASSWORD";
}
login {
class operator {
permissions [ network routing trace ];
}
}
}
routing-options {
router-id 1.1.1.1;
autonomous-system 65000;
forwarding-table {
export ECMP-POLICY;
}
static {
route 0.0.0.0/0 next-hop 203.0.113.1;
}
}
protocols {
bgp {
group INTERNAL-PEERS {
type internal;
local-address 1.1.1.1;
neighbor 2.2.2.2 {
description Primary-ISP;
local-as 65000;
peer-as 65000;
keepalive-time 10;
hold-time 30;
multipath;
}
neighbor 3.3.3.3 {
description Backup-ISP;
local-as 65000;
peer-as 65000;
}
}
group EXTERNAL-CUSTOMERS {
type external;
local-address 10.0.0.1;
neighbor 10.0.0.2 {
description Customer-A;
peer-as 65001;
import [ FILTER-INCOMMING EXPORT-OUTGOING ];
export [ SET-COMMUNITIES ADD-LOCAL-PREF ];
}
}
log-updown;
hold-time 45;
graceful-restart;
}
ospf {
area 0.0.0.0 {
interface ge-0/0/0.0 {
hello-interval 10;
dead-interval 40;
authentication-type md5;
md5-key 1 key "$9$KEY"; # encrypted
}
interface lo0.0 {
passive;
}
}
}
lldp {
interface all;
}
}
policy-options {
policy-statement EXPORT-OUTGOING {
from protocol bgp;
then {
community add CUSTOMER-COMMUNITY;
accept;
}
}
policy-statement FILTER-INCOMMING {
from {
protocol bgp;
community [ BLOCKED-COMMUNITIES ];
}
then reject;
}
community CUSTOMER-COMMUNITY members 65000:100;
community BLOCKED-COMMUNITIES members [ 65000:666 65000:999 ];
}
firewall {
filter BGP-FILTER {
term ALLOW-BGP {
from {
protocol tcp;
port bgp;
}
then accept;
}
term DENY-ALL {
then {
discard;
count blocked-packets;
}
}
}
}
# FRR (Free Range Routing) Configuration
# /etc/frr/frr.conf
frr version 8.0
frr defaults traditional
hostname router1
password zebra
enable password zebra
! OSPF Configuration
router ospf
ospf router-id 1.1.1.1
redistribute connected
redistribute bgp
network 10.0.0.0/24 area 0
network 10.1.0.0/24 area 0
network 10.2.0.0/24 area 1
area 1 stub no-summary
area 1 range 10.2.0.0/24
timers spf delay 50 holdtime 200
max-metric router-lsa on-startup 300
auto-cost reference-bandwidth 10000
! OSPF6 Configuration for IPv6
ipv6 router ospf6
router-id 1.1.1.1
redistribute connected
interface eth0 area 0.0.0.0
interface eth1 area 0.0.0.0
! BGP Configuration
router bgp 65000
bgp router-id 1.1.1.1
neighbor 10.0.0.2 remote-as 65001
neighbor 10.0.0.2 description Primary-Upstream
neighbor 10.0.0.2 ebgp-multihop 5
neighbor 10.0.0.2 soft-reconfiguration inbound
neighbor 10.0.0.2 prefix-list PL-IN in
neighbor 10.0.0.2 prefix-list PL-OUT out
address-family ipv4 unicast
network 10.0.0.0/24
network 10.1.0.0/24
neighbor 10.0.0.2 activate
neighbor 10.0.0.2 default-originate
aggregate-address 10.0.0.0/22 summary-only
exit-address-family
address-family ipv6 unicast
network 2001:db8::/32
neighbor 2001:db8::2 activate
exit-address-family
! IS-IS Configuration
router isis
net 49.0001.0011.0000.0001.00
metric-style wide
log-adjacency-changes
area-password CISCO
domain-password SECRET
interface eth0
ip pointopoint-address 10.0.0.1
isis circuit-type level-2
isis metric 10
interface lo
passive
#!/usr/bin/env python3
"""
Route Policy Manager - BGP and OSPF route manipulation
"""
import ipaddress
from typing import Dict, List, Set
from dataclasses import dataclass
from enum import Enum
class RouteAction(Enum):
PERMIT = "permit"
DENY = "deny"
SET_COMMUNITY = "set_community"
SET_LOCAL_PREF = "set_local_pref"
SET_MED = "set_med"
SET_NEXTHOP = "set_nexthop"
@dataclass
class Route:
prefix: str
next_hop: str
metric: int = 100
local_pref: int = 100
community: Set[str] = None
as_path: List[str] = None
def __post_init__(self):
if self.community is None:
self.community = set()
if self.as_path is None:
self.as_path = []
:
():
.access_lists: [, ] = {}
.prefix_lists: [, ] = {}
.route_maps: [, ] = {}
.community_lists: [, ] = {}
():
.access_lists[name] = rules
():
.prefix_lists[name] = prefixes
() -> :
list_name .access_lists:
rule .access_lists[list_name]:
action = rule.get(, )
._check_match(route, rule):
action ==
() -> :
list_name .prefix_lists:
route_net = ipaddress.IPv4Network(route.prefix, strict=)
pl .prefix_lists[list_name]:
prefix = ipaddress.IPv4Network(pl[], strict=)
match_type = pl.get(, )
match_type == :
route_net == prefix:
match_type == :
prefix.subnet_of(route_net):
match_type == :
prefix.subnet_of(route_net):
match_type == :
route_net.subnet_of(prefix):
() -> Route:
map_name .route_maps:
route
modified_route = route
sequence, rule (.route_maps[map_name], ):
._check_match(modified_route, rule.get(, {})):
action rule.get(, []):
modified_route = ._apply_action(modified_route, action)
rule.get():
modified_route
() -> :
match_criteria:
.match_prefix_list(route, match_criteria[]):
match_criteria:
.match_access_list(route, match_criteria[]):
match_criteria:
required = (match_criteria[])
required.issubset(route.community):
match_criteria:
( route.as_path match_criteria[]):
match_criteria:
route.next_hop != match_criteria[]:
() -> Route:
action_type = action.get()
action_type == RouteAction.SET_LOCAL_PREF.value:
route.local_pref = action[]
action_type == RouteAction.SET_MED.value:
route.metric = action[]
action_type == RouteAction.SET_COMMUNITY.value:
comm action.get(, []):
action.get():
route.community.add(comm)
:
route.community.discard(comm)
action_type == RouteAction.SET_NEXTHOP.value:
route.next_hop = action[]
route
COMMUNITIES = {
: ,
: ,
: ,
: ,
: ,
}
():
engine = RoutePolicyEngine()
engine.add_prefix_list(, [
{: , : },
{: , : },
])
engine.route_maps[] = [
{
: {: },
: [
{: , : },
{: , : [], : }
]
}
]
test_route = Route(
prefix=,
next_hop=,
local_pref=
)
result = engine.apply_route_map(test_route, )
()
()
()
__name__ == :
main()