I recently had a conversation with a Linux user regarding running multiple instances of JBoss on a single machine. In general, this isn’t a problem, but you need to configure each instance to use different ports, or run on different interfaces. Configuring different ports is a bit of a pain, and I haven’t quite figured out how to setup “virtual” interfaces on Leopard.


Enter IP aliasing. IP aliasing has been supported on OS X for a while (I found posts back to at least 10.2), but some things have changed in Leopard that make it useful to update some of the existing information out there. For one, the file /etc/iftab no longer exists, and niutil (another option) is no longer available, either.


Bearing that in mind, what follows is actually quite simple. The sample I show is for aliasing multiple localhost interfaces (useful if you’re doing primarily local testing). The same approach can be used for “real” interfaces (Airport & Ethernet come to mind), but you’ll need to assign addresses manually, DHCP won’t work as far as I can tell). This is all “admin” stuff, so you’ll need admin privileges to execute these commands.


The following script takes the loopback interface (lo0) down, sets up two IP aliases, then brings it back up.


sudo ifconfig lo0 down

sudo ifconfig lo0 alias 127.0.0.1 netmask 255.255.255.0

sudo ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.0

sudo ifconfig lo0 up


Running the following should show you two IPs for your loopback interface.


MacBook2:~ bruth$ ifconfig lo0

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384

inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1

inet 127.0.0.1 netmask 0xffffff00

inet6 ::1 prefixlen 128

inet 127.0.0.2 netmask 0xffffff00


I haven’t yet figured out what I can edit on Leopard to make these settings stick, so instead I’ve created an Application with Automator to reconfigure the loopback interface whenever I login.


You can download the Automator workflow here (.zip). Running the workflow from Automator itself doesn’t seem to work on my system - I had to save it as an Application, then run it - and that works. Not sure if the call to “System Events” to setup the sudo password is what hangs in Automator, maybe.


Just Save As... an Application (save it anywhere you like), then add to your Login Items. It should prompt for your password when you login (sorry, I think this is necessary) and then reconfigure the interface. Credit goes to Aric’s Tech Blog for providing the Automator skeleton to run commands with sudo.

Wednesday, October 31, 2007

 
 
Made on a Mac
next >../../../Archive.htmlshapeimage_4_link_0
< previous../../../Get_er_done.htmlshapeimage_5_link_0