年轻人的第一个公网路由 (二): 通过BGP广播你的IP

前言

上文中将 ASN 申请下来了,本文就要把自己的 IP 地址和路由广播出去,让全网可以访问你了!

拆分地址

我的 LIR 为我提供了一段 /44 和一段 /40 的 IPv6 地址,但我的测试网准备先播一段 /48 地址,所以需要拆分出来。

创建 inet6num 与 route6 对象

操作前,请先在 maintainer 与 role 对象中删除 mnt-ref 标签
前往这里创建 inet6num 对象。
填写信息
图上有一点填错了 NAME 不能有空格
然后在这里创建 route6 对象。

准备 BGP Session

找一家支持 BGP Session 的服务商,例如: Buyvm/Vultr。这里博主选择了 Buyvm
开工单,表明你需要 BGP Session 服务。对方会给你的 ASN 的管理邮箱发送一封验证邮件,在工单中回复验证码。等到晚上对方就会提示你已经开通服务了。
前往 Stallion 管理面板,找到你的 vps,进入网络管理,点击 BGP 即可看到详细信息。
点击 Configure Session 配置好机器的信息(这里面的东西一般没什么影响,按你想要的配置就行,不会配置就默认吧)。

给 VPS 绑定 ipv6 地址

Buyvm 的 VPS 似乎默认没有绑定 ipv6 地址,需要手动绑定一下。
在这里引用一篇文章 给BuyVM的Debian机添加IPv6

创建dummy 网卡

法一

直接使用下面的命令创建网卡:

1
2
3
ip link add dummy0 type dummy # 新建一个dummy网卡,命名为dummy0(强烈建议使用一个规则的命名方式,比如dummy+数字)
ip link set dummy0 up # 标记网卡状态为UP
ip addr add [你想要广播的ip地址 例 ffff:2333:400::1/128] dev dummy0 # 向dummy网卡添加地址

通过命令创建的网卡每次重启会消失

法二

/etc/network/interfaces 写入配置。

1
2
3
4
5
6
auto dummy0
iface dummy0 inet6 static
address ffff:2333:400::1
netmask 128
pre-up ip link add dummy0 type dummy
up ip link set dummy0 up

安装 BIRD

可以使用包管理器安装,也可以源码安装。
这里选择源码安装

1
2
3
4
5
6
7
8
9
apt update
apt install -y build-essential autoconf git flex bison m4 libssh-dev libncurses-dev libreadline-dev
cd ~
git clone https://gitlab.nic.cz/labs/bird.git -b v2.15.1 BIRD
cd BIRD
autoreconf
./configure --prefix= --sysconfdir=/etc/bird --runstatedir=/var/run/bird
make
make install

创建服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# /etc/systemd/system/bird.service

[Unit]
Description="BIRD Internet Routing Daemon"
After=network.target

[Service]
Type=simple
ExecStartPre=/usr/sbin/bird -p
ExecReload=/usr/sbin/birdc configure
ExecStart=/usr/sbin/bird -f -u bird -g bird
Restart=on-abort

[Install]
WantedBy=multi-user.target

一个小坑

BIRD 无法自己创建 socket 文件(未知原因)
每次开机需要手动 mkdir -p /run/bird/

撰写配置文件

这部分内容建议查看 阶段1 BGP Player
因为我自己的配置文件没跑起来。

启动!

如果启动服务后,看见 BGP 状态为 Established 即为成功。
Established

年轻人的第一个公网路由 (二): 通过BGP广播你的IP

https://omn.cc/archives/75.html

作者

空指针

发布于

2024-07-03

更新于

2024-07-03

许可协议

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

评论

You forgot to set the shortname for Disqus. Please set it in _config.yml.
Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×