Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 98a8749

Browse files
[baseimage]: Avoid removing localhost entry from /etc/hosts file (sonic-net#2452)
- What I did This fix removes the possibility of 'localhost' entry getting removed from /etc/hosts file by hostname-config service. Without this change, whenever we change the hostname from 'localhost' to any other name on the config_db.json and reload the config, /etc/hosts file will only have the new hostname on it. But there are multiple sonic utilities (eg: swssconfig) which relies on the hard coded 'localhost' name and they tend to stop working. - How I did it Added a new check on hostname-config.sh script to avid blindly deleting the line containing the old hostname from /etc/hosts file. Now it will delete the old hostname only if its not localhost or when the hostname is not changing. - How to verify it Bring up SONiC on a device with hostname as localhost Edit /etc/sonic/config_db.json to update the 'hostname' filed under DEVICE_METADATA from "hostname" : "localhost" --> "hostname" : "sonic" run config reload -y to reflect the hostname change done on config_db.json file. cat /etc/hosts and check whether both 127.0.0.1 localhost and 127.0.0.1 sonic entry are present on the file. ping localhost should work fine. - Description for the changelog Make hostname-config service more robust in handling SONiC hostname change from localhost to anything else. Change-Id: I4599bcaade05331d737f3e70f449dd51f7c636bb
1 parent ba3569c commit 98a8749

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)