Content #
EnvironmentFile=-/etc/default/ssh
The minus sign (-) in front of the path to the file tells systemd that if the file doesn’t exist, don’t worry about it and start the service anyway.
没有[Install]意味着服务为static,将无法enable。
Default location: /lib/systemd/system,如果要覆盖默认文件,可将自己的文件放在:/etc/systemd/system 目录下。 filename extension describes which type of unit it is.
systemctl list-unit-files
展示系统中所有已经安装的unit file。
...systemd unit files Service Units(systemd) unclean kill signal Masking a service Create a new container service with podman from user account systemd timers Changing the default locale Setting time and timezone parameters Shutdown and Reboot(systemd) The four default slices 需要执行daemon-reload的情形
自定义服务应当放在/etc/systemd/system目录下,放在/lib/systemd/system下的服务文件会被系统更新时覆盖。
user@.service文件中的@符号表示这是service template,配置文件中的"%i"会被替换为@后的参数。
systemd starts loading the bootup targets in the following order:
Within each target, processes start up in parallel.
systemd生成的unit文件位置:
/run/systemd/generator
hostnamectl
sudo hostnamectl set-hostname "Donnie's Computer"
man systemd-system.conf
apropos systemd
man -k systemd
man systemd.unit
man systemd.directives #配置指令文档
man systemd.exec #Execution environment configuration
systemctl -h # quick reference
systemctl --state=help #see a list of all of the different states
systemctl show #show running configuration
systemctl show --property=DefaultLimitSIGPENDING
cook:systemd cook:journalctl sub:cgroups systemd-boot
...Initialize PKI
./easyrsa init-pki
Building the CA
./easyrsa build-ca
check CA
openssl x509 -in /path/to/ca.crt -text -noout
Generate an empty CRL(Certificate Revocation List)
./easyrsa gen-crl
verify the CRL
openssl crl -noout -text -in /path/to/crl.pem
Build server certificate Prevents one of your clent certificates from being used as a server in a Man-In-The_middle attack.
...The client-side network 192.168.4.0/24(client: 10.200.0.2) needs to be routed over the VPN tunnel to the server(10.200.0.1).
openvpn --ifconfig 10.200.0.1 10.200.0.2 \
--dev tun --secret secret.key 0 \
--route 192.168.4.0 255.255.255.0 \
--daemon --log /var/log/movpn-server.log
a route statement was added to tell OpenVPN that the network 192.168.4.0/24 is founded at the other end of the tunnel. Instead of using route statement, we can also use iproute2 command:
...Start the first endpoint in the listening mode
openvpn --ifconfig 10.200.0.1 10.200.0.2 --dev tun
launch the OpenVPN client
openvpn --ifconfig 10.200.0.2 10.200.0.1 --dev tun --remote first.endpoint
The default protocol that OpenVPN uses is UDP, if the TCP protocol is required:
Start the first endpoint in the listening mode
openvpn --ifconfig 10.200.0.1 10.200.0.2 --dev tun --proto tcp-server
launch the OpenVPN client
...Using a TCP-based application over a TCP-based VPN can result in double performance loss, especially if the underlying network connection is bad. In that case, a re-transmittance of lost packets is done for packets lost both inside and outside the tunnel, leading to a double performace hit. When choosing between UDP or TCP transport, the general rule of thumb is as follows: If UDP(mode udp) works for you, then use it; if not, then try TCP(mode tcp-server and mode tcp-client).
...以下是在Linux下使用iptables和cgroup为Firefox进程及其子进程打上标记的步骤:
sudo apt install cgroup-tools
sudo cgcreate -g misc:firefox_cgroup
pgrep firefox
sudo cgclassify -g misc:firefox_cgroup firefox_pid
sudo iptables -t mangle -A OUTPUT -m cgroup --path '/firefox_cgroup' -j MARK --set-mark 0x1
cgroup2中已经没有net_cls及classid,应该使用path参数。
现在,所有由Firefox进程及其子进程生成的网络包都将被标记为 `0x1`。