Skip to content

Instantly share code, notes, and snippets.

@huynhsamha
Last active January 30, 2019 07:22
Show Gist options
  • Save huynhsamha/e8a9d6d58732f25d0ffd0db5b6bd6467 to your computer and use it in GitHub Desktop.
Save huynhsamha/e8a9d6d58732f25d0ffd0db5b6bd6467 to your computer and use it in GitHub Desktop.
Using Ubuntu Server 18.04 on VirtualBox 6.0 (Config Networking, SSH, Firewall, NGINX)

Configure Ubuntu Server 18.04 on VirtualBox 6.0

Networking

Config Host-only Network on VirutalBox

Tools -> Click to Button More -> Network -> Create new network vboxnet0:

  • Adapter: IP: 192.168.56.1
  • DHCP Server: 192.168.56.2, from 192.168.56.3 to 192.168.56.254

Config network adapter on Ubuntu Server

Add adapter before start server

Ubuntu Server -> Settings -> Network

  • Adapter 1: NAT
  • Adapter 2: Host-only Network -> vboxnet0

Start server and login

Check network adapters

# Currently without Host-only network
$ ifconfig
enp0s3: ...
lo: ...

# We have network adapter enp0s8, is host-only network
$ ifconfig -a
enp0s3: ...
lo: ...
enp0s8: ...

Install necessary pacakge

$ sudo apt install ifupdown

Edit network interfaces

$ sudo vim /etc/network/interfaces

Edit to

# Use for after install apt ifupdown
source /etc/network/interfaces.d/

# Loopback
auto lo
iface lo inet loopback

# DHCP - NAT network
auto enp0s3
iface enp0s3 inet dhcp

# Static IP - Host only network
auto enp0s8
iface enp0s8 inet static
address 192.168.56.10 # your IP address
netmask 255.255.255.0

Up interface enp0s8 and restart networking

sudo ifconfig enp0s8 up
sudo /etc/init.d/networking restart

Test ping Open terminal outsite VM, ping to VM by IP

$ ping 192.168.56.10
PING 192.168.56.10 (192.168.56.10) 56(84) bytes of data.
64 bytes from 192.168.56.10: icmp_seq=1 ttl=64 time=0.020 ms
64 bytes from 192.168.56.10: icmp_seq=2 ttl=64 time=0.039 ms
64 bytes from 192.168.56.10: icmp_seq=3 ttl=64 time=0.060 ms

SSH

Install OpenSSH

sudo apt install -y openssh-server

Useful commands

sudo systemctl status ssh
sudo systemctl start ssh
sudo systemctl disable ssh
sudo systemctl enable ssh
sudo systemctl restart ssh

Trying SSH

Open terminal and trying SSH (on MacOS or Linux, on Windows, use Putty)

ssh username@192.168.56.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment