Have following configuration in /etc/network/interfaces

auto enp1s0
iface enp1s0 inet static
  mtu 1500

After boot internet works.

Suppose one wants to change his address from to

ifconfig enp1s0 netmask

But now internet does not work! Even if reset ip back to

ifconfig enp1s0 netmask

it does not connect to the internet, only after reboot it works again with specified in /etc/network/interfaces static address. I read man pages, tried various commands with ip, route, ifconfig - does not seem to help.

Could you please show how to solve the problem?


ifconfig only set IP address. To have internet access you need to specify a default gateway and DNS namesever. Use following commands:

ifconfig enp1s0 netmask
route add  default gw
echo "dns-nameserver" > cat /etc/resolv.conf
  • Interesting, I found that after every execution of ifconfig(setting netmask and static IP address) removes default gateway from routing tables, so one needs to reissue "route ... gw IP address"? What that happens? Very unusual for me. – Bulat M. Nov 23 '16 at 14:40
  • 1
    @BulatM. : Because you have configured enp1s0 to get IP address, subnet mask, default gateway IP address and DNS server IP address from DHCP Server. Issuing ifconfig command says to your Linux box to not using DHCP configuration, so default gateway record is removed from the routing table. – SuB Nov 23 '16 at 18:55
  • @SuB, I did not said that I used DHCP, indeed I was trying to get run with static configuration in that case. Could you point to man pages or another source where it stated that after ifconfig execution default route(gateway) gets removed from kernel's routing table? – Bulat M. Nov 23 '16 at 19:43
  • 1
    @BulatM. Sorry. DHCP/Static configuration have the same result when you set IP address using ifconfig. I haven't any resource says about this situation. – SuB Nov 23 '16 at 20:01
  • @SuB, could you please also explain the differences between purposes of NetworkManager(.service) and networking(.service). It is not clear why one needs the latter. – Bulat M. Nov 25 '16 at 17:37

After you edited the network configurations, run following command:

sudo systemctl restart networking
  • Could you please explain what is the difference between NetworkManager.service and networking service. First is daemon to make network configuration user-friendly but why do one need to use networking.service(and restart it)? – Bulat M. Nov 23 '16 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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