- Add missing files.

This commit is contained in:
Arnaud G. GIBERT 2025-06-05 11:22:52 +02:00
parent 77a94f7ad4
commit 3086205f02
3 changed files with 106 additions and 0 deletions

View File

@ -12,6 +12,7 @@ The following topics are tageted:
- VPN,
- Proxy,
- Port forwarding,
- Dynamic DNS.
This release support IPTables and OpenVPN.

19
usr/local/sbin/ip_host_update Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
host=$1
zone=$2
ip=$3
ttl=$4
date="$(date --rfc-3339 seconds)"
(
echo "prereq yxrrset ${host}.${zone}. A"
echo "update delete ${host}.${zone}. A"
echo "update add ${host}.${zone}. ${ttl} A ${ip}"
echo "update delete ${host}.${zone}. TXT"
echo "update add ${host}.${zone}. ${ttl} TXT ${date}"
echo ""
) | nsupdate

86
usr/local/sbin/ns-launch Executable file
View File

@ -0,0 +1,86 @@
#!/bin/bash
[ -e /etc/sysconfig/rx3-net ] && . /etc/sysconfig/rx3-net
id=$1
table=$2
shift
shift
cmd="$(printf " %q" "$@")"
prefix=10.2
eth_dev="v-eth${id}"
peer_dev="v-peer${id}"
peer_addr="${prefix}.${id}.1"
eth_addr="${prefix}.${id}.254"
eth_mask="255.255.255.0"
peer_mask="${eth_mask}"
ns_name="darkstar${id}"
export PATH=$PATH:/usr/local/sbin:/usr/local/bin
# Create Net-NS
ip netns del ${ns_name} 2>/dev/null
sleep 3
ip netns add ${ns_name}
# Create v-eth / v-peer
ip link del ${eth_dev} 2>/dev/null
ip link add ${eth_dev} type veth peer name ${peer_dev}
# Add v-peer to Net-NS
ip link set ${peer_dev} netns ${ns_name}
# Configure v-eth
#ip link set ${eth_dev} up
#ip link set ${peer_dev} up
ifconfig ${eth_dev} ${eth_addr} netmask ${eth_mask} up
# Configure lo, v-peer & default route
ip netns exec ${ns_name} ip link set lo up
ip netns exec ${ns_name} ifconfig ${peer_dev} ${peer_addr} netmask ${peer_mask} up
ip netns exec ${ns_name} route add default gw ${eth_addr} dev ${peer_dev}
# Add rule to table
ip rule del from ${peer_addr} 2>/dev/null
ip rule add from ${peer_addr} table ${table}
# Add new route in vpn tables
route="$(ip route list table main | grep -e ${eth_dev} | grep -e ${eth_addr} | sed 's/ proto.*//')"
for tab in ${TABLE_LIST}
do
ip route del ${route} table ${tab} 2>/dev/null
ip route add ${route} table ${tab}
done
# Run the cmd
ip netns exec ${ns_name} "$@"