Posted: . At: 10:03 AM. This was 2 years ago. Post ID: 16398
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.



Sponsored



Using netplan to set up IP Networking on Ubuntu.


I recently set up my server again and I wanted to use it on a network. I removed Network Manager from the system as it was overwriting the /etc/resolv.conf file. Then I set up netplan instead. This allows me to setup a DHCP configuration and get my machine working on the network again.

I still had the /etc/netplan/01-network-manager-all.yaml file on my system, so I edited this to add the proper settings to use DHCP for IPv4 and IPv6.

jason@jason-Lenovo-H50-55:/etc/netplan$ sudo mcedit /etc/netplan/01-network-manager-all.yaml

These are the settings I am using to run networking on Ubuntu using netplan.

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s25:
      dhcp4: true
      dhcp6: true

And these settings in the /etc/resolv.conf. I deleted the existing symlink to this file and recreated it with the custom IP addresses. This enables Internet access.

nameserver 192.168.1.1
nameserver 8.8.8.8
nameserver 8.8.4.4

And now I have an IP address and my server works on the Internet.

jason@jason-Lenovo-H50-55:/etc/netplan$ ip a | awk "NR==9 || NR==11 {print $1}"
    inet 192.168.1.2/24 brd 192.168.1.255 scope global dynamic enp0s25
    inet6 fdc8:1451:5fa9:4700:d250:99ff:fe0d:ab0f/64 scope global dynamic mngtmpaddr noprefixroute

Make sure you use YAML formatting for the edits. Use spaces instead of tabs.

Use this command to apply your edits to the netplan configuration.

jason@jason-Lenovo-H50-55:/etc/netplan$ sudo netplan apply

But why does this happen?

jason@jason-Lenovo-H50-55:/etc/netplan$ ping google.com
ping: connect: Network is unreachable
jason@jason-Lenovo-H50-55:/etc/netplan$ ping yahoo.com
PING yahoo.com (98.137.11.164) 56(84) bytes of data.
64 bytes from media-router-fp73.prod.media.vip.gq1.yahoo.com (98.137.11.164): icmp_seq=1 ttl=50 time=193 ms
64 bytes from media-router-fp73.prod.media.vip.gq1.yahoo.com (98.137.11.164): icmp_seq=2 ttl=50 time=193 ms
64 bytes from media-router-fp73.prod.media.vip.gq1.yahoo.com (98.137.11.164): icmp_seq=3 ttl=50 time=193 ms
64 bytes from media-router-fp73.prod.media.vip.gq1.yahoo.com (98.137.11.164): icmp_seq=4 ttl=50 time=192 ms
^C
--- yahoo.com ping statistics ---
5 packets transmitted, 4 received, 20% packet loss, time 4005ms
rtt min/avg/max/mdev = 192.329/192.783/193.072/0.275 ms

This is strange. But yes, netplan really does work very well. Even though Systemd is taking over the whole Linux ecosystem, it still works very well.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.