FQDN (Fully Qualified Domain Names) in R

January 29, 2016

[This article was first published on Mango Solutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

By Steph Locke

Get the fully qualified domain name for your machine

This is just a quick post, to mention how you can get your computer name with the domain it is registered in i.e.  the fully qualified domain name (FQDN) by using R.

Base R

In Windows to get the computer name in it’s fully qualified form you need to do:


In Linux, you can use:

## [1] ""

Each of these returns an empty string in the other OS so you can concatenate them to get the FQDN.

getFQDN <- function (){
           paste0( paste(Sys.getenv("COMPUTERNAME"),
                 , Sys.getenv("HOSTNAME")
## [1] "slocke.mango.local"

Using iptools

Alternatively, we could use the iptools package (available from CRAN) which now also works in Windows.

## [[1]]
## [1] "slocke.Mango.local"

For more info on iptools, check out the GitHub repo.

To leave a comment for the author, please follow the link and comment on their blog: Mango Solutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)