[ADD] add hyper-v vm'ip to name translation#88
Open
JoJoJoinme wants to merge 2 commits intoshayne:masterfrom
Open
[ADD] add hyper-v vm'ip to name translation#88JoJoJoinme wants to merge 2 commits intoshayne:masterfrom
JoJoJoinme wants to merge 2 commits intoshayne:masterfrom
Conversation
support hyper-v vm's ipv4 addr to domain name. adn the domain-name format is <-your-vmName->.example.com
[Explain why this feature is needed and what problem it solves.]
I meet same problem. 'the ip address of vm inside hyper-v changed everytime when system restart'
Inspired by this project. I write a domain-name <---> ip addr translation function
And there are hyper-v api which you can get vm info(ip addr, vnName, etc..)managed by hyper-v
1. get all runing vm info
`Get-VM | Where-Object {$_.State -eq 'Running'} | Select-Object-ExpandProperty Name`
2. get ip addr of running vm
` Get-VMNetworkAdapter -VMName <-put-your-vmName-> | Select-Object -ExpandProperty IPAddresses`
This must be run by Administrator
[Describe the tests you've run to verify your changes. Provide instructions so we can reproduce.]
compile it and run.
[Add screenshots to help explain your feature, if applicable.]
No sceenshots but there are logs..
>
PS D:\Code\go-wsl2-host> .\wsl2host.exe debug
wsl2host.info(1): starting wsl2host service
Get running vm names [Fedora-39-2 win10-home]
vm:Fedora-39-2, ipInfo:ipv4:[172.17.116.89], ipv6:[fe80::215:5dff:fe00:104]
vm:win10-home, ipInfo:ipv4:[172.17.112.60], ipv6:[fe80::d7bc:1e4f:3ca0:e1a0]
old hapi entry info:map[Fedora-39-2.exmaple.com:id:23, ip:172.17.116.89, hostname:Fedora-39-2.exmaple.com, comment:managed by api - hyper-vm win10-home.exmaple.com:id:24, ip:172.17.112.60, hostname:win10-home.exmaple.com, comment:managed by api - hyper-vm]
upsert entry:id:0, ip:172.17.116.89, hostname:Fedora-39-2.exmaple.com, comment:managed by api - hyper-vm
upsert entry:id:0, ip:172.17.112.60, hostname:win10-home.exmaple.com, comment:managed by api - hyper-vm
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] My code follows the code style of this project.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the **CONTRIBUTING** document.
[Add any additional information that might be helpful for reviewers.]
additional. I fix a bug of `GetHostIP` func which get gateway addr of wsl, and write a new func `GetHostIPv2` which get result from api directly
[ADD] add hyper-v vm'ip to name translation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
[Provide a brief description of the new feature you're adding.]
support hyper-v vm's ipv4 addr to domain name. adn the domain-name format is <-your-vmName->.example.com
Motivation and Context
[Explain why this feature is needed and what problem it solves.]
I meet same problem. 'the ip address of vm inside hyper-v changed everytime when system restart' Inspired by this project. I write a domain-name <---> ip addr translation function
How Has This Been Tested?
[Describe the tests you've run to verify your changes. Provide instructions so we can reproduce.]
Proof of Concept:
there are hyper-v api which you can get vm info(ip addr, vnName, etc..)managed by hyper-v
Get-VM | Where-Object {$_.State -eq 'Running'} | Select-Object-ExpandProperty NameGet-VMNetworkAdapter -VMName <-put-your-vmName-> | Select-Object -ExpandProperty IPAddressesThis must be run by AdministratorI solve the problem by writing a function to do the same thing
Screenshots (if appropriate):
[Add screenshots to help explain your feature, if applicable.]
No sceenshots but there are logs..
Types of changes
Checklist:
Additional Notes
[Add any additional information that might be helpful for reviewers.]
Additional. I fix a bug of
GetHostIPfunc which get gateway addr of wsl, and write a new funcGetHostIPv2which get result from api directly