I am operating under root, the normal user needs sudo permission
UFW Disable off
UFW Enable Open
This file can be closed IPv6
/etc/default/ufw
View Rules
UFW status
Example of adding a rule:
ufw default allow outgoing ufw default deny incoming ufw default deny 关闭所有外部访问端口 ufw allow ssh ufw allow 22 ufw allow 80/tcp ufw allow http/tcp ufw allow 1725/udp ufw allow 25:29/udp ufw allow from 123.45.67.89 ufw allow from 123.45.67.89/24 ufw allow from 123.45.67.89 to any port 22 proto tcp sudo ufw allow from 192.168.1.1 允许此IP访问所有的本机端口 sudo ufw deny proto tcp from 10.0.0.0/8 to 192.168.0.1 port 22 要拒绝所有的TCP流量从10.0.0.0/8 到192.168.0.1地址的22端口
========================================
Log directory: Vim/var/log/ufw.log
sudo ufw logging on boot log
sudo ufw logging off log
sudo ufw logging Low|medium|high
- Sep 15:08:14 The preceding values list the date, time, and host name of your server. The remaining important information includes:
- [UFW BLOCK]: This is where the description of the recording event begins. In this example, it means that the connection is blocked.
- In: If it contains a value, then the event is an incoming event
- Out: If it contains a value, then the event is an outgoing event
- Mac: Combination of destination and source MAC address
- SRC: IP of package source
- DST: IP for package destination
- LEN: Packet length
- TTL: Packet ttl, or time to live. Before the destination is found, it jumps between the routers until it expires.
- PROTO: Protocol for packets
- SPT: The source port of the package
- DPT: Destination port of the package
- WINDOW: The size of the packets that the sender can receive
- SYN URGP: Indicates whether a three-time handshake is required. 0 indicates no need.
========================================
Three to see the operating system port monitoring
Netstat-an | grep LISTEN | Grep-v ^unix "
Netstat-ntulp
Lsof-i-n-p
Ubuntu Simple firewall UFW configuration record