0

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!!

  • 1
    try systemctl restart ifup@enp0s3 – RoVo Jan 11 at 13:03
  • Doesn't work :( Thanks! – Ommadawn Jan 11 at 13:08
  • 1
    Which version of Ubuntu are you using? Is the result any better if you: sudo ifdown enp0s3 && sudo ifup -v enp0s3? – chili555 Jan 11 at 16:10
  • 1
    In the absence of Network Manager, in 18.04, networking is handled by netplan, not /etc/network/interfaces. Please see: askubuntu.com/questions/976464/… – chili555 Jan 11 at 17:19
  • 1
    Not to be too blunt, but it appears that the answer is incorrect. You can use interfaces, but it takes much more than ifup/down. askubuntu.com/questions/1031709/… Be sure to read all the following comments. Isn't it just much simpler to adapt to netplan? – chili555 Jan 11 at 17:37
1
  1. Check the IP with ping;
  2. Then check IP, it will assign dynamically into LAN or not, If IP assign to another machine in your LAN then it will come 'IP conflict';
  3. If not, add static IP (192.168.1.20) in /etc/network/interfaces;
  4. Then restart networking with the command service networking restart;
  5. then run command ifdown enp0s3 && ifup enp0s3 if you don't want to restart.
  • 1) Both addresses answer to ping. 2) No conflict, it's an isolated virtual machine with its on LAN. 3) Added. 4) I have run the command and nothing have changed. If I restart the computer, it works, but I don't want to restart! :( THanks for your help! – Ommadawn Jan 11 at 15:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.