Is it possible to set a static IP on laptop wireless port?

Issues related to configuring your network
Post Reply
zetret
Posts: 6
Joined: 2017/06/17 16:36:07

Is it possible to set a static IP on laptop wireless port?

Post by zetret » 2017/06/17 16:42:06

Good Afternoon

I want to set a static IP on my wireless port (something like wlp4s0). I followed the steps to add parameters to ifcfg-<SSID> file like SSID, key, name, static boot protocol, but still I am unable to understand how this will register this IP with my wireless router. Can someone please explain how to do this on CentOS 7 or later.

Also, I'd like to know if enabling DHCP and letting the router give the same IP everytime to this laptop, is the same as setting a static IP? I am trying to setup OpenStack RDO on this CentOS which requires disabling NetworkManager. So, how am I supposed to get a static IP on this wireless port? Please explain.

Thank you
Regards

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: Is it possible to set a static IP on laptop wireless port?

Post by hunter86_bg » 2017/06/17 19:48:22

Post your /etc/sysconfig/network-scripts/ifcfg-wlp4s0 here.Once you define IPADDR and GATEWAY entries -stop Network Manger and restart the legacy network:

Code: Select all

systemctl stop NetworkManger && systemctl restart network && ip a s

zetret
Posts: 6
Joined: 2017/06/17 16:36:07

Re: Is it possible to set a static IP on laptop wireless port?

Post by zetret » 2017/06/17 20:24:40

Hi, yes I set IPADDR, GATEWAY, NETMASK, DNS entries as shown here; But when I stop NetworkManager, and start network like you mention, wlp4s0 shows as having the static IP, but can't ping the router. And the router doesn't have the connection. I think that makes sense, because you need to authenticate to the router, right? My question is how to do that.

HWADDR=MY_WIRELESS_CARD_MAC
ESSID="NAME_OF_SSID"
MODE=Managed
KEY_MGMT=WPA-PSK
TYPE=Wireless
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME="NAME_OF_SSID"
UUID=e123e936-2739-4e61-b721-9f87036ec14e
ONBOOT=yes
DNS1=192.168.0.1
DNS2=8.8.8.8
DOMAIN=NAME_OF_MY_DOMAIN
WPA_ALLOW_WPA=yes
WPA_ALLOW_WPA2=yes
MAC_ADDRESS_RANDOMIZATION=default
IPADDR=192.168.0.201
PREFIX=24
GATEWAY=192.168.0.1
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

tunk
Posts: 1206
Joined: 2017/02/22 15:08:17

Re: Is it possible to set a static IP on laptop wireless port?

Post by tunk » 2017/06/17 21:42:35

Also, I'd like to know if enabling DHCP and letting the router give the same IP everytime to this laptop, is the same as setting a static IP?
Not really, but I guess you could cheat and set the lease time on the DHCP server (router?) to a few weeks.
I don't know if this will have any unwanted side effects.

zetret
Posts: 6
Joined: 2017/06/17 16:36:07

Re: Is it possible to set a static IP on laptop wireless port?

Post by zetret » 2017/06/17 22:35:46

I am sorry to say none of the answers even attempted to help.

After some trial and error, the following worked to get the authentication to my Wi-Fi router; Maybe it'll help someone in the future.

Code: Select all

wpa_supplicant -B -D wext -i wlp4s0 -c /etc/wpa_supplicant/wpa_supplicant.conf
Then, I had to do this to access the Internet;

Code: Select all

dhclient wlp4s0
(Please search the Internet for what to have in the wpa_supplicant.conf file)

Then go to

Code: Select all

/etc/rc.d/rc.local
Add this to auto-run at boot time and it worked;

Code: Select all

wpa_supplicant -B -D wext -i wlp4s0 -c /etc/wpa_supplicant/wpa_supplicant.conf;dhclient wlp4s0

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Is it possible to set a static IP on laptop wireless port?

Post by jlehtone » 2017/06/18 20:02:26

Network configuration and how it is implemented are somewhat separate things.

You connect wirelessly to an access point (AP). The AP is in some subnet. The subnet has some member that acts as router between that subnet and other subnet(s). If the members of the subnet have resolvable names, then there is a name resolver (DNS) somewhere. For your device to be member of the subnet, it has to have a valid subnet address, and know the router's and DNS's addresses.

Your device could have same address on every connection or it would use a free address from a pool of addresses. DHCP prefers to give the same IP from pool if possible, but there is no guarantee of same IP every time. Even when the IP is not same every time, the name can be if DNS is dynamically updated. You seem to want to get same, known IP address predictably.


There are more than one way to set an IP address for an interface. The top two are DHCP and manual. While the manual configuration does set the exact values that you want, you need to know the correct values and the subnet cannot be adjusted without also updating your manual configuration. Manual configuration does not "register" anything with anyone.

It is totally possible to configure a DHCP server to hand out specific IP for a specific client (usually by MAC address). Even the cheap consumer-grade "routers" tend to allow that in their mind-bogglingly limited web interfaces. I know organisations where every device gets "static" address from DHCP and nobody can get a "random" address.

I would use the DHCP. If the current DHCP server of the subnet has no necessary configuration options, then replace it with something sane.


PS. I see MAC_ADDRESS_RANDOMIZATION in config. Most of that config was created by NetworkManager, was it not? I don't know wireless, nor whether network.service uses that option. It is about: https://blogs.gnome.org/thaller/2016/08 ... ger-1-4-0/

Post Reply