栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

DN42 - 接入DN42网络平台

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

DN42 - 接入DN42网络平台

DN42 - 接入DN42网络平台
  • 1 注册AS
  • 2 Linux系统配置
  • 3 建立隧道:wireguard
    • 3.1 wireguard安装
    • 3.2 寻找AS Peer
    • 3.3 wireguard配置
  • 4 BGP软件:bird
    • 4.1 bird安装
    • 4.2 bird配置
    • 4.3 Updating ROA tables
    • 4.4 Useful bird commmands
  • 5 tcpdump抓包

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 =
PrivateKey =
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 =
PublicKey =
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 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 with the ip of your peer who is connected with you using your favorite vpn protocol (openvpn, ipsec, tinc, …)
  • Replace the Autonomous System Number of your peer (only the digits)
  • Replace a self chosen name for your peer

/etc/bird/bird.conf、/etc/bird/local4.conf和/etc/bird/peers4/三个配置文件的内容直接照搬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 可以重新运行该协议。比如此处可以直接运行

bird> restart lutoma_v4

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

5 tcpdump抓包

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/836298.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号