DN42 - 接入DN42网络平台

1 注册AS

参考DN42 - 注册AS.

2 Linux系统配置

在/etc/sysctl.conf配置文件中增加以下配置信息。

# 打开 Linux 内核的数据包路由转发功能
net.ipv4.ip_forward=1
net.ipv6.conf.default.forwarding=1 #
net.ipv6.conf.all.forwarding=1

# 关闭反向路径过滤
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0

其他配置信息可参考:linux /etc/sysctl.conf 内核参数详解

3 建立隧道:wireguard

3.1 wireguard安装

Ubuntu18.04和Ubuntu20.04:

sudo apt install wireguard

macOS:

brew install wireguard-tools

我在Ubuntu安装中,遇到了报错:

[#] ip link add wg0 type wireguard
RTNETLINK answers: Operation not supported
Unable to access interface: Protocol not supported
[#] ip link delete dev wg0
Cannot find device “wg0”

解决方案就是升级内核并重启:

sudo apt update
sudo apt upgrade
reboot

我的Ubuntu 20.04(装在Mac mini2012上的),原来的内核版本多少我忘了,反正更新完内核之后,开机会进入busybox。网上说是文件系统出了点问题,改一下就行。但是我这键盘咋敲命令都不行。干脆放弃了,改用华为云服务器(过几天闲下来再重装系统吧,麻了)

3.2 寻找AS Peer

有以下几种途径吧(点进链接看看):

  1. DN42 PingFinder
  2. DN42 services/Automatic Peering
  3. DN42 services/IRC

我图省事就直接选择了第二种。

3.3 wireguard配置

进入/etc/wireguard文件路径下:(看看该文件夹的权限,有可能当前用户没有操作权限,chmod授权一下)

cd /etc/wireguard

生成公私钥:

wg genkey | tee privatekey | wg pubkey > publickey

配置虚拟网卡tunnel.conf:

# tunnel.conf
[Interface]
ListenPort = <replace me>
PrivateKey = <replace me>
PostUp = /sbin/ip addr add dev %i 172.20.163.XXX/32 peer 172.22.119.XXX/32
PostUp = /sbin/ip addr add dev %i fd90::XXXX/128 peer fe80::XXXX/128
Table = off

[Peer]
Endpoint = <replace me>
PublicKey = <replace me>
AllowedIPs = 0.0.0.0/0,::/0

如果双方协商成功的话,这时候配置完tunnel.conf再执行:

# 启动
wg-quick up tunnel
# 停止
wg-quick down tunnel
# 查看链接的详细信息
wg

up之后就可以去ping一下peer对象,看能不能通,能的话就是可达对方的IP了。
在这里插入图片描述
配置的详细信息可参考:
1⃣️wiregurad官网
2⃣️WireGuard 不权威指南:WireGuard搭建与配置详解
3⃣️DN42 howto/wireguard

4 BGP软件:bird

4.1 bird安装

sudo apt install bird

我用Ubuntu18.04安装完的bird版本是1.x
在这里插入图片描述

4.2 bird配置

前面好像忘了说了,我这边只配置了IPv4。

以下配置信息仅关于bird 1.x。bird2的话,可以参考DN42 howto/Bird2

需要替换的信息:

  • Replace with your Autonomous System Number (only the digits)
  • Replace <GATEWAY_IP> with your gateway ip (the internal dn42 ip address you use on the host, where dn42 is running)
  • Replace with your registered dn42 subnet
  • Replace <PEER_IP> with the ip of your peer who is connected with you using your favorite vpn protocol (openvpn, ipsec, tinc, …)
  • Replace <PEER_AS> the Autonomous System Number of your peer (only the digits)
  • Replace <PEER_NAME> a self chosen name for your peer

/etc/bird/bird.conf、/etc/bird/local4.conf和/etc/bird/peers4/<PEER_NAME>三个配置文件的内容直接照搬DN42 howto/Bird,修改一下上述对应的变量就可以了。

这是就可以在虚拟网卡上抓包了。

4.3 Updating ROA tables

此处也仅限IPv4
create the directory to make sure curls can save the files:

mkdir -p /var/lib/bird/

You can add cron entries to periodically update the tables:

curl -sfSLR {-o,-z}/var/lib/bird/bird_roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird1_4.conf && chronic birdc configure

4.4 Useful bird commmands

bird can be remote controlled via the birdc command. Here is a list of useful bird commands:

birdc

在这里插入图片描述

在这里插入图片描述

这里有个restart <protocol>可以重新运行该协议。比如此处可以直接运行

bird> restart lutoma_v4

BGP peer关系就会重新建立并发送Update Message。也可此时重新抓包。

5 tcpdump抓包

tcpdump -i wg0 -w lutoma_hk.pcap
# -i 指定要抓取的网卡
# -w 指定结果保存的位置

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值