If you're looking for a private IP address, or for a set of all IP addresses assigned to the box, you could use some combination of ifconfig (on BSD and GNU/Linux), ip addr (on GNU/Linux), hostname (options -i and -I on GNU/Linux) and netstat to see what's going on. IPANY="$(dig -t txt. +short | tr -d \")" Here's a sample script that uses all the options above to set the variables: #!/bin/sh Other options include and, which answer with A and AAAA records (instead of TXT as in the above example from Google), so, they don't require having the quotes removed: You could use dig(1) options like -4 or -6 to specifically look for an IPv4 or IPv6 address Google will provide an answer in a record of TXT type, which will have quotes around it when presented by dig if you want to subsequently use the variable with utilities like traceroute, you gotta use something like tr(1) to remove said quotes. But, even despite NAT if the VM is receiving its LAN connection, and its route to the internet, from the main host surely, the main host must have some kind of record of that link in the IP chain. If you're looking for a public IP address of the box, you could use the following: Okay, I thought it was bridged by default.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |