汇总.note

noteId: 9B6A4B0537E74E199A06F43435607BAB · 原始路径:/ALL/世赛题目(练习) - 笔记/集训笔记/贵州-贵阳/A模块/汇总.note · 图片:5 · 附件待处理:0

 
· 初始化:
 
1、安装 测试工具:
apt install -y curl wget lynx dnsutils ftp lftp nfs-common smbclient ssh telnet traceroute ntpdate lsof nmap bsd-mailx sudo vim bash-completion net-tools man dbus
 
 
2、设置主机名、时区:
hostnamectl set-hostname xxxxx
timedatectl set-timezone Asia/Shanghai
 
 
3、设置 keymap 为: us:
localectl set-x11-keymap us
 
 
一、路由:
 
1、开启路由功能
 
2、安装 frr ,启用 BGP,在 ISP 上通告路由条目
 
 
二、iptables、nftables 防火墙:
 
1、创建表和链:
iptables -A INPUT -s 1.1.1.1 -j ACCEPT

iptables -A OUTPUT -s 1.1.1.1 -j ACCEPT

iptables -A FORWARD

iptables -t nat -A PREROUTING -s 1.1.1.1 -j DNAT --to 2.2.2.2

iptables -t nat -A POSTROUTING -s 1.1.1.1 -j SNAT --to 2.2.2.2

iptables -F

iptables -t nat -F
 
 
2、设置默认策略
 
 
3、MANAGE 配置 静态 NAT:
NAT 会自动将数据包的源地址转换回去,所以这里只需要ISP的一条路由即可
# ROUTING1:
nft add rule ip nat POSTROUTING ip saddr 192.168.100.110 snat 213.110.3.10
 
# ISP:
echo "up route add -net 213.110.3.10 netmask 255.255.255.255 gw 213.110.3.1" >> /etc/network/interfaces
systemctl restart networking
 
 
4、为 GZ2024.GZ 域所有主机配置 PAT:
# 这条需要写在 将 MANAGE 那条 静态 NAT 之后
nft add rule ip nat POSTROUTING ip saddr 192.168.100.0/24 snat 213.110.3.1
 
 
5、为服务配置端口转发:
nft add rule ip nat PREROUTING ip daddr 213.110.3.10 tcp dport 22 dnat 192.168.100.110    //SSH 流量
nft add rule ip nat PREROUTING ip daddr 213.110.3.10 udp dport 123 dnat 192.168.100.110    //NTP端口
nft add rule ip nat PREROUTING ip daddr 213.110.3.10 tcp dport 53 dnat 192.168.100.110    //DNS端口(TCP)
nft add rule ip nat PREROUTING ip daddr 213.110.3.10 udp dport 53 dnat 192.168.100.110    //DNS端口(UDP)
nft add rule ip nat PREROUTING ip daddr 213.110.3.10 tcp dport 80 dnat 192.168.100.110    //Web端口(80)
nft add rule ip nat PREROUTING ip daddr 213.110.3.10 tcp dport 443 dnat 192.168.100.110    //Web端口(443)
nft add rule ip nat PREROUTING ip daddr 213.110.3.10 tcp dport 389 dnat 192.168.100.110    //OpenLDAP端口
nft add rule ip nat PREROUTING ip daddr 213.110.3.10 udp dport 389 dnat 192.168.100.110    //OpenLDAP端口
nft add rule ip nat PREROUTING ip daddr 213.110.3.10 udp dport 1812 dnat 192.168.100.110    //RADIUS端口
nft add rule ip nat PREROUTING ip daddr 213.110.3.10 udp dport 1813 dnat 192.168.100.110    //RADIUS端口
 
nft add rule ip nat PREROUTING ip daddr 213.110.3.10 dnat 192.168.100.110    //防止服务无法进行通信,可以添加一条转发所有
 
 
6、
 
 
 
三、NTP:
 
1、INET 配置 chrony:
apt install -y chrony
vim /etc/chrony/chrony.conf
# 先注释掉官方地址
 
2、MANAGE 配置 chrony:
apt install -y chrony systemd-timesyncd
# 先配置 chrony作为服务器
vim /etc/chrony/chrony.conf
# 先注释掉官方地址池
 
 
3、客户端 使用 timedatectl 显示时间同步状态:
apt install -y systemd-timesyncd
vim /etc/systemd/timesyncd.conf
systemctl restart systemd-timesyncd