LINUX.ORG.RU
решено ФорумAdmin

Bird не принимает маршруты после запуска

 , , ,


1

1

У меня почему-то bird сегодня все маршруты от пира отфильтровал. Вот фольтр:

gw=bgp_next_hop; if net = ::/0 then reject; else accept;

Самое интересное, что после перезапуска, всё стало работать. Причём сколько я дёргал, так баг воспроизвести не получилось. Bird запускается в netns. Сам netns инициализируется через init скрипт. Вот скрипт инициализации netns:

#!/bin/bash
# Configuration
EXT_INTERFACES="eth1"
NS_NAME="vrouter"
start () {
	if [ -f /opt/bird/var/run/bird.pid ]
	then
		kill `cat /opt/bird/var/run/bird.pid `
	fi
		
	if [ -f /run/netns/${NS_NAME} ]
	then
		for a in $EXT_INTERFACES
		do
			ip -netns $NS_NAME link set dev $a netns 1
		done	
		ip netns del ${NS_NAME}
	else
		true
	fi
	ip netns add ${NS_NAME}
	for a in $EXT_INTERFACES
	do
		ip link set dev $a netns ${NS_NAME}
	done
	ip link add dev vr0p0 type veth peer name vr0p1 
        ip link add dev vr1p0 type veth peer name vr1p1 
	ip link set dev vr0p0 mtu 65535
	ip link set dev vr0p0 up
        ip link set dev vr1p0 mtu 9000
        ip link set dev vr1p0 up
	ip link set dev vr0p1 netns $NS_NAME
	ip -netns $NS_NAME link set dev lo up
	ip -netns $NS_NAME link set dev vr0p1 up
	ip -netns $NS_NAME link set dev vr0p1 mtu 65535
        ip link set dev vr1p1 netns $NS_NAME
        ip -netns $NS_NAME link set dev vr1p1 up
        ip -netns $NS_NAME link set dev vr1p1 mtu 9000
	ip -netns $NS_NAME link add dev phy-net type bridge
	ip -netns $NS_NAME link set dev phy-net up
	ip -netns $NS_NAME link set dev vr1p1 master phy-net
	for a in $EXT_INTERFACES
	do
		ip -netns $NS_NAME link set dev $a up
		ip -netns $NS_NAME link set dev $a master phy-net
	done
	ip -netns $NS_NAME addr add 198.18.120.10/24 brd 198.18.120.255 dev phy-net
	#ip -netns $NS_NAME route add default via 198.18.120.1
	ip -netns $NS_NAME addr add 2a01:d0:c353:82::10/112 dev phy-net
	ip -netns $NS_NAME route add default via 2a01:d0:c353:82::1
	echo 1|ip netns exec $NS_NAME tee /proc/sys/net/ipv4/ip_forward
        echo 1|ip netns exec $NS_NAME tee /proc/sys/net/ipv6/conf/all/forwarding
	
	ip -netns $NS_NAME link add link vr0p1 name vlan101 type vlan id 101
	ip -netns $NS_NAME link set dev vlan101 up
	ip -netns $NS_NAME link set dev vlan101 mtu 9000
	ip -netns $NS_NAME addr add 192.168.254.6/30 brd 192.168.254.7 dev vlan101
	ip -netns $NS_NAME addr add 2001:db8:8:3c::5/126 dev vlan101
	ip -netns $NS_NAME link add link eth1 name vlan72 type vlan id 72
	ip -netns $NS_NAME link set dev vlan72 up
	#ip -netns $NS_NAME link set dev vlan72 mtu 9250
	ip -netns $NS_NAME addr add 198.18.125.25/30 brd 198.18.125.27 dev vlan72
	ip -netns $NS_NAME addr add 2001:db8:8:3c::2/126 dev vlan72
	ip netns exec $NS_NAME iptables -t nat -A PREROUTING -p tcp --dport 179 -j ACCEPT
	ip netns exec $NS_NAME ip6tables -t nat -A PREROUTING -p tcp --dport 179 -j ACCEPT
	ip netns exec $NS_NAME iptables -t nat -A POSTROUTING -p tcp --dport 179 -j ACCEPT
	ip netns exec $NS_NAME ip6tables -t nat -A POSTROUTING -p tcp --dport 179 -j ACCEPT
	ip netns exec $NS_NAME iptables -t nat -A PREROUTING  -d 198.18.120.10/32 -j DNAT --to 192.168.254.1
        ip netns exec $NS_NAME iptables -t nat -A POSTROUTING  -s 192.168.254.0/24 -d 192.168.254.0/24 -j ACCEPT
	ip netns exec $NS_NAME iptables -t nat -A POSTROUTING  -s 192.168.254.1/32 -j SNAT --to 198.18.120.10
	ip netns exec $NS_NAME iptables -t nat -A POSTROUTING -s 192.168.254.5/32 -j SNAT --to 198.18.120.10
	ip netns exec $NS_NAME iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
	ip netns exec $NS_NAME ip6tables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
	ip netns exec $NS_NAME ip6tables -t nat -A PREROUTING  -d 2a01:d0:c353:82::10/128 -j DNAT --to 2001:db8::1
	ip netns exec $NS_NAME ip6tables -t nat -A POSTROUTING  -s 2001:db8::1 -j SNAT --to 2a01:d0:c353:82::10
	ip -netns $NS_NAME rule add from 192.168.254.0/24 to 192.168.254.0/24 table main pref 1
	#ip -netns $NS_NAME rule add to 198.18.120.0/24 table main pref 1
        #ip -6 -netns $NS_NAME rule add to 2a01:d0:c353:82::/64 table main pref 1
        #ip -netns $NS_NAME rule add from 198.18.120.0/24 table main pref 1
        #ip -6 -netns $NS_NAME rule add from 2a01:d0:c353:82::/64 table main pref 1
        ip -6 -netns $NS_NAME rule add from 2001:db8::/112 to 2001:db8:8:3c::/112 table main pref 1
        ip -6 -netns $NS_NAME rule add from 2001:db8::/112 to 2001:db8::/112 table main pref 1
	ip -netns $NS_NAME rule add from 192.168.254.0/30 to 198.18.0.0/15 table main pref 1
	ip -6 -netns $NS_NAME rule add from 2001:db8::/126  to 2a01:d0:c353::/48 table main pref 1
        ip -netns $NS_NAME rule add from 192.168.254.4/30 to 198.18.0.0/15 table main pref 2
        ip -6 -netns $NS_NAME rule add from 2001:db8::4/126  to 2a01:d0:c353::/48 table main pref 2
        ip -netns $NS_NAME rule add from 192.168.254.0/30 table 10 pref 3
        ip -6 -netns $NS_NAME rule add from 2001:db8::/126 table 10 pref 3
	ip -netns $NS_NAME rule add from 192.168.254.4/30  table 10 pref 10
	ip -6 -netns $NS_NAME rule add from 2001:db8::4/126  table 10 pref 10
	#ip -6 -netns $NS_NAME rule add to 2a01:d0:c353:82::/64 iif vlan101 table 12 pref 3
	#ip -netns  $NS_NAME rule add to 198.18.120.0/24 iif vlan101 table 11 pref 3
	ip -netns $NS_NAME route add default via 198.18.125.26 table 11
	ip -6 -netns $NS_NAME route add default via 2001:db8:8:3c::1 table 12
	ip -netns $NS_NAME addr add 192.168.254.2/30 dev vr0p1
	ip -netns $NS_NAME addr add 2001:db8::2/126 dev vr0p1
}
stop () {
		if [ -f /opt/bird/var/run/bird.pid ]
		then
			kill `cat /opt/bird/var/run/bird.pid `
		fi
		for a in $EXT_INTERFACES
		do
			ip -netns $NS_NAME link set dev $a netns 1
		done	
		ip netns del ${NS_NAME}
	
}
exec_bird () {
	if [ -f /run/netns/${NS_NAME} ]
	then
		PATH=$PATH:/opt/bird/sbin
		ip netns exec $NS_NAME bird -c /opt/bird/etc/bird.conf -s /opt/bird/var/run/bird.ctl -u vrouter -g vrouter -P /opt/bird/var/run/bird.pid
	fi
}
stop_bird () {
	if [ -f /opt/bird/var/run/bird.pid ]
	then
		kill `cat /opt/bird/var/run/bird.pid `
	fi		 
}
case $1 in
	start)
		start
		exec_bird
		;;
	stop)
		#stop_bird
		stop
		;;
	bird_exec)
		exec_bird
		;;
	bird_kill)
		stop_bird
		;;
esac

Сам init-скрипт:

#!/bin/bash
### BEGIN INIT INFO
# Provides:          vrouter
# Required-Start:    mountkernfs $local_fs urandom
# Required-Stop:     $local_fs
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: Virtual router namespace
# Description:       Init virtual router
### END INIT INFO
/scripts/vrouter.sh $1
★★★★★

Весь конфиг bird покажи

Pinkbyte ★★★★★
()

Проблема была в DAD. IPv6 почему-то с задержкой прописывал nwxt-hop.

ne-vlezay ★★★★★
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.