1.登陆到root
[]sudo su |
2.安装ssh服务并启动
[]apt install openssh-server []systemctl start ssh []systemctl enable ssh []vi /etc/ssh/sshd_config //修改下面参数 PermitRootLogin yes PasswordAuthentication yes |
***注意***
Ubuntu23.x以前的版本就这样,重启ssh就可以了,但是不知道为什么到23.x版本后就不行了,始终出现:
重启了也没用!最后花了一下午的时间,好不容易在网上看见:
[]#passwd root []#/etc/init.d/ssh restart |
重启后终于可以了!
2.添加多张网卡
实验环境网络规划
网段 | IP | 性质 | 备注 | |
Nat | DHCP | 外联Internet | VMnet8 | |
业务网 | 静态 192.168.0.0/24 | 实验室局域网 | Vmnet0 | |
内网 | 静态 100.100.100.0/24 | 内网 | Vmnet1 |
其中nat网卡①是连接外网的,网卡②vmnet0桥接到实验室局域网段192.168.0.0/24上,网卡③是内网100.100.100.0/24
虚拟机网卡配置如下:VMnet0为192.168.0.1/24
VMnet1为100.100.100.1/24
VMnet8为DHCP
查看IP
root@wu:~# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:50:36:82 brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.137.138/24 metric 100 brd 192.168.137.255 scope global dynamic ens33 valid_lft 1138sec preferred_lft 1138sec inet6 fe80::20c:29ff:fe50:3682/64 scope link valid_lft forever preferred_lft forever 3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default link/ether 02:42:e8:cb:11:7a brd ff:ff:ff:ff:ff:ff inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0 valid_lft forever preferred_lft forever 4: ens37: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 00:0c:29:50:36:96 brd ff:ff:ff:ff:ff:ff altname enp2s5 5: ens38: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 00:0c:29:50:36:8c brd ff:ff:ff:ff:ff:ff altname enp2s6 |
再查看虚拟机网卡mac地址
因此,可以确定VMnet0是ens38连接VMnet0,即实验室网段的,这里将其ip地址规划为:
192.168.0.138/24
显然ens37连接内网,IP地址规划为
100.100.100.138
root@wu:~# cd /etc/netplan/ root@wu:/etc/netplan# vi 00-installer-config.yaml |
添加内容
# Let NetworkManager manage all devices on this system network: ethernets: ens33: dhcp4: true ens37: addresses: [100.100.100.138/24] dhcp4: false gateway4: 100.100.100.1 ens38: addresses: [192.168.0.138/24] dhcp4: false gateway4: 192.168.0.1 version: 2 |
配置好后,用下面的命令生效:
[]#netplan apply
然后测试:
测试外网:
root@wu:~# ping www.baidu.com -c 2
PING www.a.shifen.com (183.2.172.42) 56(84) bytes of data.
64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=1 ttl=52 time=25.4 ms
至此,三张网卡均已成功部署。我们可以远程登陆了.
3.查看镜像源
sudo nano /etc/apt/sources.list # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb http://mirrors.aliyun.com/ubuntu lunar main restricted # deb-src http://mirrors.aliyun.com/ubuntu lunar main restricted ## Major bug fix updates produced after the final release of the ## distribution. deb http://mirrors.aliyun.com/ubuntu lunar-updates main restricted # deb-src http://mirrors.aliyun.com/ubuntu lunar-updates main restricted ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team. Also, please note that software in universe WILL NOT receive any ## review or updates from the Ubuntu security team. deb http://mirrors.aliyun.com/ubuntu lunar universe # deb-src http://mirrors.aliyun.com/ubuntu lunar universe deb http://mirrors.aliyun.com/ubuntu lunar-updates universe # deb-src http://mirrors.aliyun.com/ubuntu lunar-updates universe ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## multiverse WILL NOT receive any review or updates from the Ubuntu ## security team. deb http://mirrors.aliyun.com/ubuntu lunar multiverse # deb-src http://mirrors.aliyun.com/ubuntu lunar multiverse deb http://mirrors.aliyun.com/ubuntu lunar-updates multiverse # deb-src http://mirrors.aliyun.com/ubuntu lunar-updates multiverse ## N.B. software from this repository may not have been tested as ## extensively as that contained in the main release, although it includes ## newer versions of some applications which may provide useful features. ## Also, please note that software in backports WILL NOT receive any review ## or updates from the Ubuntu security team. deb http://mirrors.aliyun.com/ubuntu lunar-backports main restricted universe multiverse # deb-src http://mirrors.aliyun.com/ubuntu lunar-backports main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu lunar-security main restricted # deb-src http://mirrors.aliyun.com/ubuntu lunar-security main restricted deb http://mirrors.aliyun.com/ubuntu lunar-security universe # deb-src http://mirrors.aliyun.com/ubuntu lunar-security universe deb http://mirrors.aliyun.com/ubuntu lunar-security multiverse # deb-src http://mirrors.aliyun.com/ubuntu lunar-security multiverse |
已经是国内源了,就无需更改了。如果要变成其他源,可以自行修改。
4.更新
root@wu:~# apt-get upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
sosreport ubuntu-advantage-tools
The following packages will be upgraded:
apparmor apport apt apt-utils base-files bind9-dnsutils bind9-host bind9-libs cloud-init distro-info
distro-info-data initramfs-tools initramfs-tools-bin initramfs-tools-core kpartx libapparmor1
libapt-pkg6.0 libglib2.0-0 libglib2.0-bin libglib2.0-data libnetplan0 libnss-systemd libpam-systemd
libsgutils2-2 libsystemd-shared libsystemd0 libudev1 mdadm motd-news-config multipath-tools needrestart
netplan.io python3-apport python3-distro-info python3-distupgrade python3-pkg-resources
python3-problem-report python3-setuptools sg3-utils sg3-utils-udev snapd systemd systemd-hwe-hwdb
systemd-resolved systemd-sysv systemd-timesyncd tzdata tzdata-icu ubuntu-drivers-common
ubuntu-release-upgrader-core udev ufw
52 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Need to get 44.7 MB of archives.
After this operation, 5,015 kB disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu lunar-updates/main amd64 motd-news-config all 12.3ubuntu2.1 [7,450 B]
Get:2 ……
还走一遍
root@wu:~# apt-get update
Hit:1 http://mirrors.aliyun.com/ubuntu lunar InRelease
Hit:2 http://mirrors.aliyun.com/ubuntu lunar-updates InRelease
Hit:3 http://mirrors.aliyun.com/ubuntu lunar-backports InRelease
Hit:4 http://mirrors.aliyun.com/ubuntu lunar-security InRelease
Reading package lists... Done
至此,基本的系统工具准备完毕!