LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-21-2020, 06:16 PM   #1
queshaw
LQ Newbie
 
Registered: Sep 2012
Posts: 13

Rep: Reputation: Disabled
hostname with no sub-domain?


I am ultimately trying to setup an SSL certificate.

My domain name is like example.com not something.example.com

How should I configure my hostname without a sub-domain? The main reason is that I need to give domain names and aliases to register to certbot and to httpd.
 
Old 01-22-2020, 02:21 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by queshaw View Post
I am ultimately trying to setup an SSL certificate.

My domain name is like example.com not something.example.com

How should I configure my hostname without a sub-domain? The main reason is that I need to give domain names and aliases to register to certbot and to httpd.
You can create certificate(s) for just example.com, or something.example.com or even *.example.com, with letsencrypt
Take a look at this howto for example

Regards
 
Old 01-22-2020, 05:34 AM   #3
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
With certbot you can repeat the -d parameter to have a multi-name cert, providing your host is reachable on the other names.

For example on my web servers I generally use:

Code:
/bin/certbot --rsa-key-size 4096 -n certonly --webroot -w ${FOLDER} -d ${DOMAIN} -d www.${DOMAIN}
 
Old 01-23-2020, 07:42 PM   #4
queshaw
LQ Newbie
 
Registered: Sep 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
I know that I can specify domain names with the -d option, But, it complains if those are not resolved domain names or aliases served by my web server, I think.

The domain names and aliases are derived from hostname.

So, how do I configure a hostname, if it is not a sub-domain?

For example:

hostname blah

Results in a FQDN blah.example.com

hostname example

Results in example.example.com
 
Old 01-24-2020, 12:44 AM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by queshaw View Post
I know that I can specify domain names with the -d option, But, it complains if those are not resolved domain names or aliases served by my web server, I think.

The domain names and aliases are derived from hostname.

So, how do I configure a hostname, if it is not a sub-domain?

For example:

hostname blah

Results in a FQDN blah.example.com

hostname example

Results in example.example.com
Check the "domain" and/or "search" option of /etc/resolv.conf
 
Old 01-24-2020, 10:37 AM   #6
queshaw
LQ Newbie
 
Registered: Sep 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
I'm not following how those allow me to have a host name without a sub-domain. Could you elaborate?
 
Old 01-24-2020, 04:40 PM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by queshaw View Post
I'm not following how those allow me to have a host name without a sub-domain. Could you elaborate?
Did you read the resolv.conf manpage at the link in my previous post?
If you use the search/domain directive in resolv.conf (e.g. search example.com), when you do a lookup for "blah" the resolver will actually resolve blah.example.com

If you don't use dns, you can achieve the same result with the hosts file (/etc/hosts)
 
Old 01-24-2020, 04:53 PM   #8
queshaw
LQ Newbie
 
Registered: Sep 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bathory View Post
Did you read the resolv.conf manpage at the link in my previous post?
If you use the search/domain directive in resolv.conf (e.g. search example.com), when you do a lookup for "blah" the resolver will actually resolve blah.example.com

If you don't use dns, you can achieve the same result with the hosts file (/etc/hosts)
Right. That is what I am trying to avoid. My domain name is like example.com not blah.example.com. The hostname is used in various configuration files. If I set the hostname to "example" it resolves to example.example.com, which is also wrong.

How do people configure DNS and httpd and let's encrypt when their FQDN does not include a sub-domain?
 
Old 01-24-2020, 05:01 PM   #9
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,599

Rep: Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546
Neither Certbot nor Apache cares what your server's actual hostname is.

First step is DNS - setup an A record for "@" on the nameservers example.com uses, pointing at the IP address of your server (or firewall/loadbalancer/etc).

Next step is to configure Apache Httpd with your example.com as a VirtualHost (using appropriate SeverName and ServerAlias values). (Until DNS resolves, you can setup your local /etc/hosts to mimic the A record and test Apache is working, or even do it before changing the DNS.)

Once the DNS has resolved (anywhere from minutes to 48 hours), and assuming appropriate permissions/etc, Certbot will be able to issue your certificate.
If there are issues, Certbot will error but you can simply resolve the issues then re-run it.

 
1 members found this post helpful.
Old 01-24-2020, 05:15 PM   #10
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by boughtonp View Post
Neither Certbot nor Apache cares what your server's actual hostname is.
This is the definitive answer. OP, you don't need to do anything about your hostname.
Set up DNS as boughtonp has suggested. Set up apache to respond to the names you want. The SSL cert will contain the name as you've defined it in DNS and apache. hostname doesn't enter into it anywhere...it could be localhost or myserver instead of example.com and wouldn't matter.

On my production server, I've set the hostname to example.com, but all the virtual domains I host resolve and display just fine, even tho, except for one of them, the hostname is not the same as the domain name.

Last edited by scasey; 01-24-2020 at 05:17 PM.
 
Old 01-24-2020, 05:43 PM   #11
queshaw
LQ Newbie
 
Registered: Sep 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Thank you! Apparently, I was confused by hostname appearing in various configuration files and a left over let's encrypt configuration file that failed to renew because the machine used to have a sub-domain name.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Domain.com/sub/ works normally but, sub.domain.com not works DeSouffle Linux - Server 1 10-11-2013 10:19 AM
HOSTNAME = hostname -> HOSTNAME: command not found ? thomas2004ch Linux - Software 2 08-26-2013 08:25 PM
Shell Script to compare folders,Sub-Folders and Sub-Sub-Folders unix_72427 Programming 8 08-08-2012 02:51 PM
Sendmail doubling sender domain- ex. hostname.domain.net.domain.net halborr Slackware 7 08-23-2010 08:37 AM
Could someone explain to me the process of adding a hostname? (hostname.domain.com) brynjarh Linux - Server 2 10-18-2009 07:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration