Ubuntu ping IP: connect:Network is unreachable 解析

  • 问题描述如题:Ubuntu ping IP: connect:Network is unreachable
    如图所示:
    在这里插入图片描述

  • /etc/network/interface 文件描述如下

auto eth0 # 开机自动连接网络
iface eth0 inet static #static表示使用固定IP,dhcp表示动态IP
address xxx.xxx.xxx #本机IP地址
netmask xxx.xxx.xxx #子网掩码
gateway xxx.xxx.xxx #网关

解决方法:

1.配置ip,配置 /etc/network/interfaces 文件

      配置静态IP地址

sudo vim /etc/network/interfaces

内容如下:

auto lo
iface lo inet loopback
iface eth0 inet static
address 172.16.15.97
netmask 255.255.248.0
gateway 172.16.15.253
auto eth0

2.然后是DNS,配置 /etc/resolv.conf

   配置DNS

vim /etc/resolv.conf

增加以下内容:

nameserver 211.95.193.97
nameserver 211.92.8.161

3.增加默认网关

route add default gw 172.16.15.253

4.重新启动网络配置

sudo /etc/init.d/networking restart

附:
(几个名称解释)

eth0 eth1 网卡
netmask 网关
Genmask 网络掩码
Iface 设定使用的网络接口

设置网卡eth0 的IP地址和子网掩码
sudo ifconfig eth0 133.133.133.190 netmask 255.255.255.0

             ------------------------------------

设置网关
sudo route add default gw 133.133.133.40

  • 4
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 11
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值