Ubuntu Server 无头启动 + 配置
2025年1月13日大约 1 分钟
最近整了一套 Z270 + 1240v6,打算无头启动(连显卡都无的那种!),结果踩坑了,拔了显卡之后网络挂壁,而且CPU风扇慢转。
以为是内核模块挂了导致 kernel panic,排查了好几个小时,终于看到这篇博文,是 PCIE 变动导致网卡名称改变的问题,遂修改 netplan 为:
network:
version: 2
ethernets:
enp1s0:
dhcp4: true
enp2s0:
dhcp4: true
enp3s0:
dhcp4: true
enp4s0:
dhcp4: true
enp5s0:
dhcp4: true
重启解决!后面进去一看,哎,正好是跑到了 enp1s0 的位置!
Edit: 其实可以使用 netplan 的 MAC match 功能进行指定,可以有效解决这些问题。
最终配置
netplan:
network:
version: 2
ethernets:
onboardeth:
match:
macaddress: aa:bb:cc:dd:ee:ff
dhcp4: false
addresses:
- 192.168.1.x/24
- 192.168.8.x/24
routes:
- to: default
via: 192.168.1.1
- to: 192.168.255.y/25
via: 192.168.8.z
nameservers:
addresses:
- 192.168.1.1
/etc/udev/rules.d/99-usb-serial-getty.rules:
ACTION=="add", SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", RUN+="/usr/bin/stty -F /dev/%k 115200", TAG+="systemd", ENV{SYSTEMD_WANTS}="serial-getty@%k.service"
lxd + vxlan 隔离网络配置:
https://artivis.github.io/post/2024/lxc-isolated/
name: lxdbr2
description: ipv4 only internet isolated
type: bridge
config:
security.acls: external-only
security.acls.default.egress.action: allow
security.acls.default.ingress.action: allow
ipv4.address: 10.122.156.1/24
ipv4.nat: 'true'
ipv6.address: none
name: lxdbr1
description: vxlan to global v6
type: bridge
config:
tunnel.lxdv6.id: 'abcd'
tunnel.lxdv6.interface: enp3s0
tunnel.lxdv6.local: 192.168.8.x
tunnel.lxdv6.port: '4789'
tunnel.lxdv6.protocol: vxlan
tunnel.lxdv6.remote: 192.168.8.z
ipv4.address: none
ipv6.address: none
/etc/systemd/system/wol.service:
[Unit]
Description=Enable Wake On Lan
[Service]
Type=oneshot
#ExecStart=/bin/bash -c 'for a in {1..9}; do echo /usr/sbin/ethtool --change enp"${a}"s0 wol g || true; done'
ExecStart=/etc/initwol.sh
[Install]
WantedBy=basic.target
有用的命令:
systemctl enable serial-getty@ttyUSBx