ubuntu如何查看网络状态及基本配置(ubuntu如何查询网络状态)

您所在的位置:网站首页 如何查询网络 ubuntu如何查看网络状态及基本配置(ubuntu如何查询网络状态)

ubuntu如何查看网络状态及基本配置(ubuntu如何查询网络状态)

2023-04-03 02:35| 来源: 网络整理| 查看: 265

该配置环境为ubuntu16.04.2

(一) 网络配置

安装完成系统后网络配置如下:

第一步:ifconfig -a 查看有几个网卡

如下截图表示有四个网卡

第二步:找出接线网卡

执行命令:ifconfig +网卡 up

例:up 第一个网卡enp4s0f0

ifconfig enp4s0f0 up

然后执行命令: ethtool enp4s0f0  查看Link状态,如下截图:

如果是yes表示该网卡已经接线 ,尝试手动配置ip(配置方法请见下一步骤)。如果是no,继续ifconfig up其他网卡,直到找到yes的为止。如果全部是no,请检查网线是否接好

第三步:配置网卡ip(只有临时作用,再次重启服务器配置会失效)

命令:ifconfig enp11s0f1 10.57.23.13/25

说明:配置网卡 enp11s0f1  IP为10.57.23.13 掩码是25位。即255.255.255.128

配置好截图如下:

第四步:检测连通性

尝试ping 网关,如果网关不通,表示直连不通,请检查网线和配置。网关通,接着配置默认路由,见第五步

第五步:配置路由(临时,重启后失效)

route add default gw 10.57.23.1 (默认配置这一条后,内网可以正常访问),如果不能,添加如下明细:

route add -net 10.0.0.0/8 gw 10.57.23.1

route add -net 192.168.0.0/16 gw 10.57.23.1

route add -net 172.16.0.0/12 gw 10.57.23.1

route add -net 100.64.0.0/10 gw 10.57.23.1

第六步:写入配置文件(永久)

注:一定要写入配置文件

ubuntu为何不直接在最开始写入配置文件里。因为ubuntu直接写入配置文件,不重启服务器貌似不生效(个人经验)

vim /etc/network/interfaces 可以直接在这里修改,具体配置如下:

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

auto enp11s0f1     

iface enp11s0f1 inet static

address 10.57.23.13

netmask 255.255.255.128

gateway 10.57.23.1

####添加路由,这样网卡服务重启之后这些路由就会加载

up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.57.23.1

up route add -net 192.168.0.0 netmask 255.255.0.0 gw 10.57.23.1

up route add -net 172.16.0.0 netmask 255.240.0.0 gw 10.57.23.1

up route add -net 100.64.0.0 netmask 255.192.0.0 gw 10.57.23.1

重启网卡服务之后,配置的路由会自动加载,如下:

(二) 修改ssh 配置文件

ubuntu系统安装,默认是禁止root直接登录的

vim /etc/ssh/sshd_config

修改:PermitRootLogin yes

然后重启ssh服务 /etc/init.d/ssh restart



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3