Apache HTTP Server Bind by MAC Address

apache-2.2socket

I have 2 ethernet ports on my machine, both receiving their IP addresses via DHCP.

I would like to run essentially two web servers on the machine. Technically, I would like to run Apache on one address/port combination, and Node.js listening on port 80 on the other ethernet port.

All Apache documentation I've found mentions using the Listen directive for specifying which address/port Apache should listen on. The only problem is that my IP addresses are dynamic, and I don't want to bother changing the config every time my IP changes.

Is there anyway to tell Apache to bind to a specific MAC address?

I'm pretty sure the answer is no, considering the socket bind function appears to require an IP address, unless it's smart enough to take a MAC or port name, and lookup the associated IP.

Best Answer

Servers are just not meant to run on dynamic IPs. I don't believe you can get apache to listen on a MAC address, but I can suggest two possible work arounds:

  1. have the two web services run on different ports rather than different IPs - EASY
  2. hack the apache startup script so that it detects the IP addresses on the two cards, and then edits the config file before actually starting the server - MESSY HACK