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

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

sudo systemctl stop NetworkManager.service
sudo systemctl disable NetworkManager.service

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

  1. 临时,直接使用命令行方式,重启后失效
    sudo ifconfig eth0 down
    sudo ifconfig eth0 hw ether xx:xx:xx:xx
    sudo 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 lo
iface lo inet loopback 
# The primary network interface
auto eth0 #网卡
iface eth0 inet static #设置IPV4为静态地址
address 1.1.1.2 #设置IP
netmask 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地址

 

参考:

http://blog.csdn.net/zhangwu1241/article/details/53311534

http://www.youritronics.com/how-to-set-the-mac-address-from-etcnetworkinterfaces-in-debian/

https://www.cnblogs.com/qiuxiangmuyu/p/6343841.html

http://wiki.ubuntu.org.cn/Quick_HOWTO_:_Ch03_:_Linux_Networking/zh#.2Fetc.2Fnetwork.2Finterfaces.E6.96.87.E4.BB.B6

http://blog.csdn.net/u011077672/article/details/71123319

https://wiki.debian.org/NetworkConfiguration

posted @ 2018-02-04 13:07  EasonJim  阅读(14299)  评论(0编辑  收藏  举报