1

I tried to change my private IP address with the following commands:

sudo ifconfig wlp3s0 down
sudo ifconfig wlp3s0 192.168.1.12
sudo ifconfig wlp3s0 up

They just work fine becouse the IP changes but then the newtork become unavailable. The issue remains if I change again the IP address to the initial one. What's wrong with that? How can I solve it?

dann32
  • 11
  • See also https://unix.stackexchange.com/questions/289710/changing-ip-address-in-terminal . – pbhj May 04 '18 at 19:24
  • This is also pertinent to IP address issues - https://unix.stackexchange.com/questions/57710/static-ip-address-shifting-to-192-168-1-251?rq=1 – pbhj May 04 '18 at 19:27

1 Answers1

6

You might need to specify the subnet mask to use. The command above is likely assuming that the subnet mask is 255.255.255.255, which is for a point-to-point network.

The following might work:

sudo ifconfig wlp3s0 down
sudo ifconfig wlp3s0 192.168.1.12/255.255.255.0
sudo ifconfig wlp3s0 up

(Also check to see that a default route is present, using the ip route command.)

On a side note, ifconfig is deprecated and is replaced by the ip command. The equivalent steps are:

sudo ip link set dev wlp3s0 down
sudo ip addr add 192.168.1.12/24 dev wlp3s0
sudo ip link set dev wlp3s0 up
saiarcot895
  • 1,371