resolv.conf is being overwritten after container reboot

Refers to:

  • Plesk 12.0 for Linux

Created:

2016-11-16 13:14:29 UTC

Modified:

2016-12-21 20:16:00 UTC

0

Was this article helpful?


Have more questions?

Submit a request

resolv.conf is being overwritten after container reboot

Symptoms

resolv.conf is getting overwritten after container restart, all changes to the file are lost.

  1. Right after the start configuration file has nameserver and searchdomain set:

    [root@pvcfl ~]# vzctl start 100500
    Container is mounted
    Starting the Container ...
    Setting permissions 20002 dev 0x7d00
    Adding offline management to Container(1): 4643 8443 4649
    Adding IP addresses:
    Hostname of the Container set: container.tld
    File resolv.conf was modified
    Starting the Container ...
    [root@pvcfl ~]# vzctl exec 100500 cat /etc/resolv.conf
    nameserver 192.168.55.1
    search parallels.com
  2. We can rewrite the file, and changes will take effect:

    [root@pvcfl ~]# vzctl exec 100500 'echo "nameserver 10.20.30.40" > /etc/resolv.conf'
    [root@pvcfl ~]# vzctl exec 100500 cat /etc/resolv.conf
    nameserver 10.20.30.40
  3. However, after container restart all changes will be lost again:

    [root@pvcfl ~]# vzctl restart 100500
    Restart the Container
    Stopping the Container ...
    Stop the Container...
    Container was stopped
    Container is unmounted
    Container is mounted
    Starting the Container ...
    Setting permissions 20002 dev 0x7d00
    Adding offline management to Container(1): 4643 8443 4649
    Adding IP addresses:
    Hostname of the Container set: container.tld
    File resolv.conf was modified
    Starting the Container ...
    [root@pvcfl ~]# vzctl exec 100500 cat /etc/resolv.conf
    nameserver 192.168.55.1
    [root@pvcfl ~]#

Cause

Parallels Virtuozzo Containers controls /etc/resolv.conf configuration file if NAMESERVER or SEARCHDOMAIN values are specified in the container's configuration file:

[root@pvcfl ~]# grep -e NAMESERVER -e SEARCHDOMAIN /etc/vz/conf/100500.conf
NAMESERVER="192.168.55.1"
SEARCHDOMAIN="parallels.com"

Resolution

Parallels Virtuozzo Containers won't overwrite /etc/resolv.conf if NAMESERVER or SEARCHDOMAIN settings are not set, thus if you want to give full control of the file to the container's user, you can unset these values:

[root@pvcfl ~]# vzctl unset 100500 --searchdomain --nameserver --save
Unset parameters for Container 100500
[root@pvcfl ~]# grep -e NAMESERVER -e SEARCHDOMAIN /etc/vz/conf/100500.conf
[root@pvcfl ~]#

Alternatively, you can just specify the correct nameserver or/and searchdomain with the help of vzctl tool:

[root@pvcfl ~]# vzctl set 100500 --nameserver 10.20.30.40 --searchdomain test.tld --save
File resolv.conf was modified
Saved parameters for Container 100500
[root@pvcfl ~]# grep -e NAMESERVER -e SEARCHDOMAIN /etc/vz/conf/100500.conf
NAMESERVER="10.20.30.40"
SEARCHDOMAIN="test.tld"
[root@pvcfl ~]#
Have more questions? Submit a request
Please sign in to leave a comment.