I'm using xubuntu and I have set my /etc/network/interfaces
file like this:
auto lo
iface lo inet loopback
auto enp0s3
iface enp0s3 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8
When I reboot the system and run ifconfig
command, everything is ok:
enp0s3: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255
[...]
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
[...]
But, when I update the /etc/network/interfaces
file changing the IP to 192.168.1.20 and do this:
sudo ifdown -a && sudo ifup -a
The ifconfig
command show me the same IP (192.168.1.10) as before. Moreover, I can do a ping
to both addresses and they answer.
I can't see the expected IP (192.168.1.20) until I reboot the system. Even a sudo /etc/init.d/networking restart
execution can't solve that...
What am I doing wrong?
Thanks!
PS: I have disabled the GUI Network Manager to avoid conflicts.
EDIT: I have used sudo ifdown enp0s3 && sudo ifup -v enp0s3
and this is the result:
Configuring interface enp0s3=enp0s3 (inet)
/bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/wireless-tools
run-parts: executing /etc/network/if-pre-up.d/wpasupplicant
/bin/ip addr add 192.168.1.20/255.255.255.0 broadcast 192.168.1.255 dev enp0s3 label enp0s3
/bin/ip link set dev enp0s3 up
/bin/ip route add default via 192.168.1.1 dev enp0s3 onlink
/bin/run-parts --exit-on-error --verbose /etc/network/if-up.d
run-parts: executing /etc/network/if-up.d/avahi-autoipd
run-parts: executing /etc/network/if-up.d/avahi-daemon
run-parts: executing /etc/network/if-up.d/wpasupplicant
EDIT2:
Every time I edit the /etc/network/interfaces
, change the static IP address and restart the network, it's like if I were adding new IPs to my machine. I can ping to each one I write!!
ping
;192.168.1.20
) in/etc/network/interfaces
;service networking restart
;ifdown enp0s3 && ifup enp0s3
if you don't want to restart.