MagiTrickle/README.md

78 lines
2.5 KiB
Markdown
Raw Normal View History

2024-08-24 01:29:29 +03:00
# kvas2-go
Better implementation of [KVAS](https://github.com/qzeleza/kvas)
2024-08-26 19:10:40 +03:00
Realized features:
- [x] DNS Proxy (UDP)
- [ ] DNS Proxy (TCP)
2024-09-05 03:59:03 +03:00
- [x] Records memory
- [x] IPTables rules for rebind DNS server port [1]
2024-08-30 04:40:46 +03:00
- [X] IPSet integration
2024-09-05 03:59:03 +03:00
- [X] IP integration
2024-08-24 01:29:29 +03:00
- [ ] IPTables rules to IPSet [2]
2024-09-05 03:59:03 +03:00
- [ ] Rule composer (CRUD)
- [ ] GORM integration
- [X] Listing of interfaces
2024-08-24 01:29:29 +03:00
- [ ] HTTP API
- [ ] HTTP GUI
2024-09-05 03:59:03 +03:00
- [ ] CLI
- [ ] (Keenetic) Support for custom interfaces [3]
2024-09-05 03:59:03 +03:00
- [ ] It is not a concept now... REFACTORING TIME!!!
- [ ] (Keenetic) Getting readable names of interfaces from Keenetic NDMS
2024-08-24 01:29:29 +03:00
- [ ] HTTP Auth
[1] Example
```bash
2024-08-24 20:12:45 +03:00
KVAS2_NAME=KVAS2
2024-08-24 01:29:29 +03:00
KVAS2_DNS_PORT=7548
2024-08-24 20:12:45 +03:00
# Создание правил
2024-08-24 20:23:30 +03:00
iptables -t nat -N ${KVAS2_NAME}_DNSOVERRIDE_PREROUTING
iptables -t nat -A ${KVAS2_NAME}_DNSOVERRIDE_PREROUTING -p udp --dport 53 -j REDIRECT --to-port ${KVAS2_DNS_PORT}
2024-08-24 20:12:45 +03:00
# Применение правил
2024-08-24 20:23:30 +03:00
iptables -t nat -I PREROUTING 1 -j ${KVAS2_NAME}_DNSOVERRIDE_PREROUTING
2024-08-24 20:12:45 +03:00
# Удаление правил
2024-08-24 20:23:30 +03:00
iptables -t nat -D PREROUTING -j ${KVAS2_NAME}_DNSOVERRIDE_PREROUTING
2024-08-24 20:30:23 +03:00
iptables -t nat -F ${KVAS2_NAME}_DNSOVERRIDE_PREROUTING
iptables -t nat -X ${KVAS2_NAME}_DNSOVERRIDE_PREROUTING
2024-08-24 01:29:29 +03:00
```
[2] Example
```bash
2024-08-24 20:17:19 +03:00
KVAS2_NAME=KVAS2
2024-08-24 01:29:29 +03:00
IPSET_TABLE=kvas2
MARK=1
TABLE=100
INTERFACE=ovpn_br0
2024-08-24 20:17:19 +03:00
# Создание правил
2024-08-24 20:23:30 +03:00
iptables -t mangle -N ${KVAS2_NAME}_ROUTING_PREROUTING
iptables -t nat -N ${KVAS2_NAME}_ROUTING_POSTROUTING
iptables -t mangle -A ${KVAS2_NAME}_ROUTING_PREROUTING -m set --match-set ${IPSET_TABLE} dst -j MARK --set-mark ${MARK}
iptables -t nat -A ${KVAS2_NAME}_ROUTING_POSTROUTING -o ${INTERFACE} -j MASQUERADE
2024-08-24 20:17:19 +03:00
# Применение правил
ip rule add fwmark ${MARK} table ${TABLE}
ip route add default dev ${INTERFACE} table ${TABLE}
2024-08-24 20:23:30 +03:00
iptables -t mangle -A PREROUTING -j ${KVAS2_NAME}_ROUTING_PREROUTING
iptables -t nat -A POSTROUTING -j ${KVAS2_NAME}_ROUTING_POSTROUTING
2024-08-24 20:17:19 +03:00
# Удаление правил
ip rule del fwmark ${MARK} table ${TABLE}
ip route del default dev ${INTERFACE} table ${TABLE}
2024-08-24 20:23:30 +03:00
iptables -t mangle -D PREROUTING -j ${KVAS2_NAME}_ROUTING_PREROUTING
2024-08-24 20:30:23 +03:00
iptables -t mangle -F ${KVAS2_NAME}_ROUTING_PREROUTING
iptables -t mangle -X ${KVAS2_NAME}_ROUTING_PREROUTING
2024-08-24 20:23:30 +03:00
iptables -t nat -D POSTROUTING -j ${KVAS2_NAME}_ROUTING_POSTROUTING
2024-08-24 20:30:23 +03:00
iptables -t nat -F ${KVAS2_NAME}_ROUTING_POSTROUTING
iptables -t nat -X ${KVAS2_NAME}_ROUTING_POSTROUTING
2024-08-24 01:29:29 +03:00
```
[3] Example
```bash
INTERFACE=ovpn_br0
iptables -A _NDM_SL_FORWARD -o ${INTERFACE} -m state --state NEW -j _NDM_SL_PROTECT
```