Ubuntu 22.10 开机无法自动联网及打印机识别问题求助
大家好,几天前我在Ubuntu 22.10上装了Apache,本来想把服务器弄成公网可访问的结果把开机自动联网的设置搞砸了。现在不仅开机得手动连网,打印机也找不到了。我本来想着新建个用户应该能解决,结果新用户也没网,现在每次重启都得手动敲sudo dhclient -v才能联网。一开始我还用过sudo ufw enable,后来发现dhclient就够了,而且关掉ufw网也正常,应该不是防火墙的锅?
我现在纠结要不要重装系统,或者换个用户能不能解决?我不敢乱试怕越搞越糟,目前就只试过开了又关ufw,没别的操作。对了,Ubuntu桌面右上角连网络连接的图标都没了,看起来NetworkManager好像没正常工作?
我的Ubuntu版本
执行命令:
lsb_release -a
输出:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.10
Release: 22.10
Codename: kinetic
UFW防火墙状态
执行命令:
sudo ufw status verbose
输出:
Status: Aktiv
Protokollierung: on (low)
Voreinstellung: allow (eingehend), allow (abgehend), deny (gesendet)
Neue Profile: skipZu Aktion Von
80,443/tcp (Apache Full) ALLOW IN Anywhere
137,138/udp (Samba) ALLOW IN Anywhere
139,445/tcp (Samba) ALLOW IN Anywhere
5050 ALLOW IN Anywhere
67,68/udp ALLOW IN Anywhere
69/udp ALLOW IN Anywhere
80,443/tcp (Apache Full (v6)) ALLOW IN Anywhere (v6)
137,138/udp (Samba (v6)) ALLOW IN Anywhere (v6)
139,445/tcp (Samba (v6)) ALLOW IN Anywhere (v6)
5050 (v6) ALLOW IN Anywhere (v6)
67,68/udp (v6) ALLOW IN Anywhere (v6)
69/udp (v6) ALLOW IN Anywhere (v6)
67,68/udp ALLOW OUT Anywhere
69/udp ALLOW OUT Anywhere
67,68/udp (v6) ALLOW OUT Anywhere (v6)
69/udp (v6) ALLOW OUT Anywhere (v6)
UFW可用应用列表
执行命令:
sudo ufw app list
输出:
Verfügbare Anwendungen:
Apache
Apache Full
Apache Secure
CUPS
Samba
networkd.conf配置
查看文件内容:
cat /etc/systemd/networkd.conf
内容:
# the networkd.conf.d/ subdirectory. The latter is generally recommended. # Defaults can be restored by simply deleting this file and all drop-ins. # # See networkd.conf(5) for details. [Network] #SpeedMeter=no #SpeedMeterIntervalSec=10sec #ManageForeignRoutingPolicyRules=yes #ManageForeignRoutes=yes #RouteTable= [DHCPv4] #DUIDType=vendor #DUIDRawData= [DHCPv6] #DUIDType=vendor #DUIDRawData=
Netplan配置文件
查看文件内容:
cat /etc/netplan/01-network-manager-all.yaml
内容:
# Let NetworkManager manage all devices on this system network: version: 2 renderer: NetworkManager dhcp4: true nameservers: addresses: [8.8.8.8, 8.8.4.4]
iptables规则
执行命令:
sudo iptables -L
输出:
Chain INPUT (policy ACCEPT)
target prot opt source destinationChain FORWARD (policy DROP)
target prot opt source destination
DOCKER-USER all -- anywhere anywhere
DOCKER-ISOLATION-STAGE-1 all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
LIBVIRT_FWX all -- anywhere anywhere
LIBVIRT_FWI all -- anywhere anywhere
LIBVIRT_FWO all -- anywhere anywhere
ufw-before-logging-forward all -- anywhere anywhere
ufw-before-forward all -- anywhere anywhere
ufw-after-forward all -- anywhere anywhere
ufw-after-logging-forward all -- anywhere anywhere
ufw-reject-forward all -- anywhere anywhere
ufw-track-forward all -- anywhere anywhereChain OUTPUT (policy ACCEPT)
target prot opt source destinationChain DOCKER (1 references)
target prot opt source destinationChain DOCKER-ISOLATION-STAGE-1 (1 references)
target prot opt source destination
DOCKER-ISOLATION-STAGE-2 all -- anywhere anywhere
RETURN all -- anywhere anywhereChain DOCKER-ISOLATION-STAGE-2 (1 references)
target prot opt source destination
DROP all -- anywhere anywhere
RETURN all -- anywhere anywhereChain DOCKER-USER (1 references)
target prot opt source destination
RETURN all -- anywhere anywhereChain LIBVIRT_FWI (1 references)
target prot opt source destination
ACCEPT all -- anywhere localhost/24 ctstate RELATED,ESTABLISHED
REJECT all -- anywhere anywhere reject-with icmp-port-unreachableChain LIBVIRT_FWO (1 references)
target prot opt source destination
ACCEPT all -- localhost/24 anywhere
REJECT all -- anywhere anywhere reject-with icmp-port-unreachableChain LIBVIRT_FWX (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhereChain LIBVIRT_INP (0 references)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:bootps
ACCEPT tcp -- anywhere anywhere tcp dpt:67Chain LIBVIRT_OUT (0 references)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:bootpc
ACCEPT tcp -- anywhere anywhere tcp dpt:68Chain ufw-after-forward (1 references)
target prot opt source destinationChain ufw-after-input (0 references)
target prot opt source destination
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:netbios-ns
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:netbios-dgm
ufw-skip-to-policy-input tcp -- anywhere anywhere tcp dpt:netbios-ssn
ufw-skip-to-policy-input tcp -- anywhere anywhere tcp dpt:microsoft-ds
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:bootps
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:bootpc
ufw-skip-to-policy-input all -- anywhere anywhere ADDRTYPE match dst-type BROADCASTChain ufw-after-logging-forward (1 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix "[UFW BLOCK] "Chain ufw-after-logging-input (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix "[UFW BLOCK] "Chain ufw-after-logging-output (0 references)
target prot opt source destinationChain ufw-after-output (0 references)
target prot opt source destinationChain ufw-before-forward (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere icmp destination-unreachable
ACCEPT icmp -- anywhere anywhere icmp time-exceeded
ACCEPT icmp -- anywhere anywhere icmp parameter-problem
ACCEPT icmp -- anywhere anywhere icmp echo-request
ufw-user-forward all -- anywhere anywhereChain ufw-before-input (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ufw-logging-deny all -- anywhere anywhere ctstate INVALID
DROP all -- anywhere anywhere ctstate INVALID
ACCEPT icmp -- anywhere anywhere icmp destination-unreachable
ACCEPT icmp -- anywhere anywhere icmp time-exceeded
ACCEPT icmp -- anywhere anywhere icmp parameter-problem
ACCEPT icmp -- anywhere anywhere icmp echo-request
ACCEPT udp -- anywhere anywhere udp spt:bootps dpt:bootpc
ufw-not-local all -- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp -- anywhere 239.255.255.250 udp dpt:1900
ufw-user-input all -- anywhere anywhereChain ufw-before-logging-forward (1 references)
target prot opt source destinationChain ufw-before-logging-input (0 references)
target prot opt source destinationChain ufw-before-logging-output (0 references)
target prot opt source destinationChain ufw-before-output (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ufw-user-output all -- anywhere anywhereChain ufw-logging-allow (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix "[UFW ALLOW] "Chain ufw-logging-deny (2 references)
target prot opt source destination
RETURN all -- anywhere anywhere ctstate INVALID limit: avg 3/min burst 10
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix "[UFW BLOCK] "Chain ufw-not-local (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere ADDRTYPE match dst-type LOCAL
RETURN all -- anywhere anywhere ADDRTYPE match dst-type MULTICAST
RETURN all -- anywhere anywhere ADDRTYPE match dst-type BROADCAST
ufw-logging-deny all -- anywhere anywhere limit: avg 3/min burst 10
DROP all -- anywhere anywhereChain ufw-reject-forward (1 references)
target prot opt source destinationChain ufw-reject-input (0 references)
target prot opt source destinationChain ufw-reject-output (0 references)
target prot opt source destinationChain ufw-skip-to-policy-forward (0 references)
target prot opt source destination
DROP all -- anywhere anywhereChain ufw-skip-to-policy-input (7 references)
target prot opt source destination
DROP all -- anywhere anywhereChain ufw-skip-to-policy-output (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhereChain ufw-track-forward (1 references)
target prot opt source destinationChain ufw-track-input (0 references)
target prot opt source destinationChain ufw-track-output (0 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere ctstate NEW
ACCEPT udp -- anywhere anywhere ctstate NEWChain ufw-user-forward (1 references)
target prot opt source destinationChain ufw-user-input (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:httpsChain ufw-user-limit (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 5 LOG level warning prefix "[UFW LIMIT BLOCK] "
REJECT all -- anywhere anywhere reject-with icmp-port-unreachableChain ufw-user-limit-accept (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhereChain ufw-user-logging-forward (0 references)
target prot opt source destinationChain ufw-user-logging-input (0 references)
target prot opt source destinationChain ufw-user-logging-output (0 references)
target prot opt source destinationChain ufw-user-output (1 references)
target prot opt source destination
备注:内容来源于stack exchange,提问作者jikki plikki

