Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


BGP VM with BIRD2, how to route outgoing traffic via the IP in the dummy adapter instead of main IP?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

BGP VM with BIRD2, how to route outgoing traffic via the IP in the dummy adapter instead of main IP?

dnwkdnwk Member

With below configuration, I could ping the IP and access the IP on the dummy adapter. However, on the server, when I try to run curl ifconfig.co/ I got my main IP. How do I set the dummy to the default route?
Thanks

Here is my BIRD2 configure

define OURASN = ;
define OURIPv6 = ;
define OURIPv4 = ;
define OURIPv6_2 = ;
define MyIPV6Block =;
log syslog all;

router id OURIPv4;

protocol device {
        scan time 5;
}

protocol direct {
        interface "dummy*";
        ipv6;
}

protocol static localmap{
        ipv6;
        route MyIPV6Block via OURIPv6%ens19;
}
protocol kernel {
        ipv6 { import all; };
        learn;
}

protocol bgp s1{
        description "s1";
        local OURIPv6 as OURASN;
        interface "ens18";
        neighbor NEIGHBOURIP1 as NEIGHBOURAS1;
        ipv6 {
                import all;
                export where proto = "localmap";
        };
}

protocol bgp s2{
        description "s2";
        local OURIPv6_2 as OURASN;
        neighbor NEIGHBOURIP2fas NEIGHBOURAS2;
        interface "ens19";
        ipv6 {
                import all;
                export where proto ="localmap";
        };
}

Here is how I add IP to dummy

ip link add dev dummy1 type dummy
ip link set dummy1 up
ip addr add dev dummy1 MYIPV6ADDRESS

Comments

  • you can do that with ip r add default $GW src $DUMMYIP metric 256 , or have bird export the routes to kernel table with krt_prefsrc.

  • dnwkdnwk Member

    @cadddr said:
    you can do that with ip r add default $GW src $DUMMYIP metric 256 , or have bird export the routes to kernel table with krt_prefsrc.

    Could you show me an example of full Kernel config? And for $GW, what is my $GW, I haven't figured out. Is it the same as my VM's public IP?

  • doghouchdoghouch Member
    edited August 2022

    @dnwk said:

    @cadddr said:
    you can do that with ip r add default $GW src $DUMMYIP metric 256 , or have bird export the routes to kernel table with krt_prefsrc.

    Could you show me an example of full Kernel config? And for $GW, what is my $GW, I haven't figured out. Is it the same as my VM's public IP?

    • $GW refers to your gateway. The command above adds a ‘default’ route, which means (in general) that traffic will be routed through there when trying to access resources on the Internet. Think of it like this: you’re on a remote island and you can send requests locally. Any ‘international’ traffic needs to go through an airport (gateway) to reach other networks.
    • The ‘metric’ value is a sort of ‘priority’ number — the lower the metric => the more the route is preferred.
    • The gateway is not the same as your public IP.
  • cadddrcadddr Member
    edited August 2022
    protocol kernel {
        learn on;
    
        ipv6 {
            import all;
            export filter {
                if source !~ [RTS_STATIC, RTS_BGP] then reject;
    
                krt_prefsrc = OURIPV6;
                accept;
            };
        };
    }
    

    This would export all routes(~150k) to the kernel table with the preferred src attribute. Replace OURIPV6 with $DUMMYIP.

    Since you can reach your announced ips without exporting anything i presume the same gateway(that you configured for the vm, check with ip -6 r get ::/0) is used as the nexthop.

  • dnwkdnwk Member

    @cadddr said:

    protocol kernel {
        learn on;
    
        ipv6 {
            import all;
            export filter {
                if source !~ [RTS_STATIC, RTS_BGP] then reject;
    
                krt_prefsrc = OURIPV6;
                accept;
            };
        };
    }
    

    This would export all routes(~150k) to the kernel table with the preferred src attribute. Replace OURIPV6 with $DUMMYIP.

    Since you can reach your announced ips without exporting anything i presume the same gateway(that you configured for the vm, check with ip -6 r get ::/0) is used as the nexthop.

    Success! Thanks! With this kernel configure, my outgoing IP is set to the one in my dummy adapter!
    By the way, ip -6 r get ::/0 doesn't work. it says "need at least a destination address"

  • @dnwk said: By the way, ip -6 r get ::/0 doesn't work.

    Try ip -6 r show ::/0.

    Thanked by 1Lutung
  • dnwkdnwk Member

    What does bgp_path.prepend AS Path prepending do? Does it make incoming connection to choose the preferred upstream?

  • rubenruben Member, Host Rep

    @dnwk said: What does bgp_path.prepend AS Path prepending do?

    The effect depends on where you put it, on import or export.
    Usually, it's in the export filter. When prepending a prefix on export, the path for a prefix becomes longer for the peer, hence usually less preferred for inbound traffic.

    That said, a peer may have a preference set on their import filter, which overrules the as-path length.

    Thanked by 1dnwk
Sign In or Register to comment.