Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Jul 2009 21:51:46 -0700
From:      Julian Elischer <julian@elischer.org>
To:        Jamie Ostrowski <jamie.ostrowski@gmail.com>
Cc:        freebsd-net@freebsd.org, "Lucian@lastdot.org" <lucian@lastdot.org>
Subject:   Re: How to change default source address?
Message-ID:  <4A693DE2.3050905@elischer.org>
In-Reply-To: <29ae62fc0907232114r2afb9dc8y966a22db6d3236bc@mail.gmail.com>
References:  <5a3c8f450907230757j21191a11n6cae4699ec8a76e1@mail.gmail.com> <29ae62fc0907232114r2afb9dc8y966a22db6d3236bc@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Jamie Ostrowski wrote:
> On Thu, Jul 23, 2009 at 9:57 AM, Lucian@lastdot.org <lucian@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.

you could set up 2 routing tables and assign different apps to use 
different tables.

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A693DE2.3050905>