0

I have a linux machine configured with both static IP and DHCP. I got a requirement that when the linux machine got IP using DHCP then that linux machine should only be accessible using DHCP IP, It should never be accessible by static IP which was configured already manually.

But when DHCP is down then the linux machine needs to be accessible by static IP automatically.

For example: -> LinuxMachine is configured manually with static IP 192.168.1.1. - > the same machine is configured with DHCP(client) enabled -> Now the machine got DHCP IP 192.168.1.15 (Automatically) after bootup

Requirement is the Linux machine to be accessible by DHCP IP 192.168.1.15 only and it should not be accessible by static IP 192.168.1.1.

Is this possible to disable/enable static IP access automatically?

5
  • Could you provide more info ? What service is managing your network interfaces ? Maybe this can help askubuntu.com/questions/1186636/… ?
    – golder3
    Apr 28 at 7:35
  • The Linux machine I am using here is an embedded board with customized linux on it. It is not laptop or any PC. DHCP client is configured with static IP on this embedded board via systemd service. Embedded board is connected to the router(may contain DHCP server). We are handling all the worst case scenarios.Need to test following scenario: When DHCP IP is assigned to the board by the DHCP server(router), then the board should not be accessible by using static IP. Board should only be accessible by DHCP IP. Currently we are able to access the board using both the IP's(Static and DHCP). Apr 28 at 11:19
  • Do you have a systemd service file ? You can write another service which would check IP addresses and disable static IP and you can start it after the service that configures DHCP client. Do you know when and why DHCP isn't working ?
    – golder3
    Apr 28 at 20:20
  • Actually this is worst case scenario test. To remove the board to be accessed by static IP when DHCP is enabled. I am not sure how to check if DHCP is enabled/disabled. Apr 29 at 8:22
  • I planned the following way to check if DHCP enabled/disabled, though not sure if it works: 1) Checking ifconfig will show ip address on DHCP port then will consider it as DHCP enabled 2) If no ip address on DHCP port assigned to the board then will consider as DHCP disabled. Apr 29 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.