root@ubuntu2204:~# vim /etc/apt/sources.list deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse # deb-src https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
root@ubuntu2204:~# grub-mkconfig -o /boot/grub/grub.cfg Sourcing file `/etc/default/grub' Sourcing file `/etc/default/grub.d/init-select.cfg' Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.15.0-102-generic Found initrd image: /boot/initrd.img-5.15.0-102-generic Warning: os-prober will not be executed to detect other bootable partitions. Systems on them will not be added to the GRUB boot configuration. Check GRUB_DISABLE_OS_PROBER documentation entry. done
root@ubuntu2204:~# reboot
root@ubuntu2204:~# ip addr 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:fb:bc:2d brd ff:ff:ff:ff:ff:ff altname enp2s1 altname ens33 inet 10.0.0.131/24 metric 100 brd 10.0.0.255 scope global dynamic eth0 valid_lft 1782sec preferred_lft 1782sec inet6 fe80::20c:29ff:fefb:bc2d/64 scope link valid_lft forever preferred_lft forever
配置IP地址
网上配置文件为YAML格式,存放在/etc/netplan/**.yaml文件中
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
root@ubuntu2204:~# ls /etc/netplan/ 00-installer-config.yaml
root@ubuntu2204:~# vim /etc/netplan/00-installer-config.yaml # This is the network config written by 'subiquity' network: ethernets: eth0: dhcp4: false addresses: - 10.0.0.7/24 gateway4: 10.0.0.2 nameservers: addresses: - 10.0.0.2 - 223.5.5.5 version: 2
检查配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
## DNS检查 root@ubuntu2204:~# resolvectl status Global Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported resolv.conf mode: stub
Link 2 (eth0) Current Scopes: DNS Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported Current DNS Server: 10.0.0.2 DNS Servers: 10.0.0.2 223.5.5.5
## 网关检查 root@ubuntu2204:~# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.0.0.2 0.0.0.0 UG 0 0 0 eth0 10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
root@ubuntu2204:~# apt search net-tools Sorting... Done Full Text Search... Done atm-tools/jammy 1:2.5.1-4build2 amd64 Base programs for ATM in Linux, the net-tools for ATM
ddnet-tools/jammy 15.9.1-1 amd64 Tools for DDNet
hobbit-plugins/jammy 20201127 all plugins for the Xymon network monitor
iproute2/jammy,now 5.15.0-1ubuntu2 amd64 [installed,automatic] networking and traffic control tools
root@ubuntu2204:~# timedatectl Local time: Wed 2024-05-15 16:19:04 CST Universal time: Wed 2024-05-15 08:19:04 UTC RTC time: Wed 2024-05-15 08:19:04 Time zone: Asia/Shanghai (CST, +0800) System clock synchronized: yes NTP service: active RTC in local TZ: no