我的 Linux 发行版是 Debian 12.8.0,64 位,英文版。
我已经安装了软件包ifupdown
,iproute2
并且macchanger
在寻求帮助之前,我查阅了以下帖子:
ip link set 未分配 IP 地址,但 ifup 分配了
注意:使用该软件包启动和关闭网络接口没有任何问题,ifupdown
并且能够访问互联网。
的内容/etc/network/interfaces
是
# 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
#allow-hotplug enxfe5953ed38a0
#iface enxfe5953ed38a0 inet static
# address 192.168.1.50/24
# gateway 192.168.1.1
# dns-* options are implemented by the resolvconf package, if installed
# dns-nameservers 9.9.9.9 149.112.112.112
的内容/etc/network/script/home-lan
是
# The primary network interface
allow-hotplug enxfe5953ed38a0
iface enxfe5953ed38a0 inet static
address 192.168.1.50/24
netmask 255.255.255.0
gateway 192.168.1.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 1.1.1.1 8.8.8.8
我创建了一个名为的 bash 脚本lan-new-up
,使其可执行,并将其放置在/usr/local/bin
其内容如下:
#!/bin/bash
sudo macchanger -r enxfe5953ed38a0
sudo cp /etc/network/script/home-lan /etc/network/interfaces.d
#sudo ifup enxfe5953ed38a0
sudo ip link set dev enxfe5953ed38a0 up
sudo ip address add 192.168.1.50/24 dev enxfe5953ed38a0
sudo ip route add default via 192.168.1.1 dev enxfe5953ed38a0
执行脚本后lan-new-up
,出现如下所示的错误:
username@hostname:~$ lan-new-up
[sudo] password for username:
Current MAC: 02:b3:c2:9f:0a:90 (unknown)
Permanent MAC: 02:b3:c2:9f:0a:90 (unknown)
New MAC: fe:59:53:ed:38:a0 (unknown)
username@hostname:~$ ping yahoo.com
ping: yahoo.com: Temporary failure in name resolution
感谢您的帮助。