systemrescue_as_a_router
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| systemrescue_as_a_router [2026/06/20 17:18] – steve | systemrescue_as_a_router [2026/06/23 17:28] (current) – steve | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ==== System Rescue as a router ==== | ==== System Rescue as a router ==== | ||
| - | Use curl to get this script to a freshly booted machine running SystemRescue [[https:// | + | Use curl to get this script to a freshly booted machine running SystemRescue [[https:// |
| ^^%%curl -sL " | ^^%%curl -sL " | ||
| Line 12: | Line 12: | ||
| # The variables below are the only things that should need changing; | # The variables below are the only things that should need changing; | ||
| - | export ExtIF=" | + | export ExtIF=" |
| - | export IntIF=" | + | export IntIF=" |
| - | export Sub="31" | + | export Sub="192.168.11" |
| - | export CIDR="/ | + | export CIDR="/ |
| - | export IntIP=" | + | export |
| - | export IntNet=" | + | export IntNet=" |
| - | export IntLow=" | + | export IntLow=" |
| - | export | + | export |
| - | export Dur=" | + | export Dur=" |
| - | export DNS1=" | + | export DNS1=" |
| - | export DNS2=" | + | export DNS2=" |
| + | export Dom=" | ||
| - | # 1. Clean Dnsmasq Configuration | ||
| # Replace the contents of your / | # Replace the contents of your / | ||
| - | |||
| mv / | mv / | ||
| Line 38: | Line 37: | ||
| domain-needed | domain-needed | ||
| bogus-priv | bogus-priv | ||
| - | domain=local.lan | + | domain=${Dom} |
| expand-hosts | expand-hosts | ||
| Line 46: | Line 45: | ||
| # --- DHCP SETTINGS --- | # --- DHCP SETTINGS --- | ||
| - | # Lease range tailored to your ${IntNet} | + | # Lease range for ${IntNet} |
| dhcp-range=${IntLow}, | dhcp-range=${IntLow}, | ||
| - | # Explicitly pass this server' | + | # Explicitly pass this VMs internal IP as the gateway |
| dhcp-option=option: | dhcp-option=option: | ||
| - | # Announce this server | + | # Announce this VM as the authoritative DHCP source |
| dhcp-authoritative | dhcp-authoritative | ||
| EndOfFile | EndOfFile | ||
| - | # 2. Network Interface Alignment | ||
| # Before starting the services, ensure your internal interface (${IntIF}) | # Before starting the services, ensure your internal interface (${IntIF}) | ||
| + | # is configured and up | ||
| ip addr add ${IntIP}${CIDR} dev ${IntIF} | ip addr add ${IntIP}${CIDR} dev ${IntIF} | ||
| ip link set ${IntIF} up | ip link set ${IntIF} up | ||
| - | # 3. Bash Script to Flush Rules, Enable Routing, and NAT | + | # Run this to completely wipe the firewall, enable system-level |
| - | # Run this script | + | |
| # packet forwarding, and route internal client traffic out to the | # packet forwarding, and route internal client traffic out to the | ||
| # internet through ${ExtIF}. | # internet through ${ExtIF}. | ||
| - | # 1. Enable IPv4 packet forwarding in the Linux kernel | + | # Enable IPv4 packet forwarding in the Linux kernel |
| sysctl -w net.ipv4.ip_forward=1 | sysctl -w net.ipv4.ip_forward=1 | ||
| echo " | echo " | ||
| - | # 2. Set default policies to ACCEPT everything temporarily | + | # Set default policies to ACCEPT everything temporarily |
| iptables -P INPUT ACCEPT | iptables -P INPUT ACCEPT | ||
| iptables -P FORWARD ACCEPT | iptables -P FORWARD ACCEPT | ||
| iptables -P OUTPUT ACCEPT | iptables -P OUTPUT ACCEPT | ||
| - | # 3. Flush all rules from all tables (Filter, NAT, Mangle) | + | # Flush all rules from all tables (Filter, NAT, Mangle) |
| iptables -F | iptables -F | ||
| iptables -t nat -F | iptables -t nat -F | ||
| iptables -t mangle -F | iptables -t mangle -F | ||
| - | # 4. Delete all custom user-defined chains | + | # Delete all custom user-defined chains |
| iptables -X | iptables -X | ||
| iptables -t nat -X | iptables -t nat -X | ||
| iptables -t mangle -X | iptables -t mangle -X | ||
| - | # 5. Reset all packet and byte counters back to zero | + | # Reset all packet and byte counters back to zero |
| iptables -Z | iptables -Z | ||
| - | # 6. Configure NAT / Masquerade out of the external interface | + | # Configure NAT / Masquerade out of the external interface |
| iptables -t nat -A POSTROUTING -o ${ExtIF} -j MASQUERADE | iptables -t nat -A POSTROUTING -o ${ExtIF} -j MASQUERADE | ||
| - | # 7. Forward traffic from internal network out to the internet | + | # Forward traffic from internal network out to the internet |
| iptables -A FORWARD -i ${IntIF} -o ${ExtIF} -j ACCEPT | iptables -A FORWARD -i ${IntIF} -o ${ExtIF} -j ACCEPT | ||
| iptables -A FORWARD -i ${ExtIF} -o ${IntIF} -m state --state RELATED, | iptables -A FORWARD -i ${ExtIF} -o ${IntIF} -m state --state RELATED, | ||
| - | ## Restarting the Clean Infrastructure | ||
| # Wipe out any runtime artifacts from old setups and fire up the new router configuration | # Wipe out any runtime artifacts from old setups and fire up the new router configuration | ||
| # Clear any stuck active leases | # Clear any stuck active leases | ||
| Line 106: | Line 103: | ||
| systemctl restart dnsmasq | systemctl restart dnsmasq | ||
| </ | </ | ||
| + | {{ : | ||
systemrescue_as_a_router.1781975928.txt.gz · Last modified: by steve
