[Unit]
Description=Мой скрипт
[Service]
ExecStart=/путь/к/вашему/скрипту.sh
[Unit]
Description=Таймер для моего скрипта
[Timer]
OnCalendar=*-*-* 00:00:00
RandomizedDelaySec=3600
[Install]
WantedBy=timers.target
sudo systemctl daemon-reload
sudo systemctl enable myscript.timer
sudo systemctl start myscript.timer
For lease expires -19418 day left
grep -iE 'expir.*date|expir.*on'
expdate=$(whois "$domain" | grep -iE 'expir.*date|expir.*on|expires|free-date' | head -1 | grep -oE '[^ ]+$')
@def $WAN_IP1 = 1.1.1.1; # На этом разрешаем входящие
@def $WAN_IP2 = 1.1.1.2; # Через этот выходим
@def $DEV_WAN = ens1s0;
@def $VPN_NETS = (10.10.10.0/24 10.10.20.0/24); # Сети VPN клиентов
domain (ip ip6) {
table filter {
chain INPUT {
policy DROP; # Политика поумолчанию, если нет разрешающего правила значит запрещено
# connection tracking
mod state state INVALID LOG log-prefix '[FERM] INVALID INPUT DROP: ';
mod state state INVALID DROP;
mod state state (ESTABLISHED RELATED) ACCEPT;
# allow local packet
interface lo ACCEPT;
# respond to ping
#proto icmp ACCEPT;
daddr $WAN_IP1 {
# respond to ping
proto icmp ACCEPT;
# allow SSH connections
proto tcp dport 22 ACCEPT;
# allow WEB connections
proto tcp dport (http https) ACCEPT;
# allow VPN wireguard connections
proto udp dport 51820 ACCEPT;
}
}
chain OUTPUT {
policy ACCEPT;
# connection tracking
#mod state state INVALID DROP;
mod state state (ESTABLISHED RELATED) ACCEPT;
}
chain FORWARD {
policy DROP;
# connection tracking
mod state state INVALID DROP;
mod state state (ESTABLISHED RELATED) ACCEPT;
saddr $VPN_NETS ACCEPT; # Разрешаем трафику от VPN клиентов проходить в любом направлении
}
}
table nat {
chain POSTROUTING {
saddr $VPN_NETS outerface $DEV_WAN SNAT to $WAN_IP2; # Маскируем-натим исходящий трафик от VPN клиентов вторым IP
}
}
}
@include ferm.d/;
server:
verbosity: 1
interface: 0.0.0.0
do-ip4: yes
access-control: 0.0.0.0/0 allow
chroot: ""
hide-version: yes
key-cache-size: 0
cache-max-ttl: 0
private-address: 10.0.0.0/8
private-address: 172.16.0.0/12
private-address: 192.168.0.0/16
private-domain: "example.com"
local-zone: "10.in-addr.arpa." nodefault
local-zone: "16.172.in-addr.arpa." nodefault
local-zone: "168.192.in-addr.arpa." nodefault
local-data: "ntp.example.com IN A 10.10.10.10"
stub-zone:
name: "habr.com"
stub-addr: 8.8.8.8
stub-addr: 8.8.4.4
stub-zone:
name: "10.in-addr.arpa"
stub-addr: 10.10.10.5
forward-zone:
name: "ocn.net.cn"
forward-host: ns02.example.com
forward-zone:
name: "."
forward-addr: 1.1.1.1
forward-addr: 8.8.8.8
echo "100 vpn" >> /etc/iproute2/rt_tables
echo 1 > /proc/sys/net/ipv4/ip_forward
export VPN_NET="10.10.10.0/24"
export VPN_IFACE="tun1"
export VPN_OFACE="tun2s1"
iptables -t nat -A PREROUTING -s $VPN_NET -i $VPN_IFACE -m conntrack --ctstate RELATED,ESTABLISHED -j CONNMARK --restore-mark --nfmask 0xffffffff --ctmask 0xffffffff
iptables -t nat -A PREROUTING -s $VPN_NET -j MARK --set-xmark 0x1/0xffffffff
iptables -t nat -A PREROUTING -s $VPN_NET -j CONNMARK --save-mark --nfmask 0xffffffff --ctmask 0xffffffff
iptables -t nat -A POSTROUTING -s $VPN_NET -o $VPN_OFACE -j MASQUERADE
ip rule add fwmark 1 table vpn
ip route add default dev $VPN_OFACE table vpn
ip route flush cache