2

I have a FreeBSD 8.0 virtual box with two ethernet interfaces, em0 and em1. em0 is 192.168.1.99 and em1 is 192.168.1.100. Both are "Attached to: Bridged Adapter".

When both are up, if I say

# route add default 192.168.1.1
# netstat -rn
# default            192.168.1.1        UGS         1        6    em0

So far so good. It picked em0.

# ifconfig em0 down
# route delete 0.0.0.0
# route add default 192.168.1.1
# netstat -rn
# default            192.168.1.1        UGS         1        6    *em0*

Ok. So it still picks em0 (it must really like it) even if it's down. I have tested and if I pick another ip (say 10.0.0.1) for em0 it pickes em1 for the route.

This leaves me wondering: how can I make freebsd choose em1 as the outgoing interface ? In linux I remember we could do it with the dev argument.

P.S. I did try using the -interface option - no luck. I tried

# route add default 192.168.1.1 -interface 192.168.1.100
# route add default 192.168.1.1 -interface em1

The result was

0.0.0.0&0xc0a80164 192.168.1.1        US          0        0    em0 =>

I am using FreeBSD 8.0-STABLE. Any help will be appreciated.

EDIT: On Debian Lenny the same suite of operations correctly picks the interface that is up as outgoing interface. When both are up

route add default gw 192.168.1.1

picks eth2 route add default gw 192.168.1.1 dev eth0 picks eth0

So there must be a way to achieve this on FreeBSD, right ?

0

3 Answers 3

1

It sounds like you want two IPs and redundant connections. If that's the case you want to create a LAGG adapter, attach it to the two NICs, and put the IPs on the LAGG interface.

If that's not the case can you describe exactly what you're trying to accomplish?

11
  • While this is quite sensible, it doesn't answer my question. For some obscure reason I want to choose the outgoing interface. Perhaps I like one of them better. Perhaps there is an actual pertinent reason I can;t think of right now.
    – nc3b
    Commented Aug 6, 2010 at 20:14
  • 1
    Well start with why you have two NICs that are both attached to the same network?? What you're asking for amounts to a configuration that was never meant to be supported.
    – Chris S
    Commented Aug 6, 2010 at 20:24
  • So having an interface down (em0) with an ip in that subnet and an interface up (em1) with an ip in the same subnet is not supported ?
    – nc3b
    Commented Aug 6, 2010 at 20:31
  • 1
    Having two NICs connected to the exact same network and wanting to configure them totally independently is unsupported, yes. While it will obviously work for a great many things, it's not recommended, and you'll run into odd problems, as you already have. There is no reason to configure it this way.
    – Chris S
    Commented Aug 6, 2010 at 20:43
  • OK, so the last word is that this it can't be done ? I don't mean to be rude but I believe it can be done and it is simply a bug in route that it's not allowing it. (Not a very good argument but: if the linux crowd supports it I belive someone in some dark corner of the internet once needed it).
    – nc3b
    Commented Aug 6, 2010 at 20:50
9

You need to use -ifp flag, not -interface.

2
  • 1
    Could you expand on that a bit please ?
    – user9517
    Commented Oct 4, 2012 at 6:50
  • This! I'm using a Mac and this works for me. According to man route(8), -ifp specifies the interface name. Commented Oct 6, 2014 at 7:08
-1

You should take a look at the "Link Aggregation and Failover" in the FreeBSD Handbook here https://www.freebsd.org/doc/handbook/network-aggregation.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .