打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Ubuntu 16.04修改MAC地址以及网络常用设置(IP/DNS/网关)

1、先停止桌面版自带的NetworkManager,这东西很难用,且有些设置需要重启。

sudo systemctl stop NetworkManager.servicesudo systemctl disable NetworkManager.service

2、设置MAC地址在帮助文档中应该找这个关键字:hardware address,设置有两种方式,临时和永久。

  1. 临时,直接使用命令行方式,重启后失效
    sudo ifconfig eth0 downsudo ifconfig eth0 hw ether xx:xx:xx:xxsudo ifconfig eth0 up
  2. 永久,修改/etc/network/interfaces
    #加入如下MAC地址配置hwaddress ether 00:01:04:1b:2C:1F#重启网络服务sudo service networking restart

3、网络常用设置/etc/network/interfaces(IP/DNS/网关)

#This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).# The loopback network interface #环路auto loiface lo inet loopback # The primary network interfaceauto eth0 #网卡iface eth0 inet static #设置IPV4为静态地址address 1.1.1.2 #设置IPnetmask 255.255.255.0 #设置子网掩码network 1.1.1.255 #设置网关gateway 1.1.1.1 #设置网关dns-nameservers 1.1.1.1 #设置DNS服务器,多个用空格隔开dns-search .com #限制.com的查询走上面设置的DNS服务器hwaddress ether 00:01:04:1b:2C:1F #设置MAC地址

重启网络生效修改mac:

systemctl restart networking.service

/etc/init.d/networking restart

使用systemd设置开机启动,systemd默认读取/etc/systemd/system下的配置文件,该目录下的文件会链接/lib/systemd/system/下的文件。一般系统安装完/lib/systemd/system/下会有rc-local.service文件,即我们需要的配置文件。

cat /lib/systemd/system/rc-local.service #查看rc-local.service文件

注:MAC地址由udev在系统启动时探测网卡并加载,可在以下两个文件中反映出来

/sys/class/net/eth0/address 

/etc/udev/rules.d/70-persistent-net.rules ----修改无效,根据硬件自动生成的文件

不过,用ifconfig修改了mac后, /sys/class/net/eth0/address 的值随即跟着变了;但 /etc/udev/rules.d/70-persistent-net.rules 却没有变,只有在udev探测到硬件发生变化时才会修改这个文件。

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
[求助]Ubuntu网络设置
VMware虚拟机之Ubuntu网络配置
解决Redhat企业版更改IP地址,网关,DNS和MAC地址的办法
修改mac地址
ubuntu?下MAC地址的修改
IP/Ethernet Intf
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服