您的位置:首页 > 理论基础 > 计算机网络

网络测试工具和Ubuntu网络配置

2019-10-26 16:12 3955 查看

测试网络工具

  • 在命令行下测试网络的连通性
    显示主机名
      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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: