net/int
2026-03-18 07:46:57 +03:00

137 lines
4 KiB
Bash
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!bin/bash
a=1
while a==1
do
echo ""
echo "Выберите параметр"
echo ""
echo "1. Имя"
echo "2. Калькулятор маски"
echo "3. IP-адрес"
echo "4. Forward и masquerade"
echo "5. Перезагрузить машину"
echo "6. Time zone"
echo "0. Выход"
echo ""
read num
echo ""
if (( $num == 0 )); then
break
elif (( $num == 1 )); then
echo "______________________Имя_____________________"
read -p "Введите имя(isp.au-team.irpo): " name
hostnamectl set-hostname $name
exec bash
elif (( $num == 3)); then
echo "_____________________Enp0s3_______________________"
read -p "Введите ip-адрес или пропустите для DHCP: " ip_s3
if [[ -n $ip_s3 ]]; then
read -p "Введите шлюз или пропустите: " 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 "Введите ip-адрес или пропустите: " 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 "Введите ip-адрес или пропустите: " 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 "Введите ip-адрес или пропустите: " 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 и Masquerade__________________________"
sysctl net.ipv4.ip_forward=1 >> /etc/sysctl.conf
systemctl enable --now iptables
iptables -F
read -p "Введите количество ip-адресов для которых необходимо задать 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
echo "Готово"
else
read -p "Введите ip-адрес для enp0s8(192.168.0.0/30): " ip_s8
read -p "Введите ip-адрес для 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
echo "Готово"
else
read -p "Введите ip для 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 "Перезвгрузить?: " r
if (( $r == n || $r == N)); then
echo "No"
else
reboot
fi
elif (( $num == 2)); then
echo ""
echo "____________________________Калькулятор____________________________"
read -p "Введите количество PC: " mask
mask=$(echo "sqrt($mask)" | bc)
mask=$((32 - $mask))
echo $mask
echo""
elif (( $num == 6)); then
echo "For watch time zone inter: timedatectl list-timezones"
echo "Inter timedatectl set-timezone 'timezone' "
chmod 600 /etc/sudoers
fi
done