-
-
Save rqdaA/9fea933cc1512b881cf98a45eb0d3166 to your computer and use it in GitHub Desktop.
LinuxをAPにするやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
ETHER_DEV="eno2" | |
WIFI_DEV="wlo1" | |
DHCP_MASKED_IP="192.168.8.0/24" | |
ROUTER_IP="192.168.8.1/24" | |
if [ "$1" = "up" ]; then | |
sudo sysctl net.ipv4.ip_forward=1 | |
sudo systemctl start iptables | |
sudo iptables -t nat -A POSTROUTING -s $DHCP_MASKED_IP -o $ETHER_DEV -j MASQUERADE | |
sudo ip addr add $ROUTER_IP dev $WIFI_DEV | |
sudo systemctl stop firewalld | |
sudo systemctl stop NetworkManager | |
sudo systemctl start hostapd | |
sudo systemctl start kea-dhcp4 | |
elif [ "$1" = "down" ]; then | |
sudo sysctl net.ipv4.ip_forward=0 | |
sudo systemctl stop iptables | |
sudo iptables -t nat -D POSTROUTING -s $DHCP_MASKED_IP -o $ETHER_DEV -j MASQUERADE | |
sudo ip addr flush dev $WIFI_DEV | |
sudo systemctl stop hostapd | |
sudo systemctl stop kea-dhcp4 | |
sudo systemctl start firewalld | |
sudo systemctl start NetworkManager | |
else | |
echo "Usage: ./$0 [up | down]" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment