Ubuntu 禁用 Netplan 而改用 ifupdown 配置网络
安装 Ubuntu Server 18.04 后发现网络配置方法有了变化,由原来的 ifupdown 改为了 Netplan。虽然网上可以轻易找到 Netplan 配置教程,如 Linode 这个或更详细官方文档,但对于需要沿用 ifupdown 的场景就会带来障碍。下面介绍如何禁用 Netplan 改回 ifupdown,并将默认 DNS 管理由 systemd-resolved 改回 resolvconf。
系统安装时设置
Netplan FAQ 里有提到,可以在系统安装时设置不用 Netplan(引导界面按 F6 键设置如下参数)。
netcfg/do_not_use_netplan=true
该方法似乎只在实体机上具操作性,用 VNC 和 VirtualBox 测试按 F6 没反应。网上查询说因安全原因拦截了部分按键,没有找到可行解决办法。试了几个 VNC 客户端和修改 ISO 镜像文件设置均无解。
系统安装后设置
下面操作如非 root 用户请在命令前加sudo
。过程中需仔细检查确认,弄错了会丢失网络连接。
1. 安装 ifupdown、resolvconf 软件包。
apt install ifupdown resolvconf
2. 修改/etc/network/interfaces
文件配置网络连接。
如设置 DHCP 网络(修改其中网卡名称。如要使用 eth0 经典命名方式,该文曾有介绍)。
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 allow-hotplug eth0 iface eth0 inet dhcp
或设置静态网络(其中 DNS 语句如果不改回 resolvconf 将不会起作用,而需要在 systemd-resolved 所属的/etc/systemd/resolved.conf
配置文件里设置)。
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx gateway xxx.xxx.xxx.xxx dns-nameservers 8.8.8.8 8.8.4.4
3. 关闭 & 重开网络接口,设置networking
服务开机启动和重启使设置生效。
ifdown --force eth0 lo && ifup -a systemctl enable networking systemctl restart networking
之后可通过systemctl status networking
检查是否设置成功。
4. 停止、取消和禁止 Netplan 相关服务运行,并移除 Netplan 软件包及其配置文件。
解释下所操作的服务:
networkd-dispatcher
是 Netplan 后端服务(桌面版则是NetworkManager
);networkd-dispatcher
是 Netplan 守护服务,可通过监听连接状态以执行特定事件操作;systemd-networkd-wait-online
用于检测systemd-networkd
所管理网络接口的连接状态;systemd-resolved
新的 DNS 管理服务,其配置文件里有的参数依赖 Netplan 后端服务工作;
systemctl stop systemd-networkd networkd-dispatcher systemd-networkd-wait-online systemd-resolved systemctl disable systemd-networkd networkd-dispatcher systemd-networkd-wait-online systemd-resolved systemctl mask systemd-networkd networkd-dispatcher systemd-networkd-wait-online systemd-resolved apt purge nplan netplan.io
后续如要切换回 Netplan,别忘了恢复上述系统服务。将带有 mask 的命令换成 unmask 运行一次,不然即使 start disable 了也没法使用服务。
其它可能用到的命令扩展:
systemctl list-dependencies systemd-networkd --reverse
查询指定服务所关联的依赖项;systemctl list-unit-files --type=masked --all
列出/lib/systemd/system
下被禁止的服务;
6. 完成以上操作就设置完成了,全文实测在 Ubuntu Server 18.04 系统下通过。
如果 DNS 解析不了,请检查/etc/resolv.conf
所链接的文件是否是/run/resolvconf/resolv.conf
。如果不是,运行下面命令设置。
ln -sf /run/resolvconf/resolv.conf /etc/resolv.conf
Hi, very nice website, cheers!
——————————————————
Need cheap and reliable hosting? Our shared plans start at $10 for an year and VPS plans for $6/Mo.
——————————————————
Check here: https://www.reliable-webhosting.com/
Hello, i read your blog occasionally and i own a similar one and i was just wondering if you get a lot of spam remarks? If so how do you stop it, any plugin or anything you can recommend? I get so much lately it’s driving me crazy so any support is very much appreciated.|
https://vbucks.press/
hydroxychloroquine use for fibromyalgia https://hydroxychloroquine.webbfenix.com/
dapoxetine tablets for sale https://salemeds24.wixsite.com/dapoxetine
ivermectin cost per pill https://ivermectin.webbfenix.com/
ivermectin tablets for humans for sale https://ivermectin.mlsmalta.com/
studies show hydroxychloroquine works https://hydroxychloroquine.mlsmalta.com/
cialis headache jocialisrl http://www.lm360.us/
vidalista 40 mg for sale https://vidalista.mlsmalta.com/
hydroxychloroquine for sale india https://hhydroxychloroquine.com/
is generic viagra as good http://droga5.net/
tamoxifen dose breast cancer https://tamoxifen.mrdgeography.com/
how does ivermectin work https://ivermectin1st.com/
cost of aurogra at costco https://aurogra.buszcentrum.com/
sildenafil and dapoxetine dosage https://ddapoxetine.com/
cvs pharmacy refill online https://medpills.bee-rich.com/
cvs pharmacy refill online https://buymeds.mlsmalta.com/
80mg vidalista strengths https://vidalista40mg.mlsmalta.com/
tadalafil for high blood pressure https://wisig.org/
cost of albuterol sulfate solution https://amstyles.com/
loan lenders
bbw cams
low rate personal loan
dexamethasone 75 mg
buy zentiva hydroxychloroquine https://hydroxychloroquinee.com/
cam fuze
online female viagra
levitra 80 mg
hydroxychloroquine 40 mg
ivermectin humans
where to buy cialis in singapore
universal property insurance
oct plaquenil toxicity images https://hydroxychloroquine.wisig.org/
oct plaquenil toxicity images https://hydroxychloroquine.lm360.us/
You have mentioned very interesting points! ps nice web site. “Justice is the truth in action.” by Jeseph Joubert.
http://www.vreyrolinomit.com/
In fact, nearly all high one hundred apps by client spend have a subscription choice.
Take a look at my blog post; free robux generator
Here, we’re talking about essentially the most promising and the popular languages for game localization in 2021.
Also visit my webpage 吸雞巴
The age group represents a mere 14.2% of mobile gamers, whereas folks older
than forty five years make up practically a 3rd.
Feel free to surf to my homepage: among us hack download
Plus, you can play with individuals on PS4, iOS, and PC as nicely.
My blog post; Roblox darmowy robux
rxtoed generic for cialis http://cialllis.com/
Noodlecake Studios also does Alto’s Adventure, the predecessor to this one.
Take a look at my web blog – 迪克情人
Overall, the Battle of Polytopia is simply an effective way to get your strategy gaming fix on cell.
Also visit my web blog https://chrome.google.com/webstore/detail/jgicjkljgilpgnnmjdajdfemfglnlcop
The game fuses a pixelated artwork fashion with pop culture references to
create a enjoyable and fascinating gaming experience.
my webpage: mobile games
Nice post. I was checking continuously this blog and I am impressed!
Extremely helpful info particularly the last part 🙂 I care for such
info a lot. I was seeking this particular info for a very long time.
Thank you and good luck.
My blog – top 10 mobile games to play with friends
tadalafil canadian pharmacy online https://cialis.cleckleyfloors.com/
tadalafil canadian pharmacy online https://cialis.studiowestinc.com/
alex9393939393 alex9393939393 alex9393939393 alex9393939393
Monument Valley is likely one of the prettiest puzzle games in existence — and one of many
prettiest games available in any genre, really.
Look into my blog – https://issuu.com/
ng Goes On In Our Tool So We Would Like To Verify That You Are
owers & likes with TikTokFollowersFree & become TikTok famous
ss of Getting Free Followers and Likes? Head to our free software. Add in your
All you have to do is enter in your username associated with your TikTok account, select the amount of followers you
Coin Master Triche et Astuce – Comment avoir illimité Pièces et Tours sur Coin Master – Triche Astuce en Ligne
ble option and not just that, it can be. Want some free spins and coins in Coin Master
begging, type your username. Connect the account by pressing the bottom “Get Followers”. Choose the number of the fans and likes you want
ligne de cigarettes! Notre site web a été lancé pour donner aux fumeurs la g
Among Us is the game on all of your minds so lets look at what the Among Us Mod Menu apk has to offer us. Find out more! Among us hack
All skins unlocked, always imposter mod. Use this hack mod to play Among US Hack Mod Menu with
please fax or e-mail Check `n Go your latest pay stub when applying to ensure timely processing of your loan
free tiktok followers
This generator allows users to get free tiktok followers completely for free.
HOW TO GET COIN MASTER FREE SPINS 2021: Apart from just taking the daily links above
will get 5 spins from coin master. You can get 40 spins
I am sure this post has touched all the internet visitors,
its really really pleasant post on building up new
webpage. http://antiibioticsland.com/Cipro.htm
coin master free spins
This game, the one which lit the world on fireplace for
a summer season, nonetheless has a surprisingly giant
variety of hardcore followers.
Here is my website – free robux generator
What software program growth platform / tool or engine do you use to build your games?
my web blog; roblox robux hack