From owner-freebsd-net@FreeBSD.ORG Fri Jul 24 04:51:45 2009 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A5E731065676 for ; Fri, 24 Jul 2009 04:51:45 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outP.internet-mail-service.net (outp.internet-mail-service.net [216.240.47.239]) by mx1.freebsd.org (Postfix) with ESMTP id 88A828FC1A for ; Fri, 24 Jul 2009 04:51:45 +0000 (UTC) (envelope-from julian@elischer.org) Received: from idiom.com (mx0.idiom.com [216.240.32.160]) by out.internet-mail-service.net (Postfix) with ESMTP id 24D2DADA67; Thu, 23 Jul 2009 21:51:45 -0700 (PDT) X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e Received: from julian-mac.elischer.org (home.elischer.org [216.240.48.38]) by idiom.com (Postfix) with ESMTP id CF09A2D6006; Thu, 23 Jul 2009 21:51:44 -0700 (PDT) Message-ID: <4A693DE2.3050905@elischer.org> Date: Thu, 23 Jul 2009 21:51:46 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.22 (Macintosh/20090605) MIME-Version: 1.0 To: Jamie Ostrowski References: <5a3c8f450907230757j21191a11n6cae4699ec8a76e1@mail.gmail.com> <29ae62fc0907232114r2afb9dc8y966a22db6d3236bc@mail.gmail.com> In-Reply-To: <29ae62fc0907232114r2afb9dc8y966a22db6d3236bc@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-net@freebsd.org, "Lucian@lastdot.org" Subject: Re: How to change default source address? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jul 2009 04:51:45 -0000 Jamie Ostrowski wrote: > On Thu, Jul 23, 2009 at 9:57 AM, 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"