Ubuntu上网功能的配置

版权声明:凡本人原创,转发请注明出处,谢谢! https://blog.csdn.net/qq_41248872/article/details/86636574

虽然用了Ubuntu系统时间不短了,但每次重装或者升级后都会出现无法上网的问题,所以在此做下记录,方便以后配置,同时也希望能给不会配置的朋友一些帮助。

网络配置流程:

前提准备工作:

1、关闭ubuntu的防火墙
ufw disable

2、卸载iptables
apt-get remove iptables
 

1.验证网卡驱动是否已经安装成功

       打开终端 输入 ping 127.0.0.1 ,如果能ping通证明网卡驱动是好的。

2、手动设置ip
1)设置固定ip
sudo gedit /etc/network/interfaces
将里边的内容改为:

auto lo

iface lo inet loopback

auto eth0

iface eth0 inet static

address 192.168.31.92

netmask 255.255.255.0

network 192.168.31.0

broadcast 192.168.31.255

gateway 192.168.31.1

dns-nameservers 202.96.128.86

2)设置DNS服务器
sudo gedit /etc/resolv.conf
添加格式:
nameserver  202.96.128.86  (202.96.128.86是深圳电信DNS,各个区域可以自行网络查询,实在不知也可填网关地址)

3执行

      sudo gedit /etc/NetworkManager/NetworkManager.conf    

      将managed=false 改成true

4、重启网络服务

      ifdown eth0 && ifup eth0

若报如下错误:

      RTNETLINK answers: No such process
/etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /run/resolvconf/resolv.conf
/etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /run/resolvconf/resolv.conf

执行命令自动修复:

        dpkg-reconfigure resolvconf 

再次重启网卡:

         ifdown eth0 && ifup eth0

重启成功。

测试:

root@ubuntu:/home/jiangyu# ping www.baidu.com
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39: icmp_seq=1 ttl=56 time=20.1 ms
64 bytes from 14.215.177.39: icmp_seq=2 ttl=56 time=11.2 ms
64 bytes from 14.215.177.39: icmp_seq=3 ttl=56 time=16.6 ms
64 bytes from 14.215.177.39: icmp_seq=4 ttl=56 time=15.7 ms
 

成功联网!

猜你喜欢

转载自blog.csdn.net/qq_41248872/article/details/86636574