Two Networks on one System

Gary Gatten Ggatten at waddell.com
Mon Jun 20 22:30:18 UTC 2011


On 6/20/11 5:07 PM, Martin McCormick wrote:

> 	We are moving a primary name server from network A to
> network B on one of our branch campuses. If the secondary
> interface was reachable from the world, we can change the whois
> information and not worry about the exact second the change goes
> in to effect.

Can networks A and B talk to each other?  I suspect not, otherwise 
things would be just working even if all traffic went to the primary's 
gateway, but I just wanted to check that there wasn't something else bad 
happening.

On the assumption that A and B are completely disconnected, then the 
only solution for this problem that I know of is to do policy-based 
routing using the source address or interface to make routing decisions, 
rather than using solely the destination address.

This is actually relatively trivial to do using PF.

pass in on nic_a reply-to ($nic_a $gw_a)
pass in on nic_b reply-to ($nic_b $gw_b)

with the various interfaces named appropriately and variables set to 
match should get you much of the way there.  If you're using a slightly 
older version of PF, where keeping state on connections is not the 
default, you'll have to add state maintenance options to the lines.  If 
you want packets to local machines to not go to the gateways and do 
u-turns there, you'll have to add a bit of filtering based on addresses, 
etc., etc.

The explanation for the first line is more or less:

For any new "connection" that comes in on NIC A, add an entry to the 
state table indicating that any reply packets should physically go out 
NIC A and should be passed to the next hop at adress $gw_a.

WARNING:  I use PF primarily on OpenBSD so sometimes get caught out on 
the subtle differences to the FreeBSD version.



I was kinda going this route as well - policy based routing type thing, but, is there an "easier" way?

1.) Temporarily enable ipforwarding - not my favorite
2.) Instead of a second NIC, bind the new IP to the org nic (alias).

man ifconfig specifically mentions using alias during ip renumbering:

" alias   Establish an additional network address for this interface.  This
is sometimes useful when changing network numbers, and one wishes to accept packets addressed to the old interface.  If the address is on the same subnet as the first network address for this interface, a non-conflicting netmask must be given.  Usually 0xffffffff is most appropriate."

Once everything is transitioned, you may reconfigure the interface with the "permanent" config.

G







<font size="1">
<div style='border:none;border-bottom:double windowtext 2.25pt;padding:0in 0in 1.0pt 0in'>
</div>
"This email is intended to be reviewed by only the intended recipient
 and may contain information that is privileged and/or confidential.
 If you are not the intended recipient, you are hereby notified that
 any review, use, dissemination, disclosure or copying of this email
 and its attachments, if any, is strictly prohibited.  If you have
 received this email in error, please immediately notify the sender by
 return email and delete this email from your system."
</font>



More information about the freebsd-questions mailing list