Ubuntu设置IP地址、网关、DNS

Ubuntu设置IP地址、网关、DNS

# step1 查看要配置的网络名称
ifconfig
# 显示有ens33 lo, 其中lo是本地环回地址127.0.0.1, 我需要配置的是ens33
# step2 修改网络配置
sudo vim /etc/network/interfaces #编辑网网卡配置文件
# step3 添加配置信息
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
# 以下内容是我新增的,之前只有lo本地
auto ens33 #开机自动连接网络
iface ens33 inet static #static表示使用固定ip, dhcp是动态ip
address 192.168.245.7 #设置ip地址
netmask 255.255.255.0 #子网掩码
gateway 192.168.245.2 #网关
# step4 保存退出
# step5 重启网络
/etc/init.d/networking restart #重启网络

猜你喜欢

转载自blog.csdn.net/weixin_42382758/article/details/128334573
今日推荐