云服务器 ECS Ubuntu 系统修改 DNS 配置文件 i 属性报错:Operation not
对 DNS 配置文件 /etc/resolv.conf 增加 i 属性时会报错,提示操作不支持。比如:
- $ chattr +i /etc/resolv.conf
- chattr: Operation not supported while reading flags on /etc/resolv.conf
复制代码 问题原因该问题是由于 Ubuntu 12.04 之后版本系统,DNS 文件由 resolvconf 模块接管,导致直接修改 /etc/resolv.conf文件不生效,重启后会还原。 处理办法修改DNS需要对 /etc/resolvconf/resolv.conf.d/tail文件修改,具体步骤可以参考 云服务器 ECS Linux Ubuntu 系统修改 resolv 文件中的 DNS信息后重启自动还原问题解决方法。 如果仍需要使用手工修改 /etc/resolv.conf 文件的方式管理 DNS,或者增加只读属性,则需要卸载 resolvconf 模块。 执行如下指令进行卸载: - apt-get remove resolvconf
复制代码注:操作前建议快照备份,以免产生影响。快照创建方法请参考 创建快照。
操作示例: - $ apt-get remove resolvconf
- Reading package lists... Done
- Building dependency tree
- Reading state information... Done
- The following packages will be REMOVED:
- resolvconf ubuntu-minimal
- 0 upgraded, 0 newly installed, 2 to remove and 185 not upgraded.
- After this operation, 312 kB disk space will be freed.
- Do you want to continue? [Y/n] y
- (Reading database ... 93503 files and directories currently installed.)
- Removing ubuntu-minimal (1.325) ...
- Removing resolvconf (1.69ubuntu1.1) ...
- resolvconf stop/waiting
- resolvconf.postrm: Reboot recommended
- Package configuration
复制代码卸载 resolvconf 模块后,就可以直接修改 /etc/resolv.conf 文件来进行 DNS 配置,或者为该文件增加 i 属性。 可以通过 chattr 指令进行 i 属性的调整。 操作示例: - $ chattr +i /etc/resolv.conf
- $ lsattr /etc/resolv.conf
- ----i--------e-- /etc/resolv.conf
- $ chattr -i /etc/resolv.conf
- $ lsattr /etc/resolv.conf
复制代码
|