LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 11-26-2020, 06:47 PM   #1
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,440

Rep: Reputation: 110Reputation: 110
Running email on a virtual machine


I am planning to run an email server, but instead of installing it on bare metal like everybody else, I want to install and run it on a VirtualBox virtual machine.

I am wondering what kind of arrangements I will have to do to make it work.

When the server that is exposed to the Internet and responds for a certain domain receives mail, how does the mail server kick in from within the virtual machine and take over?
 
Old 11-26-2020, 07:03 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,397
Blog Entries: 28

Rep: Reputation: 6165Reputation: 6165Reputation: 6165Reputation: 6165Reputation: 6165Reputation: 6165Reputation: 6165Reputation: 6165Reputation: 6165Reputation: 6165Reputation: 6165
A web search for "linux email server virtual machine" will turn up many articles and tutorials.

You will want to use a "bridged" network adapter in the VM so the VM is in the same subnet as your LAN and you will need to harden the VM as you would a physical computer (firewall, etc.). As far as the LAN is concerned, the VM will be just another computer on the network and will be treated as such.

You should also check your ISP's terms of service. In the U. S., most ISPs prohibit public-facing servers on less than business-level accounts; that would include a mail server (as an aside to inconvenience wannabe spammers, not to force users to business-level accounts, as the cynical might think).
 
1 members found this post helpful.
Old 11-26-2020, 10:42 PM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by lucmove View Post
I am planning to run an email server, but instead of installing it on bare metal like everybody else, I want to install and run it on a VirtualBox virtual machine.
I don't know if everybody else runs mail servers on bare metal. Most probably that is not the case.
Quote:
I am wondering what kind of arrangements I will have to do to make it work.
The same arrangements as for a bare metal server. Plus the Virtualbox host must be configured to pass traffic to the VM, but I believe that this is configured automatically when you install Virtualbox. Also, you probably want bridge networking, as suggested by Frank Bell.
Quote:
When the server that is exposed to the Internet and responds for a certain domain receives mail, how does the mail server kick in from within the virtual machine and take over?
I am not sure what you mean by "responds for a certain domain". Do you mean the VM's host also runs a mail server?

If the host also runs a mail server, you need to configure the two mail servers so that they collaborate. Again, this is not different from bare metal configuration.

If the host does not run a mail server, it will forward traffic to the VM that is destined to the VM's IP address(es). And the other direction, too. If, for example, the VM has IP address 10.11.12.13, traffic to 10.11.12.13 and port 25 will be sent to the VM. The Virtualbox host just forwards it. If a mail server is then configured on the VM, it will pick up that traffic.

Last edited by berndbausch; 11-26-2020 at 10:48 PM.
 
1 members found this post helpful.
Old 11-27-2020, 12:20 AM   #4
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,440

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by berndbausch View Post
If the host does not run a mail server, it will forward traffic to the VM that is destined to the VM's IP address(es). And the other direction, too. If, for example, the VM has IP address 10.11.12.13, traffic to 10.11.12.13 and port 25 will be sent to the VM. The Virtualbox host just forwards it. If a mail server is then configured on the VM, it will pick up that traffic.
The host doesn't run a mail server, but when I configure my domain at the registrar's control panel, I will of course use the host's IP address, but since the email server will be running inside a VM, it will have another IP address, an internal IP address, and that is the part that confuses me. I picture email coming to the host server and the host server shrugging like, "What the hell am I supposed to do with this? I am not an email server!"

Sorry if that last part sounds like a scene from a cartoon. But I'm sure you get what I mean.

Note: I am answering this but I haven't investigated web searches as recommended by frankbell yet.

Last edited by lucmove; 11-27-2020 at 12:21 AM.
 
Old 11-27-2020, 12:50 AM   #5
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by lucmove View Post
since the email server will be running inside a VM, it will have another IP address, an internal IP address, and that is the part that confuses me.
In other words, you are not using bridged networking. Insted, the VM resides behind a NAT router. This is standard for Virtualbox.
Quote:
I picture email coming to the host server and the host server shrugging like, "What the hell am I supposed to do with this? I am not an email server!"
Your mental picture is correct, but you can configure port forwarding on the host. Traffic to email ports like 25 gets forwarded to the VM. Easy to achieve with Virtualbox.

But that is not sufficient. You also have to configure your mail server so that it can work behind the NAT router. I don't know how to do that, but it is possible, for example see Postfix documentation.
 
Old 11-27-2020, 02:52 AM   #6
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,477
Blog Entries: 7

Rep: Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575
Quote:
Originally Posted by lucmove View Post
The host doesn't run a mail server, but when I configure my domain at the registrar's control panel, I will of course use the host's IP address, but since the email server will be running inside a VM, it will have another IP address, an internal IP address, and that is the part that confuses me.
As above, you should use Bridge Mode networking for the guest so that the guest can function as an independent machine on your network. This will enable it to query the router and obtain its own IP address completely independent of the host.

Once this is done, you can set up a port forward on your router directly to the VM's IP address.
 
1 members found this post helpful.
Old 11-27-2020, 11:55 AM   #7
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,440

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by rkelsen View Post
As above, you should use Bridge Mode networking for the guest so that the guest can function as an independent machine on your network. This will enable it to query the router and obtain its own IP address completely independent of the host.

Once this is done, you can set up a port forward on your router directly to the VM's IP address.
There is no router. I am going to do it on a VPS or dedicated server hosting account.

I am using neither NAT nor bridged. It isn't installed yet. I can use bridged, but if the guest is going to function as an independent machine, how is the host server supposed to know that some creature inside it handles email and forward anything?
 
