linux 主机无法联网问题

主机不能联网
查看当前ip ping路由

ifconfig wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.78  netmask 255.255.255.0  broadcast 192.168.2.255

ping 192.168.2.1

查看是否能ping通

查看路由表

route -n
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.2.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0

这种情况缺默认网关,添加网关

route add default gw 192.168.2.1
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.2.1   0.0.0.0         UG    0      0        0 wlan0
192.168.2.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0

查看 /etc/resolv.conf dns解析

cat    /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "resolvectl status" to see details about the actual nameservers.
nameserver 192.168.0.1

dns解析为空或缺失对应 添加一行

nameserver 192.168.2.1

192.168.2.1修改为对应的路由地址

相关推荐

  1. linux 主机无法联网问题

    2024-01-29 19:18:03       52 阅读
  2. linux jenkins下找不到主机问题

    2024-01-29 19:18:03       53 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-29 19:18:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-29 19:18:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-29 19:18:03       87 阅读
  4. Python语言-面向对象

    2024-01-29 19:18:03       96 阅读

热门阅读

  1. C语言——函数

    2024-01-29 19:18:03       48 阅读
  2. 牛客每日一解

    2024-01-29 19:18:03       60 阅读
  3. 学习Vue3的defineProps方法

    2024-01-29 19:18:03       55 阅读
  4. 使用 ip2region 或 geoip2 根据用户ip获取用户省市

    2024-01-29 19:18:03       55 阅读
  5. Ubuntu20.0.4下设置frpc开机自启动

    2024-01-29 19:18:03       41 阅读