After insert or delete entry in static-host-mapping, /etc/hosts lost all static-host-mapping entries, until modify system host-name
Description
Details
- Difficulty level
- Unknown (require assessment)
- Version
- VyOS 1.2 rolling release
- Why the issue appeared?
- Will be filled on close
- Is it a breaking change?
- Unspecified (possibly destroys the router)
- Issue type
- Bug (incorrect behavior)
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Resolved | jestabro | T1846 Make session_config not depend on the current edit level | |||
Resolved | Viacheslav | T1861 hosts lost after modified static-host-mapping |
Event Timeline
I don't see this bug in the latest versions of the VyOS (VyOS 1.2-rolling-201912090217 and VyOS 1.3-rolling-201912090242).
Adding static-host-mapping
set system static-host-mapping host-name r03 inet '192.168.122.62' set system static-host-mapping host-name r04 inet '192.168.122.67' set system static-host-mapping host-name r05 inet '192.168.122.68' set system static-host-mapping host-name r06 inet '192.168.122.69' [email protected]# commit [edit]
Check current hosts:
[email protected]# sudo cat /etc/hosts | tail -n 5 # From DHCP and "system static host-mapping" 192.168.122.69 r06 192.168.122.62 r03 192.168.122.68 r05 192.168.122.67 r04
Delete host 'r05'
[email protected]# delete system static-host-mapping host-name r05 [edit] [email protected]# commit [email protected]# sudo cat /etc/hosts | tail -n 5 # From DHCP and "system static host-mapping" 192.168.122.62 r03 192.168.122.69 r06 192.168.122.67 r04 [edit] [email protected]#
@qiuchengxuan Can you describe the sequence of how to reproduce this bug?
Confirm the problem on edit level.
vyos@vyos# show system static-host-mapping host-name r04 { inet 192.168.122.67 } host-name r06 { inet 192.168.122.69 } [edit] [edit system static-host-mapping] vyos@vyos# set host-name r03 inet 192.168.122.65 [edit system static-host-mapping] vyos@vyos# commit [edit system static-host-mapping] vyos@vyos# [edit system static-host-mapping] vyos@vyos# cat /etc/hosts ### Autogenerated by VyOS ### ### Do not edit, your changes will get overwritten ### # Local host 127.0.0.1 localhost 127.0.1.1 vyos # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters # From DHCP and "system static host-mapping"[edit system static-host-mapping] vyos@vyos#
@jestabro problem is not resolved
vyos@vultr# edit system static-host-mapping [edit system static-host-mapping] vyos@vultr# set host-name test.lan inet 127.0.0.1 [edit system static-host-mapping] vyos@vultr# commit [ system static-host-mapping ] Traceback (most recent call last): File "/usr/libexec/vyos/conf_mode/host_name.py", line 180, in <module> c = get_config() File "/usr/libexec/vyos/conf_mode/host_name.py", line 48, in get_config conf = Config() File "/usr/lib/python3/dist-packages/vyos/config.py", line 115, in __init__ self._running_config = vyos.configtree.ConfigTree(running_config_text) File "/usr/lib/python3/dist-packages/vyos/configtree.py", line 182, in __init__ raise ValueError("Failed to parse config: {0}".format(msg)) ValueError: Failed to parse config: Syntax error on line 1, character 21: Invalid syntax. [[system static-host-mapping]] failed Commit failed [edit system static-host-mapping] vyos@vultr#
you probably needs to change config.py:L102 running config also
Thanks; this is necessary when (1) editing at the level of an unset node; (2) reading effective_value(s) in configuration mode. I will extend the original fix.
[edit system static-host-mapping]
vyos@vultr# set host-name test.lan inet 127.0.0.1
[edit system static-host-mapping]
vyos@vultr# commit
[edit system static-host-mapping]
vyos@vultr# save
Saving configuration to '/config/config.boot'...
Done
[edit]
vyos@vultr# show system static-host-mapping
host-name test.lan {
inet 127.0.0.1
}
[edit]
vyos@vultr#
Verified as resolved
vyos@vultr:~$ show version
Version: VyOS 1.2-rolling-201912130217