How to change default source address?

Jamie Ostrowski jamie.ostrowski at gmail.com
Fri Jul 24 04:42:07 UTC 2009


On Thu, Jul 23, 2009 at 9:57 AM, Lucian at lastdot.org <lucian at lastdot.org>wrote:

> Hi guys,
>
> I need to change the default source address on a freebsd server.
> My situation is somehow similar to this
> (http://marc.info/?l=freebsd-questions&m=122535960804508&w=2).
> In linux i can easily do it like:
>
> ip ro replace default via 10.10.10.1 src a.b.c.d (where a.b.c.d is em0
> alias).
>
> Any ideas?
>


  There may technically be a way to do this. If you set your default route
to the gateway of your secondary network assigned to your card, it will
actually change the source ip of your packets to be coming from the machine.


  For example, let's say I've got my nic configured like this:

   fxp1: 172.16.1.5 netmask 255.255.255.0
   fxp1_alias0: 192.168.0.2 255.255.255.0

  If I do:

   route delete default
   route add default 192.168.0.1

  The machine will send all the packets bound for any default address out
the interface 192.168.0.2 to 192.168.0.1, and it will show up on the other
end of the connection coming from that address, rather than 172.16.1.5.

  Of course, that will only work if, in your case, your secondary ip address
you want to use is on a different subnet than your primary on the machine.
Since you didn't specify, I'm making that assumption.

  Depending on your application, your mileage will vary.


    - Jamie











> _______________________________________________
> freebsd-net at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe at freebsd.org"
>


More information about the freebsd-net mailing list