防火墙 UFW
安装防火墙
支持 IPv6
sudo vim /etc/default/ufw
默认策略
1 2
| sudo ufw default deny incoming sudo ufw default allow outgoing
|
开放端口
启用 UFW
1 2 3 4 5
| sudo ufw enable
sudo ufw disable
sudo ufw reset
|
子网访问
1 2 3
| sudo ufw allow from 192.168.249.0/24
sudo ufw allow from 192.168.249.0/24 to any port 22
|
删除规则
1 2 3 4 5 6
| sudo ufw status numbered sudo ufw status verbose
sudo ufw delete number sudo ufw delete allow http sudo ufw delete allow 80
|
systemctl 服务
开机没有登录时,即可运行的程序
service 文件位置
service 文件内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| [Unit] Description=desc After=network.target
[Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginc -c /usr/local/nginx/conf/nginx.conf ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s quit # 为服务分配独立的空间 PrivateTmp=true
[Install] WantedBy=multi-user.target
|
查看已启动的服务
1
| systemctl list-units --type=service
|
No protocol specified Unable to init server: 无法连接:拒绝连接
当前用户执行命令
user 不在 sudoers 文件中。此事将被报告。
1 2 3 4 5 6 7
| sudo vim /etc/sudoers
... # User privilege specification root ALL=(ALL:ALL) ALL user ALL=(ALL:ALL) ALL ...
|