Old 11-27-2020, 03:52 PM   #8
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by lucmove View Post
I can use bridged, but if the guest is going to function as an independent machine, how is the host server supposed to know that some creature inside it handles email and forward anything?
It isn't supposed to know. The host doesn't care what's inside the VM. This is true for any network protocol, HTTP, SSH, ... The host just forwards all traffic that is destined to the VM, to the VM. Not only email traffic.

Quote:
There is no router
By default, Virtualbox sets up NAT networking. In this case, Virtualbox creates a NAT router and connects the VM to it. When you opt for bridged networking, there is no router, indeed.

Last edited by berndbausch; 11-27-2020 at 03:57 PM.
 
Old 11-27-2020, 04:06 PM   #9
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,760

Rep: Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224
Quote:
Originally Posted by lucmove View Post
There is no router. I am going to do it on a VPS or dedicated server hosting account.

I am using neither NAT nor bridged. It isn't installed yet. I can use bridged, but if the guest is going to function as an independent machine, how is the host server supposed to know that some creature inside it handles email and forward anything?
Hmm. Is there any difference between a VPS and a VM? Isn't a Virtual Private Server just a Virtual Machine within a container? A VPS isn't "bare metal," as I understand it. (Someone please correct me if I'm wrong)

I'm wondering why you want to put the mail server in a VM? We provide email services on a different IP than a domain's web services by using an alias in the network configuration and configuring the servers to listen on different IPs. e.g.
Code:
#  ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.57.26 
	...
	
eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.57.27  
	...
...of course, that's just a guess at what you're wanting to accomplish...again, why use a VM?
 
Old 11-27-2020, 04:28 PM   #10
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,440

Original Poster
Rep: Reputation: 110Reputation: 110
I will be using a VM because I hate installing and configuring email, so I want to do it ONCE in a VM that I can take anywhere in case I move to another host provider and everything is just ready to go.
 
Old 11-27-2020, 05:02 PM   #11
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,156

Rep: Reputation: 394Reputation: 394Reputation: 394Reputation: 394
Can you do it in Docker? I've really come to appreciate the mobility of it. I rebuilt my home server a few days ago for 2 reasons. One to switch from the docker official package to the snap (not necessary to rebuild), and the other was just to see how long it took to rebuild. Before I moved to Docker it would take me 4-5 hours to get everything sorted. With Docker I had it fully functional and online doing it's job in an hour or so, most of which was waiting for download and the docker build to complete namely squid with ssl support.

Last edited by jmgibson1981; 11-27-2020 at 05:09 PM.
 
Old 11-27-2020, 05:19 PM   #12
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,760

Rep: Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224
Quote:
Originally Posted by lucmove View Post
I will be using a VM because I hate installing and configuring email, so I want to do it ONCE in a VM that I can take anywhere in case I move to another host provider and everything is just ready to go.
That makes sense, but I accomplish that with extensive and complete backups of configuration files, etc*....but then I’ve yet to learn how to “do” VMs...I (think) I understand the concepts, but haven’t learnt the specifics. OTOH I’m very familiar with how to setup my mail server (I use qmail)

Do you already know how to create and administer a VM?
What MTA are you using that is so hateful?

*I should be able to recover my entire setup to the last backup on a new server in a few hours.
 
Old 11-27-2020, 07:12 PM   #13
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,440

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by jmgibson1981 View Post
Can you do it in Docker? I've really come to appreciate the mobility of it. I rebuilt my home server a few days ago for 2 reasons. One to switch from the docker official package to the snap (not necessary to rebuild), and the other was just to see how long it took to rebuild. Before I moved to Docker it would take me 4-5 hours to get everything sorted. With Docker I had it fully functional and online doing it's job in an hour or so, most of which was waiting for download and the docker build to complete namely squid with ssl support.
I am not familiar with Docker, but a virtual machine seems to be easier.
 
Old 11-27-2020, 07:15 PM   #14
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,440

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by scasey View Post
That makes sense, but I accomplish that with extensive and complete backups of configuration files, etc*....but then I’ve yet to learn how to “do” VMs...I (think) I understand the concepts, but haven’t learnt the specifics. OTOH I’m very familiar with how to setup my mail server (I use qmail)

Do you already know how to create and administer a VM?
What MTA are you using that is so hateful?

*I should be able to recover my entire setup to the last backup on a new server in a few hours.
You create a VM, start with an empty hard disk, install the OS on it just like on bare metal, and use it.

On another machine, you transfer the existing VM into it, install VirtualBox, open the existing VM and run it.

Couldn't be any easier. Even I can do it.

The hateful MTA will probably be qmail because it's the only one I have installed and maintained, many many years ago. It is hateful, but all MTAs are.
 
Old 11-27-2020, 07:19 PM   #15
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,760

Rep: Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224
My go to for qmail
 
1 members found this post helpful.
  


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
How to : Open Virtual Machine Manager to create a new virtual machine BKChicago Linux - Newbie 2 11-08-2016 09:48 PM
Looking For A Bootable OS + Virtual Machine Combo - Bootable Virtual Machine OS Help angelbabycry Linux - Newbie 7 05-08-2015 08:36 PM
how to know the remote machine is Virtual machine or physical machine pantdk Linux - Server 19 10-16-2014 01:48 PM
Is base memory of virtual machine used when virtual machine is not running? ravisingh1 Linux - Virtualization and Cloud 3 04-09-2013 03:41 AM
Running virtual pc files in a virtual machine in linux ... preferably virtual box biharibong Linux - Software 4 01-21-2009 01:04 PM

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

All times are GMT -5. The time now is 02:57 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