net/int
2026-02-16 15:01:26 +05:00

140 lines
3.6 KiB
Bash
Executable file

#!bin/bash
a=1
while a==1
do
echo ""
echo "Enter number"
echo ""
echo "1. Hostname"
echo "2. Calculate the mask"
echo "3. IP"
echo "4. Forward and masquerade"
echo "5. Reboot"
echo "6. Account"
echo "0. Exit"
echo ""
read num
echo ""
if (( $num == 0 )); then
break
elif (( $num == 1 )); then
echo "______________________Hostname_____________________"
read -p "Enter name(isp.au-team.irpo): " name
hostnamectl set-hostname $name
exec bash
elif (( $num == 3)); then
echo "_____________________Enp0s3_______________________"
read -p "Enter ip or skip for DHCP: " ip_s3
if [[ -n $ip_s3 ]]; then
read -p "Enter gateway: " gt_s3
cat > /etc/NetworkManager/system-connections/enp0s3.nmconnection << EOF
[connection]
id=enp0s3
uuid=$(uuidgen)
type=ethernet
autoconnect-priority=-999
interface-name=enp0s3
timestamp=$(date +%s)
[ethernet]
[ipv4]
address1=$ip_s3
dns=8.8.8.8
gateway=$gt_s3
method=manual
[ipv6]
addr-gen-mode=eui64
method=disabled
[proxy]
EOF
chmod 600 /etc/NetworkManager/system-connections/enp0s3.nmconnection
systemctl restart NetworkManager
fi
echo ""
echo "________________________Enp0s8_________________________"
read -p "Enter ip or skip: " ip_s8
if [[ -n $ip_s8 ]]; then
nmcli connection modify enp0s8 ipv4.method manual ipv4.addresses $ip_s8 ipv6.method disabled
systemctl restart NetworkManager
fi
echo ""
echo "____________________________Enp0s9____________________________"
read -p "Enter ip or skip: " ip_s9
if [[ -n $ip_s9 ]]; then
nmcli connection modify enp0s9 ipv4.method manual ipv4.addresses $ip_s9 ipv6.method disabled
systemctl restart NetworkManager
fi
echo ""
echo "___________________________Enp0s10___________________________"
read -p "Enter ip or skip: " ip_s10
if [[ -n $ip_s10 ]]; then
nmcli connection modify enp0s10 ipv4.method manual ipv4.addresses $ip_s10 ipv6.method disabled
systemctl restart NetworkManager
fi
systemctl restart NetworkManager
elif (( $num == 4 )); then
echo ""
echo "_____________________________Forward and Masquerade__________________________"
sysctl net.ipv4.ip_forward=1 >> /etc/sysctl.conf
systemctl enable --now iptables
iptables -F
read -p "Enter ip for Masquerade: " a
if (( $a == 2 )); then
if [[ -n $ip_s8 || $ip_s9 ]]; then
iptables -t nat -A POSTROUTING -s $ip_s8 -o enp0s3 -j MASQUERADE
iptables -t nat -A POSTROUTING -s $ip_s9 -o enp0s3 -j MASQUERADE
else
read -p "Enter ip for enp0s8(192.168.0.0/30): " ip_s8
read -p "Enter ip for enp0s9(192.168.0.0/30): " ip_s9
iptables -t nat -A POSTROUTING -s $ip_s8 -o enp0s3 -j MASQUERADE
iptables -t nat -A POSTROUTING -s $ip_s9 -o enp0s3 -j MASQUERADE
fi
elif (( $a == 1)); then
if [[ -n $ip_s8 ]]; then
iptables -t nat -A POSTROUTING -s $ip_s8 -o enp0s3 -j MASQUERADE
else
read -p "Enter ip for enp0s8: " ip_s8
iptables -t nat -A POSTROUTING -s $ip_s8 -o enp0s3 -j MASQUERADE
fi
fi
iptables-save --file /etc/sysconfig/iptables
elif (( $num == 5)); then
read -p "Reboot?: " r
if (( $r == n || $r == N)); then
echo "123"
else
reboot
fi
elif (( $num == 2)); then
echo ""
echo "____________________________Calc____________________________"
read -p "Enter amount PC: " mask
mask=$(echo "sqrt($mask)" | bc)
mask=$((32 - $mask))
echo $mask
echo""
elif (( $num == 6)); then
echo "________________________Account_________________________"
read -p "Yes or no?: " acc
if [[ -n $acc ]]; then
read -p "Enter name acc: " acc_n
cat >> /etc/sudoers << EOF
$acc_n ALL=(ALL)NOPASSWD:ALL
EOF
chmod 600 /etc/sudoers
fi
fi
done