Ubuntu 18 is the OS that adds a NIC to a server instance in Sakura's cloud and assigns a local IP.

Create a server in Sakura's cloud, add a NIC and assign a local IP

When you want to have such a configuration

image.png image.png

With a server that connects to the Internet Separate servers that cannot be connected to the Internet. I don't know what kind of attack will come when I connect to the Internet. Therefore, if you want to prevent the server containing important data from being directly connected to the Internet.

Server A to connect to the Internet needs two NICs

image.png What is a NIC? Network interface card Connect NIC1 to the interface Connect NIC2 to LAN

Actual configuration

さくらのクラウドにNICを追加してローカルIPを割当てる OSはUbuntu18b.png

Create a server. Assign a global IP to the NIC when it is created. After creating the server instance, add a NIC and connect to the switch. The switch address is 192.168.101.1 and the VPN router has been set. Then connect to the VPN with a MacBook Pro etc. and log in to the Ubuntu server.

This time I recorded the procedure to add a NIC and set the local IP address 192.168.101.20.

Setting procedure Confirm that the eth1 device has been created

Execute the command. ip addr To check the address allocation status

ipconfig -a Then, make sure that the eth1 device exists.

netplan It seems that the network is set up from Ubuntu 18 with something called netplan. See below for details. https://wiki.ubuntu.com/Netplan https://netplan.io/

Make a backup

sudo cp -p /etc/netplan/01-netcfg.yaml /home/ubuntu/01-netcfg.yaml.bkup

If you make a mistake in the network settings, you will not be able to log in with SSH. Make a backup so that you can restore it. Hmm? How do I get the settings back when I can't log in with SSH? At that time, let's work using Sakura's cloud console. https://manual.sakura.ad.jp/cloud/server/console.html

Edit 01-netcfg.yaml

sudo vi /etc/netplan/01-netcfg.yaml And edit with the vi editor. You can also use the nano editor.

01-netcfg.yaml after change

network: 
  ethernets: 
    eth0: 
      addresses: 
        - 153.125.512.30/24
      dhcp4: 'no'
      dhcp6: 'no'
      gateway4: 153.125.512.1
      nameservers: 
        addresses: 
          - 133.242.0.3
          - 133.242.0.4
        search: 
          - localdomain
    eth1:
      addresses:
        - 192.168.101.20/24

  renderer: networkd
  version: 2

The part to be added below.

    eth1:
      addresses:
        - 192.168.101.20/24

Reflect the settings

sudo netplan apply To check if the address is reflected in ifconfig.

Try rebooting

sudo shutdown -r now Reboot with, log in with SSH and make sure the network settings are enabled with ifconfig. If you make a mistake at this time, you may not be able to log in with SSH. In that case, use the console to restore the settings.

This is the first time I learned about netplan. I'm not familiar with it, so it may be wrong. Masakari is welcome.

Recommended Posts

Ubuntu 18 is the OS that adds a NIC to a server instance in Sakura's cloud and assigns a local IP.
How to use Ubuntu Server 20.10 (Groovy Gorilla) in Sakura's cloud
What to do about "A server is already running ..." that happened without turning off the rails server in the terminal
I tried to make a web application that searches tweets with vue-word cloud and examines the tendency of what is written in the associated profile
Just plug in the storage and power to run the Raspberry Pi (Ubuntu Server Edition)
If you want to recreate the instance in cloud9
[Rails] How to temporarily save the request URL of a user who is not logged in and return to that URL after logging in
Determine that the value is a multiple of 〇 in Ruby
[Java] A class is an OS, and an instance is a virtual computer.
What to do if Cloud9 is full in the Rails tutorial
How to install the language used in Ubuntu and how to build the environment
What is the difference between a web server and an application server?
How to identify the path that is easy to make a mistake
ngrok --https communication in local environment (exposing the server to the outside)
Creating an ArrayList that allows you to throw in and retrieve the coordinates of a two-dimensional plane
[RSpec] When you want to use the instance variable of the controller in the test [assigns is not recommended]