1

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

Ommadawn
  • 383
  • 1
    try systemctl restart ifup@enp0s3 – pLumo Jan 11 '19 at 13:03
  • 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 '19 at 16:10
  • @chili555: xubuntu 18.04 LTS. I have done what you said and I have got the results you can see at my edited post (didn't work). Thanks! – Ommadawn Jan 11 '19 at 16:19
  • 1
    In the absence of Network Manager, in 18.04, networking is handled by netplan, not /etc/network/interfaces. Please see: https://askubuntu.com/questions/976464/why-is-the-network-configuration-i-set-in-etc-network-interfaces-ignored-on-ubu/976497#976497 – chili555 Jan 11 '19 at 17:19
  • @chili555: I asked that before and someone answered me saying there was no problem... :( https://askubuntu.com/questions/1108217/is-etc-network-interfaces-still-working-with-newer-ubuntu – Ommadawn Jan 11 '19 at 17:30
  • 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. https://askubuntu.com/questions/1031709/ubuntu-18-04-switch-back-to-etc-network-interfaces/1031737#1031737 Be sure to read all the following comments. Isn't it just much simpler to adapt to netplan? – chili555 Jan 11 '19 at 17:37
  • @chili555, yes it could be, but I'm doing it with academic purposes, so it's so annoying to do several versions of how to configure a network. Thanks! – Ommadawn Jan 11 '19 at 18:00

1 Answers1

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.
  • 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 '19 at 15:30