Ubuntu 16.04.4的网络配置

1、查看网卡状态

root@Ubuntu-Ansible:~# ifconfig -a
root@Ubuntu-Ansible:~# ip addr
root@Ubuntu-Ansible:~# ip route show

2、设置静态IP

root@Ubuntu-Ansible:~# vim /etc/network/interfaces

加入如下内容:

auto eth0
iface eth0 inet static
address 192.168.1.5
gateway 192.168.1.1
netmask 255.255.255.0 

3、配置DNS

root@Ubuntu-Ansible:~# vim /etc/resolvconf/resolv.conf.d/base

DNS修改如下文件,默认是空的,在里面加入DNS服务器,一行一个

nameserver 180.76.76.76          # 百度DNS
nameserver 223.5.5.5                # 阿里DNS

保存后执行:

root@Ubuntu-Ansible:~# /sbin/resolvconf -u

root@Ubuntu-Ansible:~# etc/init.d/resolvconf restart

4、查看DNS

root@Ubuntu-Ansible:~# cat /etc/resolv.conf

5、重启网络服务

root@Ubuntu-Ansible:~# /etc/init.d/networking restart

6、一般此时已经可以联网,ping www.baidu.com 是可以ping通的 ,若不行,请尝试:

重启网卡:
root@Ubuntu-Ansible:~# ifconfig eht0 down
root@Ubuntu-Ansible:~# ifconfig eht0 up
重启Ubuntu:
root@Ubuntu-Ansible:~# reboot

7、网络OK了,不能SSH远程连接,检查sshd服务

root@Ubuntu-Ansible:~# ps -e|grep ssh
root@Ubuntu-Ansible:~# apt-get install openssh-sever

8、启动ssh

root@Ubuntu-Ansible:~# /etc/init.d/ssh start
root@Ubuntu-Ansible:~# netstat -tlp

8、Ubuntu升级更新

root@Ubuntu-Ansible:~# apt-get update
root@Ubuntu-Ansible:~# apt-get upgrade
root@Ubuntu-Ansible:~# apt-get dist-upgrade
root@Ubuntu-Ansible:~# reboot

转载于:https://blog.51cto.com/tangyade/2330627

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值