下面是所以命令 仅供参考,
拓扑是:
ns6 ns7模拟的是路由器,ns5 和 ns8 是两边的AS。
# brctl addbr br5
# brctl addbr br8
# brctl addbr br9
ip netns add ns5
ip netns add ns6
ip netns add ns7
ip netns add ns8
ip link add name ns5-0 type veth peer name ns5-br8
ip link add name ns6-0 type veth peer name ns6-br8
ip link add name ns6-1 type veth peer name ns6-br5
ip link add name ns7-0 type veth peer name ns7-br5
ip link add name ns7-1 type veth peer name ns7-br9
ip link add name ns8-0 type veth peer name ns8-br9
ip link set ns5-0 netns ns5
ip link set ns6-0 netns ns6
ip link set ns6-1 netns ns6
ip link set ns7-0 netns ns7
ip link set ns7-1 netns ns7
ip link set ns8-0 netns ns8
brctl addif br8 ns5-br8
brctl addif br8 ns6-br8
brctl addif br5 ns6-br5
brctl addif br5 ns7-br5
brctl addif br9 ns7-br9
brctl addif br9 ns8-br9
ip netns exec ns5 ip ad add 10.0.1.5/24 dev ns5-0
ip netns exec ns6 ip ad add 10.0.1.6/24 dev ns6-0
ip netns exec ns6 ip ad add 10.0.2.5/24 dev ns6-1
ip netns exec ns7 ip ad add 10.0.2.6/24 dev ns7-0
ip netns exec ns7 ip ad add 10.0.3.6/24 dev ns7-1
ip netns exec ns8 ip ad add 10.0.3.5/24 dev ns8-0
ip netns exec ns5 ip link set dev ns5-0 up
ip link set dev ns5-br8 up
ip netns exec ns6 ip link set dev ns6-0 up
ip link set dev ns6-br8 up
ip netns exec ns6 ip link set dev ns6-1 up
ip link set dev ns6-br5 up
ip netns exec ns7 ip link set dev ns7-0 up
ip link set dev ns7-br5 up
ip netns exec ns7 ip link set dev ns7-1 up
ip netns exec ns8 ip link set dev ns8-0 up
ip link set dev ns7-br9 up
ip link set dev ns8-br9 up
ip link set dev br4 up
ip link set dev br5 up
ip link set dev br6 up
ip link set dev br7 up
ip link set dev br8 up
ip link set dev br9 up
ip netns exec ns6 bird -c /root/bird-ns6.conf -s /run/bird/bird-ns6
ip netns exec ns7 bird -c /root/bird-ns7.conf -s /run/bird/bird-ns7
# cat bird-ns6.conf
log syslog { debug, trace, info, remote, warning, error, auth, fatal, bug };
log "/tmp/bird-ns6.log" all;
router id 10.0.2.5;
debug protocols all;
protocol kernel {
persist; # Don't remove routes on bird shutdown
scan time 20; # Scan kernel routing table every 20 seconds
export all; # Default is export none
}
protocol device {
scan time 10; # Scan interfaces every 10 seconds
}
protocol direct {
interface "ns6-0";
}
protocol static {
debug all;
}
protocol ospf {
import all;
export all;
area 0.0.0.0 {
interface "ns6-1" {
hello 9;
retransmit 6;
cost 10;
transmit delay 5;
dead count 60;
wait 10;
type bcast;
};
};
}
# cat bird-ns7.conf
log syslog { debug, trace, info, remote, warning, error, auth, fatal, bug };
log "/tmp/bird-ns7.log" all;
router id 10.0.2.6;
debug protocols all;
protocol kernel {
persist; # Don't remove routes on bird shutdown
scan time 20; # Scan kernel routing table every 20 seconds
export all; # Default is export none
}
protocol device {
scan time 10; # Scan interfaces every 10 seconds
}
protocol direct {
interface "ns7-1";
}
protocol static {
debug all;
}
protocol ospf {
import all;
export all;
area 0.0.0.0 {
interface "ns7-0" {
hello 9;
retransmit 6;
cost 10;
transmit delay 5;
dead count 60;
wait 10;
type bcast;
};
};
}
root@wrt:~# ip netns exec ns7 ip ro
10.0.1.0/24 via 10.0.2.5 dev ns7-0 proto bird
10.0.2.0/24 dev ns7-0 proto kernel scope link src 10.0.2.6
10.0.3.0/24 dev ns7-1 proto kernel scope link src 10.0.3.6
~# ip netns exec ns7 birdc
BIRD 1.6.4 ready.
bird> show route
10.0.2.0/24 dev ns6-1 [ospf1 11:25:22] * I (150/10) [10.0.2.5]
10.0.3.0/24 via 10.0.2.6 on ns6-1 [ospf1 11:33:15] * E2 (150/10/10000) [10.0.2.6]
10.0.1.0/24 dev ns6-0 [direct1 11:25:21] * (240)
bird>
bird> exit
参考:https://github.com/qmcclab/blog/blob/master/bird-on-openwrt.md
阅读(2097) | 评论(0) | 转发(0) |