From owner-freebsd-net@FreeBSD.ORG Fri Jul 24 04:42:07 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 0312C1065670 for ; Fri, 24 Jul 2009 04:42:07 +0000 (UTC) (envelope-from jamie.ostrowski@gmail.com) Received: from mail-fx0-f218.google.com (mail-fx0-f218.google.com [209.85.220.218]) by mx1.freebsd.org (Postfix) with ESMTP id 7A9EF8FC1C for ; Fri, 24 Jul 2009 04:42:06 +0000 (UTC) (envelope-from jamie.ostrowski@gmail.com) Received: by fxm18 with SMTP id 18so1200313fxm.43 for ; Thu, 23 Jul 2009 21:42:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=/XFtLGrEzyevgM8UXvewG6iBdeX8TLIZNuLIcdgBd3s=; b=JCvstxn9Y/2b4oLN/EPvPfnuv1hwWs+ht573vrmo3LFjPoFAOT2C4vqAgoaZ5Y0Mlu rdn28WLBW4mdNfos1mnV4TcMle2A8x0LKa9Ob77yG0VHxFMXj40+HGt4LC17KkJlC7JU RfNQJybMe7CE+hNdLh30XEUPIkYJ1wI8ROe5c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=ot1+XBlM9FyJLjdpfxfcYD80Vax0CQOTi/kp92GOMCVo/hKD0lNaRKY5mVQtJYQoEp +N0LOYqW4NzH0ZKNMxcKzASgETmZ5IQFkUwOIVACP+6bmZTqKBlHpKo595mMUNQGUJL+ V2bfLz/pCHt86czHU7M/itRnBalepewo0jjHI= MIME-Version: 1.0 Received: by 10.204.119.71 with SMTP id y7mr2786609bkq.16.1248408883922; Thu, 23 Jul 2009 21:14:43 -0700 (PDT) In-Reply-To: <5a3c8f450907230757j21191a11n6cae4699ec8a76e1@mail.gmail.com> References: <5a3c8f450907230757j21191a11n6cae4699ec8a76e1@mail.gmail.com> Date: Thu, 23 Jul 2009 23:14:43 -0500 Message-ID: <29ae62fc0907232114r2afb9dc8y966a22db6d3236bc@mail.gmail.com> From: Jamie Ostrowski To: "Lucian@lastdot.org" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-net@freebsd.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:42:07 -0000 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. - 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" >