Ubuntu22.04 Server配置静态IP

本篇主要记录在Oracle Vm VirtualBox 中安装Ubuntu22.04 Server,并设置静态IP

1. 下载

VirtualBox下载地址
https://www.virtualbox.org/wiki/Downloads
ubuntu下载地址
https://releases.ubuntu.com/22.04/ubuntu-22.04.1-live-server-amd64.iso

image
关机然后设置网络
点击工具选择网络
image
创建仅主机网络
image
设置ubuntu虚拟机第二张网卡
image
进入虚拟机 查看网卡配置
ip a
image

其中 enp0s3 是访问外部网络的网卡
enp0s8 是仅主机网络的网卡,没有enp0s8或网卡没有IP地址可以通过

sudo netplan generate
sudo netplan apply
sudo /sbin/dhclient

分配一个IP,然后通过SSH连接(方便复制粘贴)

在/etc/netplan/文件夹下有00开头一个网卡配置文件,对他进行修改指定静态IP地址

sudo vim /etc/netplan/00-installer-config.yaml

写入如下配置:

# This is the network config written by 'subiquity'
network:
  ethernets:
    enp0s3:
      dhcp4: true
    enp0s8:
      addresses: [192.168.56.101/24]
      dhcp4: no
  version: 2

image

保存后执行以下命令:

 sudo netplan generate
 sudo netplan apply

再次查看网卡信息:
image

IP 地址已经有了 使用主机 ping一下
image

使用shell进行连接

ssh grovee@192.168.56.101

image

OK 大功告成

posted @   grovee  阅读(1358)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示