Cloud deployment of home servers

1. Fixed static IP

  • Check the IP address, starting with en
ifconfig

Insert image description here

  • Check the router ip, starting with via
ip route

Insert image description here

  • Modify configuration file
cd /etc/netplan/               													#来到这个文件夹
sudo cp 01-network-manager-all.yaml 01-network-manager-all.yaml.bak             #先备份
vim 01-network-manager-all.yaml													#修改文件

Insert image description here
The original file looks like this

# Let NetworkManager manage all devices on this system
network:
 version: 2
 renderer: NetworkManager

Modify it to look like this

# Let NetworkManager manage all devices on this system
network:
  renderer: NetworkManager
  ethernets:
    eno1:
      addresses:
        - 192.168.0.227/24
      routes:
        - to: default
          via: 192.168.0.107
      nameservers:
        addresses:
          - 192.168.0.107
          - 114.114.114.114
  version: 2

eno1: Change to the interface starting with en as seen above.
Addresses: Change to the IP address you want to fix.
via: Change to the IP address starting with via above.
Nameservers: It is the domain name resolution server. In addition to the router, 114.114.114.114 is added as a backup.

It will take effect after the modification is completed

sudo netplan apply

Insert image description here
After a while, you can see that the network is connected.
Insert image description here
Check the IP address again. You can see that the address is the static address 192.168.0.227 we set.
Insert image description here

2. Map public network IP

First of all, you need to have a public IP. To put it simply, buy a cloud server from Alibaba Cloud, Tencent Cloud, and Huawei Cloud. I bought Tencent Cloud this year.
Remember the address starting with via that you found earlier? Directly access this address with your browser and log in to the router.
Insert image description here

Supongo que te gusta

Origin blog.csdn.net/weixin_45569617/article/details/133377876
Recomendado
Clasificación