網絡測試工具和Ubuntu網絡配置

測試網絡工具

  • 在命令行下測試網絡的連通性
    顯示主機名
      hostname
    測試網絡連通性
      ping
    顯示正確的路由表
      ip route
  • 跟蹤路由
      traceroute
      tracepath
      mtr
  • 確定名稱服務器使用
      nslookup
      host
      dig

Ubuntu網絡配置

官網文檔:
https://help.ubuntu.com/lts/serverguide/network-configuration.html.zh-CN

配置自動獲取IP

cat /etc/netplan/01-netcfg.yaml
network:
 version: 2
 renderer: networkd
 ethernets:
   ens33:
      dhcp4: yes

修改網卡配置文件後需執行命令生效:netplan apply

配置靜態IP:

cat /etc/netplan/01-netcfg.yaml
network:
   version: 2
   renderer: networkd
   ethernets:
  eth0:
    addresses:
      - 192.168.6.10/24
     - 10.10.10.10/24
   gateway4: 192.168.6.1
   nameservers:
    search: [mydomain, otherdomain]
    addresses: [223.5.5.5, 8.8.8.8, 1.1.1.1]

查看ip和gateway

ip addr
route -n

查看DNS

  • ls -l /etc/resolv.conf
    lrwxrwxrwx 1 root root 39 Dec 12 11:36 /etc/resolv.conf
    \> ../run/systemd/resolve/stub-resolv.conf
  • systemd-resolve --status

修改主機名

hostnamectl set-hostname ubuntu1904

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章