0

Hello i write a simple bash script that make the network configuration automatically. Only the last step didnt work automatically, to establish the wifi connection. This script work simple. First it write in /etc/network/interfaces the configuration for the lan port then it write the config for wlan. The last step is to establish the connection over wlan. The wlan-AP has a hidden wlan and i cant change this. i am thankful for every help

#!/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
`

1 Answers1

0

The network manager doesn't use the interfaces file. It uses own configuration files.

If you use the interfaces file, you should use the commands of the ifupdown package (ifquery to get the interface configuration, ifup to bring up the inteface, ifdown to turn off the interface). Modern implementations of the ifupdown support the include option, so you can store interfaces configurations in separate files under the /etc/network/interfaces.d/ directory.

If you want use the network manager to configure the network, you use the nmcli command. Good examples how to do it (and other things too) you can find here and here.

Anton Danilov
  • 4,874
  • 2
  • 11
  • 20