Go to the network directory
>cd /etc/netplan
>sudo vi 50-cloud-init.yaml
> cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
enp0s3:
dhcp4: true
enp0s8:
dhcp4: no
addresses: [192.168.56.104/24]
gateway4: 192.168.56.0
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
version: 2
>sudo netplan apply
Check Network
> ifconfig
enp0s3: flags=4163
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::a00:27ff:fec7:ba2 prefixlen 64 scopeid 0x20
ether 08:00:27:c7:0b:a2 txqueuelen 1000 (Ethernet)
RX packets 28 bytes 6966 (6.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 39 bytes 4677 (4.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s8: flags=4163
inet 192.168.56.104 netmask 255.255.255.0 broadcast 192.168.56.255
inet6 fe80::a00:27ff:febc:6cd8 prefixlen 64 scopeid 0x20
ether 08:00:27:bc:6c:d8 txqueuelen 1000 (Ethernet)
RX packets 109 bytes 13904 (13.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 79 bytes 11730 (11.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 88 bytes 6700 (6.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 88 bytes 6700 (6.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Some Basic Commands
Check the status of system
> systemctl status
List all the units
> systemctl list-units
Check the failed units
> systemctl --failed
The files is under
/usr/lib/systemd/system
/etc/systemd/system
Check all the services
> systemctl list-unit-files
Install the service on newly machine
>sudo apt-get install keepalived
Check version
>keepalived -version
Keepalived v2.0.10 (11/12,2018)
Copyright(C) 2001-2018 Alexandre Cassen,
Built with kernel headers for Linux 4.19.5
Running on Linux 5.0.0-20-generic #21-Ubuntu SMP Mon Jun 24 09:32:09 UTC 2019
Check the Service
> systemctl list-unit-files | grep keepalived
keepalived.service enabled
On my ubuntu-master, when I checked
> systemctl list-unit-files | grep keepalived
snap-keepalived-448.mount enabled
keepalived.service masked
snap.keepalived.daemon.service enabled
> systemctl list-unit-files | grep keepalived
snap-keepalived-448.mount enabled
keepalived.service masked
snap.keepalived.daemon.service enabled
Check the status on the second machine
> ps -ef | grep keepalived
root 940 1 0 20:10 ? 00:00:00 /snap/keepalived/448/usr/sbin/keepalived-500
root 941 940 0 20:10 ? 00:00:00 /snap/keepalived/448/usr/sbin/keepalived-500
Disable others
> systemctl disable snap-keepalived-448.mount
> systemctl disable snap.keepalived.daemon.service
Unmask my service
> sudo systemctl unmask keepalived.service
Enable the service
> systemctl enable keepalived.service
Reinstall the keepalived, it is active now
> sudo apt-get install keepalived
> systemctl list-unit-files | grep keepalived
snap-keepalived-448.mount disabled
keepalived.service enabled
snap.keepalived.daemon.service disabled
References:
https://www.cnblogs.com/lxjshuju/p/7183689.html
http://www.jinbuguo.com/systemd/systemctl.html
https://chubuntu.com/questions/11949/why-are-some-systemd-services-in-the-masked-state.html
http://www.kbase101.com/question/15548.html