你好,我写了一个简单的 bash 脚本,可以自动进行网络配置。只有最后一步没有自动运行,即建立 wifi 连接。这个脚本运行起来很简单。首先,它在 /etc/network/interfaces 中写入 lan 端口的配置,然后写入 wlan 的配置。最后一步是通过 wlan 建立连接。wlan-AP 有一个隐藏的 wlan,我无法更改它。我非常感谢大家的帮助
#!/bin/bash
# set static LAN IP in /etc/network/interfaces
echo -e 'auto eth0\nallow-hotplug eth0\niface eth0 inet static\n address 10.0.0.1\n netmask 255.255.255.0\n' >> /etc/network/interfaces
#set wlan config in /etc/network/interfaces
echo -e 'auto wlan0\nallow-hotplug wlan0\niface wlan0 inet manual\n wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf\n' >> /etc/network/interfaces
#write wlan config in etc/wpa_supplicant/wpa_supplicant.conf
echo -e 'ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev\nupdate_config=1\ncountry=DE\n\nnetwork={\n ssid="INTERN"\n scan_ssid=1\n psk="password"\n key_mgmt=WPA-PSK\n}\n' >> /etc/wpa_supplicant/wpa_supplicant.conf
# restart network manager
service network-manager restart
sleep 15
#network manager WIFI connect
nmcli device wifi connect "INTERN" password "password" hidden on
`