Good afternoon, there was a problem in setting up the network in the ubuntu server on vm.

  • Installed Ubuntu Server 16.04
  • Configure Apache2, PHP, MySQL and other services successfully
  • In the settings of Wirth Machines put the connection type Bridge
  • The file / etc / network / inferfaces is auto inet dhcp
  • I can successfully connect to the machine via ssh using the IP address, and also the server works when I access the page from the browser

And here there was a need to set the domain for ip in the hosts file, as well as to configure the connection via ssh, without the need to enter a password.

  • I set it in the / etc / network / inferfaces static ip file

In the end, I was able to configure everything I wanted, the domain and ssh works with a bang. But the fact is that I often move with a laptop, and when using the Internet in another place, I have Apache2, not to mention the connection via ssh. And you have to change static ip to make it work again.

I used vagrant before, but refused it due to the fact that some projects still have old PHP versions, not to mention the fact that they are often different (server configurations). This is if used Vagrant globally on the machine. Frankly speaking, I didn’t like it for each project to make a new vagrant, it’s easier for me to make a copy of vdi and to change the small server settings in the system (it takes less time and body movements).

In Vagrant, I liked that by default there is something 192.168.10.10 to which the connection always goes, and from different places wherever I go to this address with a bang. Tell me please, how can I set up a Wirth machine in the same way, in order to register a static ip at my discretion, and always access it from different places? As I understand it, Host-only can give such an opportunity, but it cuts off access to the network in the Wirth machine and leaves only local.

I would be very grateful for the help, as it is already the second day that I have been struggling with a problem and in no way come to a solution.
PS I use OSX (Macbook pro), all of a sudden it matters

  • one
    The default client puts the network mode in NAT and forwards the SSH port to localhost: 2222. It is quite convenient for manually created machines. - Vladimir Gamalyan
  • And can you describe in more detail what needs to be done, or give a link to a source? - Alex
  • one
    Yes, just in the network settings of the vertical machine. There and the type of network is selected and port forwarding. - Vladimir Gamalyan
  • I try, swears 403 error and does not allow port 22. - Alex

2 answers 2

MacOS has a Bonjour service that implements the Zeroconf protocol. Linux also has an implementation of this protocol, but is called Avahi ( avahi-daemon package). Sobno do the network through dhcp , ssh authorization through the key, and get to the virtual machine by the содержимое-файла-/etc/hostname-точка-local . Those. for ubuntu-serv hostname write ssh ubuntu-serv.local . Well, with the browser the same garbage.

    As a result, this case was decided by forwarding the ports, as Vladimir suggested in the comments. True, it was necessary to add another Host-only adapter. If anyone is interested, I can throw the screenshots of the settings