-1

In a home network environment, I'm hosting a web server but my ISP keeps giving me different but dynamic IP address via DHCP (dhclient here).

The system is running systemd (and not rc.d initd).

How do I ensure that Apache 2.4 is ONLY listening to that interface (of changing IP addresses)?

Caveats:

  • I don't want Apache 2.4 listening on my other 3 NIC interfaces (I've got a test network, a cable-provider network, and a WiFi network, each have their own web servers).
  • Firewall approach is not the best approach option here (besides Apache2 must know IP address somehow in advance and should selectively listen to a specified interface ... for compartmentability sake.)
John Greene
  • 899
  • 10
  • 30
  • Servers (with or without Faults) don't have dynamic IP addresses. For the rest of us `Listen 192.0.2.1:80` is all we need. – Esa Jokinen May 20 '17 at 17:57
  • So you are willing to trust application web server to keep their content separate between interfaces (public and business-private)? – John Greene May 20 '17 at 18:00
  • Having more than one interface is standard practice for servers where you wish to differentiate admin and application traffic. Having them dynamically allocated to different IPs is not. – Jenny D Jun 02 '17 at 16:56

1 Answers1

2

You can make Apache only listen to certain IP and port with Listen 192.0.2.1:80 and you can even bind VirtualHosts to a single interface with <VirtualHost 192.0.2.1:80>. The only problem here is the dynamic IP which would require dynamic configuration.

One possible solution could be to include the Listen directive from separate configuration file, making it easier to replace. Then make a script that replaces the IP in this configuration file and restarts Apache. This script could be lauched for example with up of the iface configuration in /etc/network/interfaces.

But there's no direct way. Servers are supposed to have static IP addresses.

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129