In the last article, we completed the Server installation with VMware Player and Ubuntu Server, but there is still some way to go before the remote Server is set up. In this article we will start to carry on the server network configuration, for the server through the network to provide services to the user to lay the foundation!

The network structure

Before we start configuring the network, let’s examine the structure of the default NAT network provided by VMware Player

  • Virtual machine: the server we created
  • DHCP server: dynamically provides IP addresses and other network information for computers on the virtual network
  • NAT device: If a VM in a VIRTUAL network needs to access an external network, it sends the request to the NAT device. After receiving the request, the NAT device translates the VM IP address into the HOST IP address. Because the IP address of the host is visible to the external network, VMS in the virtual network can access the external network

As can be seen from the structure of the default NAT network, the communication of our server in the virtual network is based on the dynamic IP assigned by the DHCP server, and the request to access the external network is sent to the NAT device.

However, the premise of the server to provide services is that users can find the server in a fixed place. Obviously, the dynamic IP address cannot meet the requirements. Therefore, we need to fix the IP address of the server in the virtual network to achieve stable access to the server.

Fixed IP address

The Ubuntu Server network configuration file is stored in /etc/netplan with a. Yaml suffix. Common network configuration templates can be found in Netplan

network:
  version: 2
  renderer: networkd
  ethernets:
    < nic name >:
      addresses:
        - The < static IP>
      nameservers:
        addresses: [<DNS The server IP>]
      routes:
        - to: 0.0. 0. 0/ 0
          via: The router IP>
Copy the code

However, VMware Player does not allow for virtual network customization (which is available on the paid VMware Workstation Pro), so we need to query for network information used in the default NAT virtual network and populate the configuration file with this information.

  1. Query the name and current IP address of the server network adapter: IP address

    • Nic Name:ens32
    • Server IP address:192.168.70.128/24(Since the virtual network is small, we only configure IPv4)
  2. Querying NAT device information: IP router

    • NAT device IP address:192.168.70.2
  3. Yaml: sudo vim /etc/netplan/*. Yaml

    network:
      version: 2
      renderer: networkd
      ethernets:
        ens32:
          addresses:
            - 192.16870.128./ 24
          nameservers:
            # Ali public DNS
            addresses: [223.5. 5. 5.223.66.6.]
          routes:
            - to: 0.0. 0. 0/ 0
              via: 192.16870.2.
    Copy the code

    Note that the configuration file has high requirements on indentation. Be careful when filling in the configuration file

  4. Sudo netplan try (if there is no error, it will prompt whether to apply the configuration file)

  5. Check whether the configuration takes effect (since most network information remains unchanged, we can check DNS information) : systemd-resolve –status

  6. To be on the safe side, I rebooted the server and tested the network

    • IP address:

    • DNS server:

    • Accessing external networks:

    • Host access:

conclusion

In this article, we start from the analysis of network structure, step by step successfully fixed the IP address of the server in the virtual network! Any user on the virtual network can now access our server at 192.168.70.128. But before the server can serve users, we need to configure the services we developers need.

In the next article, we’ll implement remote login access to the server from a local machine over SSH, just like in real development!