国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

ubuntu 22.04版本修改服務(wù)器名、ip,dns信息的操作方法

這篇具有很好參考價值的文章主要介紹了ubuntu 22.04版本修改服務(wù)器名、ip,dns信息的操作方法。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

總結(jié)
1、ubuntu修改服務(wù)器名重啟后生效的方法是直接修改/etc/hostname文件

2、ubuntu 22.04操作系統(tǒng)配置ip和dns信息,一般只需要使用netplan命令行工具來配置就行,在/etc/netplan/在目錄下創(chuàng)建一個yaml文件就可以實現(xiàn)ip和dns的配置,當(dāng)然如果/etc/netplan下有多個yaml文件,則所有/etc/netplan/*.yaml文件都將被netplan命令行使用,參見官方文檔https://ubuntu.com/server/docs/network-configuration和https://manpages.ubuntu.com/manpages/jammy/man5/netplan.5.html

3、個人不建議使用/etc/resolve.conf來配置ubuntu 22.04操作系統(tǒng)的dns信息,因為太復(fù)雜了,這個文件是被systemd-resolved服務(wù)托管。ubuntu操作系統(tǒng)/etc/resolve.conf中默認使用的是 nameserver 127.0.0.53回環(huán)地址,/etc/resolve.conf文中有這么一句話This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8). Do not edit。說明這個文件是被systemd-resolved這個服務(wù)托管的。通過 netstat -tnpl| grep systemd-resolved 查看到這個服務(wù)是監(jiān)聽在 53 號端口上。為啥要用127.0.0.53作為回環(huán)地址而不是127.0.0.1,因為127網(wǎng)段都是回環(huán)地址(127.0.0.1 - 127.255.255.254),不過通常用大家只喜歡用127.0.0.1來表示而已,53表示dns端口
3.1、新安裝的ubuntu 22.04環(huán)境不做其他改動的情況下,/etc/resolv.conf是/run/systemd/resolve/stub-resolv.conf的軟鏈接,如果只是手工更改/etc/resolv.conf中的內(nèi)容,重啟會后發(fā)現(xiàn)/etc/resolv.conf中的內(nèi)容又恢復(fù)成原樣了,比如注釋/etc/resolv.conf文件中的nameserver 127.0.0.53這一行,重啟系統(tǒng)后被注釋掉的nameserver 127.0.0.53這一行又回來了,如果不想重啟后/etc/resolv.conf中的內(nèi)容恢復(fù)成原樣,則執(zhí)行systemctl stop systemd-resolved和systemctl disable systemd-resolved,或把/etc/resolv.conf對應(yīng)的軟鏈接刪除,再手工建立一個/etc/resolv.conf
3.2、使用/etc/netplan/00-installer-config.yaml配置DNS 172.22.10.66并執(zhí)行netplan apply使之生效,再修改/etc/systemd/resolved.conf內(nèi)容里的DNS為172.22.136.2,然后執(zhí)行systemctl restart systemd-resolved,發(fā)現(xiàn)/etc/resolv.conf中的內(nèi)容沒變還是127.0.0.53,再執(zhí)行resolvectl status可以看到/etc/systemd/resolved.conf中的DNS 172.22.136.2存在,/etc/netplan/00-installer-config.yaml中的DNS 172.22.10.66也在,就是沒有/etc/resolv.conf中的127.0.0.53。重啟操作系統(tǒng)后/etc/resolv.conf中的內(nèi)容沒變還是127.0.0.53,重啟操作系統(tǒng)后執(zhí)行resolvectl status還是只有/etc/systemd/resolved.conf中的DNS 172.22.136.2和/etc/netplan/00-installer-config.yaml中的DNS 172.22.10.66,沒有/etc/resolv.conf中的127.0.0.53

4、ubuntu官方不建議使用/etc/resolve.conf來配置ubuntu 的dns信息,ubuntu對于/etc/resolv.conf的官方描述:If you require DNS for your temporary network configuration, you can add DNS server IP addresses in the file /etc/resolv.conf. In general, editing /etc/resolv.conf directly is not recommended, but this is a temporary and non-persistent configuration.

5、ubuntu 22.04查看dns信息的命令是resolvectl status,該命令可以看到全局dns信息和某個網(wǎng)卡的dns信息,全局DNS服務(wù)器信息一般來自配置文件/etc/systemd/resolved.conf,僅在/etc/resolv.conf不是一個指向/run/systemd/resolve/stub-resolv.conf, /usr/lib/systemd/resolv.conf, /run/systemd/resolve/resolv.conf 之一的軟連接的情況下,且/etc/systemd/resolved.conf中dns被注釋掉的情況下,全局DNS服務(wù)器才會讀取自/etc/resolv.conf,所以這就是不建議大家使用/etc/resolve.conf來配置ubuntu 的dns信息的原因。

修改服務(wù)器名
修改服務(wù)器名為FRSBachDEV3,重啟后也生效的方法
vi /etc/hostname
FRSBachDEV3
備注:如果/etc/hostname文件中的內(nèi)容寫成hostname FRSBachDEV3,那么重啟后服務(wù)器名就變成了hostnameFRSBachDEV3

修改IP
https://ubuntu.com/server/docs/network-configuration
https://manpages.ubuntu.com/manpages/jammy/man5/netplan.5.html
netplan是一個命令行工具,用于ubuntu上配置網(wǎng)絡(luò),所有/etc/netplan/*.yaml文件都將被使用

root@FRSBachDEV3:~# cat /etc/netplan/00-installer-config.yaml
network:
  ethernets:
    ens160:
      dhcp4: true
  version: 2
root@FRSBachDEV3:~# vim /etc/netplan/00-installer-config.yaml
network:
  ethernets:
    ens160:
      dhcp4: false
      addresses: [172.22.136.147/22]
      routes:
        - to: default
          via: 172.22.136.1
      nameservers:
        search: [dai.netdai.com,netdai.com]
        addresses: [172.22.10.66,172.22.10.67]
  version: 2

備注:
dhcp4中的4表示ipv4
gateway4中的4表示ipv4,不過gateway4已經(jīng)被廢棄,配置了gateway4再執(zhí)行netplan apply的話會報錯** (generate:1426): WARNING **: 09:54:13.918: gateway4 has been deprecated, use default routes instead.See the ‘Default routes’ section of the documentation for more details.
routes項填寫網(wǎng)關(guān)地址
addresses項填寫ip地址
nameservers項填寫dns地址或搜索域,其中addresses子項是dns地址列表,search子項是搜索域名列表
version: 2這一項表示YAML版本是2,curtin,MaaS等目前使用的YAML的版本是1

root@FRSBachDEV3:~# netplan apply

root@FRSBachDEV3:~# cat /etc/resolv.conf
nameserver 127.0.0.53
options edns0 trust-ad
search dai.netdai.com netdai.com

root@FRSBachDEV3:~# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.22.136.147  netmask 255.255.252.0  broadcast 172.22.139.255
        inet6 fe80::250:56ff:fe94:522d  prefixlen 64  scopeid 0x20<link>
        ether 00:50:56:94:52:2d  txqueuelen 1000  (Ethernet)
        RX packets 45071  bytes 3394009 (3.3 MB)
        RX errors 0  dropped 40  overruns 0  frame 0
        TX packets 765  bytes 78732 (78.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2331  bytes 168025 (168.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2331  bytes 168025 (168.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

查看網(wǎng)關(guān)

root@FRSBachDEV3:~# ip route | grep default
default via 172.22.136.1 dev ens160 proto static

root@FRSBachDEV3:~# nmcli dev show|grep GATEWAY
IP4.GATEWAY:                            172.22.136.1
IP6.GATEWAY:                            --
IP4.GATEWAY:                            --
IP6.GATEWAY:                            --

查看dns

root@FRSBachDEV3:~# resolvectl status
Global
       Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub

Link 2 (ens160)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 172.22.10.66
       DNS Servers: 172.22.10.66 172.22.10.67
        DNS Domain: dai.netdai.com netdai.com

實驗:如何才會使用到/etc/resolve.conf中的dns信息文章來源地址http://www.zghlxwxcb.cn/news/detail-745822.html

/etc/systemd/resolved.conf中dns為172.22.136.2
root@FRSBachDEV3:~# cat /etc/systemd/resolved.conf |grep DNS=
DNS=172.22.136.2

/etc/resolv.conf來自軟鏈接/run/systemd/resolve/stub-resolv.conf
root@FRSBachDEV3:~# ll /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Aug  9  2022 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

root@FRSBachDEV3:~# cat /run/systemd/resolve/stub-resolv.conf
nameserver 127.0.0.53
options edns0 trust-ad
search dai.netdai.com netdai.com

/run/systemd/resolve/resolv.conf有來自/etc/systemd/resolved.conf中dns 172.22.136.2,也有來自/etc/netplan/00-installer-config.yaml中dns 172.22.10.66 172.22.10.67,就是沒有來自/etc/resolv.conf的127.0.0.53
root@FRSBachDEV3:~# cat /run/systemd/resolve/resolv.conf
nameserver 172.22.136.2
nameserver 172.22.10.66
nameserver 172.22.10.67
search dai.netdai.com netdai.com

/etc/systemd/resolved.conf中dns 172.22.136.2和/etc/netplan/00-installer-config.yaml中dns 172.22.10.66 172.22.10.67,就是沒有來自/etc/resolv.conf的127.0.0.53
root@FRSBachDEV3:~# resolvectl status
Global
         Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
  resolv.conf mode: stub
Current DNS Server: 172.22.136.2
       DNS Servers: 172.22.136.2

Link 2 (ens160)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 172.22.10.66
       DNS Servers: 172.22.10.66 172.22.10.67
        DNS Domain: dai.netdai.com netdai.com

刪除/etc/resolv.conf來自軟鏈接,并手工建立/etc/resolv.conf文件,其中dns為172.22.136.3
root@FRSBachDEV3:~# ll /etc/resolv.conf
-rw-r--r-- 1 root root 946 Oct 12 10:49 /etc/resolv.conf

root@FRSBachDEV3:~# cat /etc/resolv.conf
nameserver 172.22.136.3
options edns0 trust-ad
search dai.netdai.com netdai.com

保留/etc/systemd/resolved.conf中dns 172.22.136.2的情況下,重啟systemd-resolved,發(fā)現(xiàn)還是用的/etc/systemd/resolved.conf中dns 172.22.136.2而沒有使用手工建立/etc/resolv.conf文件的dns 172.22.136.3
root@FRSBachDEV3:~# systemctl restart systemd-resolved
root@FRSBachDEV3:~# resolvectl status
Global
       Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: foreign
     DNS Servers: 172.22.136.2

Link 2 (ens160)
Current Scopes: DNS
     Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
   DNS Servers: 172.22.10.66 172.22.10.67
    DNS Domain: dai.netdai.com netdai.com

注釋掉/etc/systemd/resolved.conf中dns再重啟systemd-resolved,發(fā)現(xiàn)這個時候才真正用上了手工建立/etc/resolv.conf文件的dns 172.22.136.3
root@FRSBachDEV3:~# vim /etc/systemd/resolved.conf
root@FRSBachDEV3:~# cat /etc/systemd/resolved.conf |grep DNS
#DNS

root@FRSBachDEV3:~# systemctl restart systemd-resolved
root@FRSBachDEV3:~# resolvectl status
Global
         Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
  resolv.conf mode: foreign
Current DNS Server: 172.22.136.3
       DNS Servers: 172.22.136.3
        DNS Domain: dai.netdai.com netdai.com

Link 2 (ens160)
Current Scopes: DNS
     Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
   DNS Servers: 172.22.10.66 172.22.10.67
    DNS Domain: dai.netdai.com netdai.com

root@FRSBachDEV3:~# cat /run/systemd/resolve/resolv.conf
nameserver 172.22.136.3
nameserver 172.22.10.66
nameserver 172.22.10.67
search dai.netdai.com netdai.com

到了這里,關(guān)于ubuntu 22.04版本修改服務(wù)器名、ip,dns信息的操作方法的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Ubuntu 22.04 安裝配置時間同步服務(wù)器

    Ubuntu 22.04 安裝配置時間同步服務(wù)器

    參數(shù)解釋: 1.server 127.127.1.0 #local clock 這個參數(shù)指定了一個本地時鐘源。127.127.1.0 ,通常用于表示本地計算機的時鐘。這個參數(shù)告訴NTP守護進程,如果無法從其他NTP服務(wù)器獲取時間,或者作為備份時鐘源,應(yīng)該使用本地計算機的時鐘作為時間源。 2.fudge 127.127.1.0 stratum 10 這個參

    2024年04月28日
    瀏覽(38)
  • ubuntu22.04 服務(wù)器 SSH 密鑰登錄失敗

    SSH密鑰登錄,是將SSH公鑰寫入服務(wù)端的 ~/.ssh/authorized_keys 文件中。 今天裝了ubuntu22.04的系統(tǒng),按照以往操作,在服務(wù)端配置了SSH公鑰之后,發(fā)現(xiàn)竟然無法登錄。 首先查看OpenSSH版本: 查看 /var/log/auth.log 文件,發(fā)現(xiàn)有如下錯誤信息: 通過錯誤信息來看,填入 authorized_keys 文件的

    2024年01月18日
    瀏覽(22)
  • Ubuntu22.04 安裝深度學(xué)習(xí)服務(wù)器全紀錄

    Ubuntu22.04 安裝深度學(xué)習(xí)服務(wù)器全紀錄

    制作啟動盤 參考鏈接:https://blog.csdn.net/lyx_ok/article/details/129308753 安裝 Ubuntu 22.04 將U盤插到服務(wù)器上,開機按F11鍵(具體什么鍵跟主板型號有關(guān))選擇啟動項進入臨時的 Ubuntu 系統(tǒng),在圖形界面中選擇 Install Ubuntu ,所有配置都可以使用默認的,改一下用戶名和密碼即可。 進入

    2024年02月16日
    瀏覽(26)
  • ubuntu 22.04 服務(wù)器網(wǎng)卡無IP地址

    ubuntu 22.04 服務(wù)器網(wǎng)卡無IP地址

    ssh連接服務(wù)器連接不上,提示如下; 連接顯示器 ,ip addr ls 命令查看IP地址,有網(wǎng)卡但沒有IP地址 用于通過 DHCP 協(xié)議獲取網(wǎng)絡(luò)配置信息并為名為 enp10s0 的網(wǎng)絡(luò)接口分配 IP 地址,enp10s0替換為本機網(wǎng)絡(luò)接口名稱 但是一旦重啟 ,又沒了IP地址 。目前為止暫未找到解決辦法 偶然的機

    2024年02月22日
    瀏覽(26)
  • Ubuntu服務(wù)器安裝配置slurm (Ubuntu 22.04 LTS)

    Slurm 全稱 S imple L inux U tility for R esource M anagement。通常被用于大型Linux服務(wù)器 (超算) 上,作為任務(wù)管理系統(tǒng)。本文詳細講述如何在 Ubuntu 22.04 LTS 上安裝slurm,并進行簡單的配置。 其實網(wǎng)上相關(guān)的教程已經(jīng)非常多,但在舊版本的Ubuntu上安裝slurm時,通常需要安裝一個名為slurm-ll

    2024年02月07日
    瀏覽(100)
  • 【Ubuntu】ubuntu22.04使用VNC鏈接服務(wù)器遠程桌面

    【Ubuntu】ubuntu22.04使用VNC鏈接服務(wù)器遠程桌面

    本地主要需要一個VNC客戶端,用來遠程連接服務(wù)器端的VNC(在不安裝Web版本VNC情況下)。VNC客戶端下載地址: VNC客戶端下載 在遠程服務(wù)器控制臺中安裝Xfce桌面(這個桌面環(huán)境比較輕量化,博主用的88塊錢的騰訊云服務(wù)器) 注意更新軟件源 在遠程服務(wù)器控制臺中安裝 tightvn

    2024年02月03日
    瀏覽(30)
  • 在 ubuntu 22.04 上配置界面服務(wù)器 xrdp

    安裝 vnc 服務(wù)器 和 xrdp 服務(wù)器 配置 ~/.xsession

    2024年02月07日
    瀏覽(30)
  • 在 ubuntu 22.04 上配置界面服務(wù)器 vnc

    xrdp服務(wù)器的安裝 1.安裝服務(wù)器 查看配置 2.設(shè)置密碼 3.更改 ~/.vnc/xstartup 4.重新啟動 5.連接

    2024年02月08日
    瀏覽(27)
  • 服務(wù)器Ubuntu 22.04 64位安裝 MySQL5.7

    服務(wù)器Ubuntu 22.04 64位安裝 MySQL5.7

    官網(wǎng)地址 這里選擇下載5.7.29的ubuntu版本注意是amd64不是arm64,或者執(zhí)行下面命令 解壓下載下來的包 ls一下看看有什么 我們先安裝這個 然后再裝下一個 喜聞樂見的報錯,說我們沒有安裝紅圈里的兩個,我們?nèi)グ惭b 好嘛,server依賴client,client又缺少libtinfo5,那就不能先裝clien

    2024年02月06日
    瀏覽(28)
  • 基于Ubuntu22.04的Samba服務(wù)器搭建教程(新手保姆級教程)

    基于Ubuntu22.04的Samba服務(wù)器搭建教程(新手保姆級教程)

    Samba 是在 Linux 和 UNIX 系統(tǒng)上實現(xiàn)SMB 協(xié)議的一個免費軟件,由服務(wù)器及客戶端程序構(gòu)成。SMB(Server Messages Block,信息服務(wù)塊)是一種在局域網(wǎng)上共享文件和打印機的一種通信協(xié)議,它為局域網(wǎng)內(nèi)的不同計算機之間提供文件及打印機等資源的共享服務(wù)。SMB協(xié)議是客戶機/服務(wù)器型

    2024年04月08日
    瀏覽(31)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包