понедельник, 25 декабря 2017 г.

Debian 9.3.0 настройка сети

$ nano network.sh
Скопируем из буфера следующий скрипт:
#!/bin/bash
# настройка ip и hostname hname debian 9 на kvm
#----------------------------------------------------------------------
_hostname="deb930"
# real computer
#_iface="enp0s31f6"
# kvm iface
#_iface="ens3"
# virtualbox iface
_iface="enp0s3"
_address="192.168.0.166"
_gateway="192.168.0.1"
_netmask="255.255.255.0"
_nameserver="8.8.8.8"
#----------------------------------------------------------------------
# отключим сетевой менеджер
sudo systemctl stop NetworkManager
sudo systemctl disable NetworkManager
# настроим статический ip
sudo cat > /tmp/interfaces <<EOF
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
#auto $_iface
#iface $_iface inet dhcp
iface $_iface inet static
address $_address
netmask $_netmask
gateway $_gateway
#dns-nameservers $_nameserver
auto $_iface
EOF
sudo cp /tmp/interfaces /etc/network
sudo rm /etc/resolv.conf
sudo /bin/su -c "echo 'nameserver $_nameserver' > /etc/resolv.conf"
# изменим hostname и ip
sudo cat > /tmp/hosts <<EOF
127.0.0.1       localhost
$_address       $_hostname
EOF
sudo cp /tmp/hosts /etc
# изменим hostname
sudo hostname $_hostname
sudo /bin/su -c "echo $_hostname > /etc/hostname"
# отключим ip6
sudo /bin/su -c "echo 'net.ipv6.conf.all.disable_ipv6 = 1' >> /etc/sysctl.conf"
sudo /bin/su -c "echo 'net.ipv6.conf.default.disable_ipv6 = 1' >> /etc/sysctl.conf"
sudo /bin/su -c "echo 'net.ipv6.conf.lo.disable_ipv6 = 1' >> /etc/sysctl.conf"
#sudo /bin/su -c "echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf"
sudo sysctl -p
# перезагрузим сеть
sudo systemctl start networking.service
sudo systemctl enable networking.service
# Настройка sudo journalctl -b sudo journalctl -b -1 sudo journalctl --list-boots
sudo sed -i 's/#Storage=auto/Storage=persistent/' /etc/systemd/journald.conf
# Настройка ftp пользователь: test пароль: test
sudo apt install pure-ftpd -y
sudo groupadd ftpgroup
sudo usermod -aG ftpgroup user
sudo ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/50pure
sudo mkdir /home/user/test
sudo chown -R user:ftpgroup /home/user/test
#sudo pure-pw useradd test -u user -d /home/user/test
# Заведем пользователя ftp test с паролем test
sudo echo -e "test\ntest\n" | sudo pure-pw useradd test -u user -d /home/user/test
sudo pure-pw mkdb
sudo service pure-ftpd restart
# ubuntu
# Отключим службу ondemand
# (для разгона cpu)
# cat /proc/cpuinfo | grep MHz
# systemctl status ondemand
# systemctl stop ondemand
# systemctl disable ondemand
# nano /etc/sysctl.conf
# shutdown -r now

Сохранить.
$ chmod +x network.sh
$ ./network.sh

Комментариев нет:

Отправить комментарий