ubuntu18.0.4分Server和Desktop版本,它们之间用图形配置的网卡地址存储的配置文件是不一样的,所以在配置时,需要注意一下。
一、ubuntu18.0.4文本配置修改方法
#netplan配置方法
1、ubuntu18.04 使用了netplan来管理网络:查看/etc/netplan下面的文件,如果没有*.yaml后缀的文件,就运行如下命令创建一个(netplan会读取该目录下所有该后缀的文件):
sudo netplan generate
2、打开网络地址配置文件
vim /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
eno1:
dhcp4: no //手动配置
addresses: [192.168.10.121/24] //ip地址
gateway4: 192.168.10.254 //网关
nameservers:
addresses: [192.168.10.131] //dns服务器地址
3、通过netplan更新配置
sudo netplan apply
4、用ifconfig或者ip r l查看配置的信息
#ifconfig
ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.121 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::3648:edff:fef9:557c prefixlen 64 scopeid 0x20<link>
ether 34:48:ed:f9:55:7c txqueuelen 1000 (Ethernet)
RX packets 2512951 bytes 266808016 (266.8 MB)
RX errors 0 dropped 33502 overruns 0 frame 0
TX packets 1106168 bytes 77337745 (77.3 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 80
#ip r l
ip r l
default via 192.168.10.254 dev eno1 proto static
192.168.10.0/24 dev eno1 proto kernel scope link src 192.168.10.121
二、ubuntu18.0.4图形配置修改方法
#通过dpkg -l ubuntu-desktop查看,安装的是ubuntu-desktop版本
dpkg -l ubuntu-desktop
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============================-====================-====================-=================================================================
ii ubuntu-desktop 1.417 amd64 The Ubuntu desktop system
是用图形界面配置的网络 默认使用了NetworkManager来配置网卡地址,配完后信息存在
/etc/NetworkManager/system-connections/Wired\ connection\ 1
[connection]
id=Wired connection 1
uuid=f902ce0e-d3f2-3ffa-b382-55080ce8fde8
type=ethernet
autoconnect-priority=-999
permissions=
timestamp=1657781148
[ethernet]
mac-address=0C:C4:7A:E1:88:3E
mac-address-blacklist=
[ipv4]
address1=192.168.10.104/24,192.168.10.254
dns=192.168.10.131;
dns-search=
method=manual
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto
#如果用远程ssh上去,还可以用 nmtui命令进行修改
版权声明:本文为m0_48898914原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。