Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

containers: fix broken /etc/hosts entries when localAddress contains … #20956

Merged
merged 1 commit into from Dec 12, 2016

Conversation

montag451
Copy link
Contributor

@montag451 montag451 commented Dec 6, 2016

Motivation for this change

When localAddress contains a netmask (e.g when using hostBridge option), the entries added to /etc/hosts contains the netmask which is not correct and prevent the entries to be used for DNS resolution.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@montag451, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @kampfschlaefer and @wlhlm to be potential reviewers.

Copy link
Contributor

@kampfschlaefer kampfschlaefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you extend the tests to check for this?

Otherwise a good catch, thanks! 🍰

@montag451
Copy link
Contributor Author

@kampfschlaefer I added a test to check entries added into /etc/hosts. Is it ok for you ?

@montag451
Copy link
Contributor Author

Squashed commits

@Mic92 Mic92 merged commit ea5551b into NixOS:master Dec 12, 2016
@danbst
Copy link
Contributor

danbst commented Dec 12, 2016

I don't understand why netmask is included into localAddress attribute. Shouldn't it be separate attribute? For example, I refer via config.containers.ccc.localAddress to my container IP, and I'm bitten by the fact that localAddress has different syntax for bridge and veth. @kampfschlaefer ?

@montag451 montag451 deleted the containers-hosts branch December 12, 2016 19:48
@kampfschlaefer
Copy link
Contributor

@danbst Good point, so you would want another attribute localAddressNetmask to be used when hostBridge is used?

@danbst
Copy link
Contributor

danbst commented Dec 13, 2016

That is a simple solution, yes. More complicated is to create custom networkAddress option, that is parsed into networkAddress.ip and networkAddress.netmask, so you can refer to IP later like config.containers.ccc.localAddress.ip. Though if I'm the only with problem, perhaps I should always use head (splitString "/" config.containers.ccc.localAddress) in my scripts.

BTW, I'm very unfamiliar with bridges, though I do use them.
Can't the mask (/24) be extracted from host bridge, like toString (lib.head (config.networking.interfaces.${bridge}.ip4)).prefixLength ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants