简体   繁体   中英

How to set static IP address using connman for wifi network

I'm trying to set a static IP(manual, no dhcp) address for wifi network using connmanctl. I'm running angstrom linux.

I get the following:

connmanctl
connmanctl> config wifi_"HASH"_managed_psk --ipv4 manual 192.168.10.2 255.255.255.0 192.168.10.1 Error wifi_"HASH"_managed_psk: Not supported

anyone has an idea how to do it?

Instead of editing settings under /var/lib/connman/wifi_<HASH>_managed_psk/ , one should edit the config file /var/lib/connman/ service-name .config instead.

eg

debian@beaglebone:/var/lib/connman$ sudo cat wifi.config
[service_home]
Type = wifi
Name = yyyyyyyyy
Security = wpa
Passphrase = xxxxxxxxxx
IPv4=192.168.1.4/255.255.255.0/192.168.1.254
IPv6=off
Nameservers=8.8.8.8,8.8.4.4

For details, refer to the man page connman-service.config

I managed to get a static IP address by manually creating a file named "settings" inside the directory:

  /var/lib/connman/wifi_<HASH>_managed_psk/

with the following content:

[wifi_<HASH>_managed_psk] 
Name=<SSID>                       ←Name of the network 
SSID=544f52414445585f4252         ←Name of the network in hexadecimal format    
Favorite=true
IPv4.method=manual                ←Method to be used (in this case manual IP)
IPv4.netmask_prefixlen=24
IPv4.local_address=192.168.0.133  ←Desired IP address
IPv4.gateway=192.168.0.1
Passphrase=<PASS>                 ←Wifi network password
AutoConnect=true

then activated and connected to the wifi

connmanctl enable wifi
connmanctl connect wifi_<HASH>_managed_psk

尝试connmanctl enable wifi然后你应该能够配置它

once you install connman then it create configuration directory in /var/lib/connman where devices like wifi ,Ethernet etc. configuration file is created. in those file there is entry like :

[service_wifi_<HASH>_managed_psk]
Type = wifi
Name = <SSID>
Passphrase = <PASSPHRASE>   
IPv4.method=dhcp

open that file and see given name is correct that you are using in command

connmanctl config wifi_"HASH"_managed_psk --ipv4 manual 192.168.10.2 255.255.255.0 192.168.10.1

if other than wifi_"HASH"_managed_psk then use that . or you can see by using command connmanctl services

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM