ubuntu系统网络设置问题汇总

查询IP地址与网卡信息

ifconfig

或者

ip a

检查网络是否联通

ping xxx.xxx.xxx.xxx

设置静态IP地址

先查询网卡信息

ifconfig

得到如下的结果

eno1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 88:a4:c2:14:81:b3  txqueuelen 1000  (Ethernet)
        RX packets 527  bytes 36496 (36.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 866  bytes 157585 (157.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 323096  bytes 66697687 (66.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 323096  bytes 66697687 (66.6 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.132.43  netmask 255.255.255.0  broadcast 192.168.132.255
        inet6 240e:46c:a401:1f13:7371:c269:c750:972a  prefixlen 64  scopeid 0x0<global>
        inet6 240e:46c:a401:1f13:c084:6256:b76b:e32a  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::2ed:ce74:16aa:d8da  prefixlen 64  scopeid 0x20<link>
        ether 4c:d5:77:61:93:9f  txqueuelen 1000  (Ethernet)
        RX packets 89439  bytes 87512162 (87.5 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 64076  bytes 10228245 (10.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

网卡信息可能有多个,比如这里就有两个网卡 eno1wlp4s0
“inet”后面的IP地址是该网卡的IP地址,“netmask”后面的值是该网卡的子网掩码,
“ether”后面的值是该网卡的MAC地址,
“RX packets”表示该网卡接收到的数据包数量,
“TX packets”表示该网卡发送的数据包数量,
“RX errors”和“TX errors”表示该网卡接收和发送过程中发生的错误数量。

这时候选择我们想要固定的静态IP地址的网卡

ifconfig eno1 xxx.xxx.xxx.xxx(静态IP地址) netmask 255.255.255.0(网关)

注意,设置了静态IP地址不一定成功,这时候我们需要检查是否能够PING通

ping xxx.xxx.xxx.xxx(我们设置的静态IP地址)

如果不能,首先可以尝试开关网卡

sudo ifconfig eno1 down
sudo ifconfig eno1 up

如果不行,尝试重启网络服务

sudo systemctl restart NetworkManager.service

或者

sudo service NetworkManager stop
sudo service network restart
  • 10
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值