Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ########################### REPOSITORIOS DEBIAN 12 ################################################################
- cp -p /etc/apt/sources.list /etc/apt/sources.old
- (
- echo 'deb http://deb.debian.org/debian bookworm main non-free-firmware contrib non-free'
- echo 'deb-src http://deb.debian.org/debian bookworm main non-free-firmware contrib non-free'
- echo ' '
- echo 'deb http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware contrib non-free'
- echo 'deb-src http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware contrib non-free'
- ) > /etc/apt/sources.list
- ################################################################################################################
- apt update && apt upgrade -y
- apt install firmware-linux firmware-linux-free firmware-linux-nonfree -y
- cp -p /etc/default/grub /etc/default/grub.old
- sed -i '/GRUB_CMDLINE_LINUX_DEFAULT=/s/=splash net.ifnames=0 mitigations=off quiet/' /etc/default/grub
- (
- echo 'source /etc/network/interfaces.d/*.cfg'
- echo 'auto lo'
- echo 'iface lo inet loopback'
- echo
- echo 'auto lo0'
- echo 'iface lo0 inet manual'
- echo ' pre-up ip link add lo0 type dummy'
- echo
- echo 'auto bond0'
- echo 'iface bond0 inet manual'
- echo '#bond-slaves eth0 eth1'
- echo 'bond-mode 802.3ad'
- echo 'bond-xmit-hash-policy layer2+3'
- echo ' #post-up ifconfig eth0 mtu 9000'
- echo ' #post-up ifconfig eth1 mtu 9000'
- echo ' #post-up ifconfig bond0 mtu 9000'
- echo
- echo '#Vlan'
- echo '#auto eth0.XXX'
- echo '#iface eth0.XXX inet manual'
- echo '# pre-up ip link set dev $IFACE up'
- echo '# pre-down ip link set dev $IFACE down'
- echo
- echo 'auto eth0'
- echo 'iface eth0 inet manual'
- echo ' pre-up ip link set dev $IFACE up'
- echo ' pre-down ip link set dev $IFACE down'
- echo
- echo '#auto eth1'
- echo '#iface eth1 inet manual'
- echo '# pre-up ip link set dev $IFACE up'
- echo '# pre-down ip link set dev $IFACE down'
- ) > /etc/network/interfaces
- update-grub
- reboot
- ############## install FRR Debian ##############
- apt remove open-vm-tools -y
- apt purge open-vm-tools -y
- apt update && apt upgrade -y
- apt autoremove -y
- apt install curl apt-transport-https gnupg2 lsb-release tree net-tools htop wget ethtool grc libdrm-common mtr libdrm2 libglib2.0-0 libglib2.0-data libicu72 libmspack0 libxml2 libxmlsec1 libxslt1.1 shared-mime-info xdg-user-dirs zerofree frr frr-doc frr-pythontools frr-rpki-rtrlib frr-snmp -y
- sed -i '/bgpd/s/=no/=yes/' /etc/frr/daemons
- sed -i '/ospfd/s/=no/=yes/' /etc/frr/daemons
- sed -i '/ospf6d/s/=no/=yes/' /etc/frr/daemons
- sed -i '/babeld/s/=no/=no/' /etc/frr/daemons
- sed -i '/pbrd/s/=no/=yes/' /etc/frr/daemons
- sed -i '/bfdd/s/=no/=yes/' /etc/frr/daemons
- (
- echo '#!/bin/sh'
- echo
- echo '[ "x$1" = "x" ] && exit 1'
- echo 'cmd="show $@"'
- echo 'vtysh -c "$cmd"'
- echo
- ) > /usr/bin/show
- chmod +x /usr/bin/show
- (
- echo '#!/bin/sh'
- echo
- echo 'hostname $1'
- echo 'echo "$1" > /etc/hostname'
- echo
- ) > /sbin/sethostname
- chmod +x /sbin/sethostname
- apt install ifenslave vlan -y
- modprobe bonding
- modprobe 8021q
- modprobe tcp_htcp
- modprobe tcp_illinois
- echo bonding >> /etc/modules
- echo 8021q >> /etc/modules
- echo tcp_westwood >> /etc/modules
- echo tcp_htcp >> /etc/modules
- cat /etc/modules
- ############### CONF FRR ##################
- (
- echo 'frr version 8.x'
- echo 'frr defaults traditional'
- echo 'hostname debianRouter'
- echo 'log syslog informational'
- echo 'ip forwarding'
- echo 'ipv6 forwarding'
- echo 'service integrated-vtysh-config'
- echo '!'
- echo 'ip route 0.0.0.0/0 192.168.48.1 250'
- echo '!'
- echo '#interface bond0'
- echo 'interface eth0'
- echo ' description WAN'
- echo ' ip address 192.168.48.254/24'
- echo 'exit'
- echo '!'
- ) > /etc/frr/frr.conf
- (
- echo 'frr version 8.x'
- echo 'frr defaults traditional'
- echo 'hostname debianRouter'
- echo 'log syslog informational'
- echo 'ip forwarding'
- echo 'ipv6 forwarding'
- echo 'service integrated-vtysh-config'
- echo '!'
- echo 'ip route 0.0.0.0/0 10.100.100.1 250'
- echo 'ip route 0.0.0.0/1 10.100.100.1 250'
- echo 'ip route 128.0.0.0/1 10.100.100.1 250'
- echo '!'
- echo '#interface bond0'
- echo 'interface eth0'
- echo 'description WAN'
- echo 'ip address 10.100.100.24/24'
- echo 'ip ospf area 0.0.0.0'
- echo 'ip ospf cost 1'
- echo 'ipv6 address 2001:db8:ffff:ffff:ffff::24/64'
- echo 'ipv6 ospf6 area 0.0.0.0'
- echo 'ipv6 ospf6 cost 1'
- echo 'exit'
- echo '!'
- echo 'interface lo0'
- echo ' ip address 192.0.2.24/32'
- echo 'exit'
- echo '!'
- echo '#interface lo1'
- echo '# description INT-Virtual'
- echo '# ip address 1.0.0.1/32'
- echo '# ip address 1.1.1.1/32'
- echo '# ip address 189.38.95.95/32'
- echo '# ip address 189.38.95.96/32'
- echo '# ip address 208.67.220.220/32'
- echo '# ip address 208.67.222.222/32'
- echo '# ip address 4.4.4.4/32'
- echo '# ip address 8.8.4.4/32'
- echo '# ip address 8.8.8.8/32'
- echo '# ip address 9.9.9.9/32'
- echo '# ipv6 address 2001:4860:4860::8844/128'
- echo '# ipv6 address 2001:4860:4860::8888/128'
- echo '# ipv6 address 2606:4700:4700::1001/128'
- echo '# ipv6 address 2606:4700:4700::1111/128'
- echo '# ipv6 address 2620:119:35::35/128'
- echo '# ipv6 address 2620:119:53::53/128'
- echo '# ipv6 address 2620:fe::9/128'
- echo '# ipv6 address 2620:fe::fe/128'
- echo '# ipv6 address 2804:10:10::10/128'
- echo '# ipv6 address 2804:10:10::20/128'
- echo '#exit'
- echo '#!'
- echo 'router ospf'
- echo ' ospf router-id 192.0.2.24'
- echo ' log-adjacency-changes'
- echo ' redistribute connected'
- echo ' redistribute static'
- echo 'exit'
- echo '!'
- echo 'router ospf6'
- echo ' ospf6 router-id 192.0.2.24'
- echo ' log-adjacency-changes'
- echo ' redistribute connected'
- echo ' redistribute static'
- echo ' interface eth0 area 0.0.0.0'
- echo 'exit'
- echo '!'
- ) > /etc/frr/frr.ospf
- ############### Confi resolv.conf ##############
- (
- echo '#nameserver 127.0.0.1'
- echo 'nameserver 8.8.4.4'
- echo 'nameserver 8.8.8.8'
- echo 'nameserver 2001:4860:4860::8844'
- echo 'nameserver 2001:4860:4860::8888'
- ) > /etc/resolv.conf
- ################ Criar Servico Supergateway
- touch /lib/systemd/system/supergw.service
- (
- echo '[Unit]'
- echo 'Description=SuperGateway '
- echo 'After=network.target'
- echo
- echo '[Service]'
- echo 'User=root'
- echo 'Group=root'
- echo 'Type=simple'
- echo 'RemainAfterExit=yes'
- echo
- echo 'WorkingDirectory=/etc/network/'
- echo 'ExecStart=/etc/network/supergw.sh'
- echo
- echo 'TimeoutStartSec=60'
- echo 'TimeoutStopSec=300'
- echo
- echo '[Install]'
- echo 'WantedBy=multi-user.target'
- echo 'Alias=supergw.service'
- echo
- ) > /lib/systemd/system/supergw.service
- ########################### Criação do script com a conf supergatey
- touch /etc/network/supergw.sh
- (
- echo '#!/bin/sh'
- echo
- echo 'gateway=$(ip route get 1.2.3.4 | grep via | awk '{print $3}')'
- echo 'sourceip=$(ip addr show dev lo0 | grep -v inet6 | grep inet | awk ''{print $2}'' | cut -f1 -d/)'
- echo
- echo '/sbin/ip route add 0.0.0.0/1 via $gateway src $sourceip'
- echo '/sbin/ip route add 128.0.0.0/1 via $gateway src $sourceip'
- echo 'exit 0'
- ) > /etc/network/supergw.sh
- chmod +x /etc/network/supergw.sh
- ############################ Colocar para iniciar
- systemctl daemon-reload
- systemctl enable supergw.service
- systemctl start supergw.service
- ############################# NFTABLES #################################
- apt install nftables -y
- (
- echo '#!/usr/sbin/nft -f'
- echo '#nft list ruleset '
- echo 'flush ruleset'
- echo
- echo 'table inet filter {'
- echo
- echo 'set acesso-4 {'
- echo 'flags interval'
- echo 'type ipv4_addr'
- echo ' elements = { 127.0.0.1, 192.168.0.0/16, 10.0.0.0/8, 100.64.0.0/10, 172.16.0.0/12, 192.0.2.0/22 }'
- echo ' }'
- echo ' set acesso-6 {'
- echo ' flags interval'
- echo ' type ipv6_addr'
- echo ' elements = { ::1, 2001:db8::/32 }'
- echo ' }'
- echo ' chain input {'
- echo ' type filter hook input priority 0;'
- echo
- echo ' # Permite Acesso'
- echo ' ip saddr @acesso-4 tcp dport 22 counter accept'
- echo ' ip saddr @acesso-4 tcp dport 8822 counter accept'
- echo ' ip6 saddr @acesso-6 tcp dport 22 counter accept'
- echo ' ip6 saddr @acesso-6 tcp dport 8822 counter accept'
- echo ' tcp dport 22 counter drop'
- echo ' tcp dport 8822 counter drop'
- echo
- echo ' type filter hook input priority 0;'
- echo ' }'
- echo ' chain forward {'
- echo ' type filter hook forward priority 0;'
- echo ' }'
- echo ' chain output {'
- echo ' type filter hook output priority 0;'
- echo '}'
- echo '}'
- ) > /etc/nftables.conf
- systemctl daemon-reload
- systemctl enable nftables.service
- apt install neofetch -y
- echo -n > /etc/motd
- echo -n > /etc/issue
- echo -n > /etc/issue.net
- touch /etc/profile.d/my_bash.sh
- chmod +x /etc/profile.d/my_bash.sh
- (
- echo '#!/bin/bash'
- echo '/usr/bin/neofetch'
- echo
- echo 'echo Servidor Debian - Router '
- echo 'echo By Paulo Jr Andrade '
- echo 'echo 67 98151-2941 '
- echo 'echo ++++++++++++++++++++++++++++++++++++++++++++++++ '
- echo 'echo ACESSO PERMITIDO APENAS A PESSOAL AUTORIZADO '
- echo 'echo TODAS AS CONEXOES ESTAO SENDO '
- echo 'echo MONITORADAS E AUDITADAS '
- echo 'echo ++++++++++++++++++++++++++++++++++++++++++++++++ '
- ) > /etc/profile.d/my_bash.sh
- ######################## otimização kernel ####################
- rm /etc/sysctl.d/*
- echo -n > /etc/sysctl.conf
- (
- echo 'vm.swappiness=10'
- echo 'vm.vfs_cache_pressure=50'
- echo 'vm.max_map_count=262144'
- echo
- echo 'kernel.panic=3'
- echo 'kernel.threads-max=1031306'
- echo 'kernel.pid_max=262144'
- echo 'kernel.msgmax=327680'
- echo 'kernel.msgmnb=655360'
- echo 'kernel.msgmni=32768'
- echo
- echo 'vm.min_free_kbytes = 32768'
- echo
- echo 'net.core.rmem_default=31457280'
- echo 'net.core.wmem_default=31457280'
- echo 'net.core.rmem_max=134217728'
- echo 'net.core.wmem_max=134217728'
- echo
- echo 'net.core.netdev_max_backlog=4096'
- echo 'net.core.optmem_max=33554432'
- echo 'net.core.default_qdisc=fq'
- echo 'net.core.somaxconn=4096'
- echo
- echo 'net.ipv4.tcp_sack = 1'
- echo 'net.ipv4.tcp_timestamps = 1'
- echo 'net.ipv4.tcp_low_latency = 1'
- echo 'net.ipv4.tcp_max_syn_backlog = 8192'
- echo 'net.ipv4.tcp_rmem = 4096 87380 67108864'
- echo 'net.ipv4.tcp_wmem = 4096 65536 67108864'
- echo 'net.ipv4.tcp_mem = 6672016 6682016 7185248'
- echo 'net.ipv4.tcp_congestion_control=reno'
- echo 'net.ipv4.tcp_mtu_probing=1'
- echo 'net.ipv4.tcp_moderate_rcvbuf =1'
- echo 'net.ipv4.tcp_no_metrics_save = 1'
- echo
- echo 'net.ipv4.udp_rmem_min=131072'
- echo 'net.ipv4.udp_mem=2097152 4194304 8388608'
- echo
- echo 'net.ipv4.ipfrag_high_thresh=4194304'
- echo 'net.ipv4.ipfrag_low_thresh=3145728'
- echo 'net.ipv4.ipfrag_max_dist=64'
- echo 'net.ipv4.ipfrag_secret_interval=0'
- echo 'net.ipv4.ipfrag_time=30'
- echo
- echo 'net.ipv6.ip6frag_high_thresh=4194304'
- echo 'net.ipv6.ip6frag_low_thresh=3145728'
- echo 'net.ipv6.ip6frag_secret_interval=0'
- echo 'net.ipv6.ip6frag_time=60'
- echo
- echo 'net.ipv4.ip_local_port_range=1024 65535'
- echo 'net.ipv4.ip_default_ttl=128'
- echo
- echo 'net.ipv4.neigh.default.gc_interval = 30'
- echo 'net.ipv4.neigh.default.gc_stale_time = 60'
- echo 'net.ipv4.neigh.default.gc_thresh1 = 4096'
- echo 'net.ipv4.neigh.default.gc_thresh2 = 8192'
- echo 'net.ipv4.neigh.default.gc_thresh3 = 12288'
- echo
- echo 'net.ipv6.neigh.default.gc_interval = 30'
- echo 'net.ipv6.neigh.default.gc_stale_time = 60'
- echo 'net.ipv6.neigh.default.gc_thresh1 = 4096'
- echo 'net.ipv6.neigh.default.gc_thresh2 = 8192'
- echo 'net.ipv6.neigh.default.gc_thresh3 = 12288'
- echo
- echo 'net.ipv4.conf.default.forwarding=1'
- echo 'net.ipv6.conf.default.forwarding=1'
- echo
- echo 'net.ipv4.conf.all.forwarding=1'
- echo 'net.ipv6.conf.all.forwarding=1'
- echo 'net.ipv4.ip_forward=1'
- echo
- echo '#net.nf_conntrack_max=8000000'
- echo '#net.nf_conntrack_max=8000000'
- echo
- echo '#net.netfilter.nf_conntrack_buckets=262144'
- echo '#net.netfilter.nf_conntrack_checksum=1'
- echo '#net.netfilter.nf_conntrack_events = 1'
- echo '#net.netfilter.nf_conntrack_expect_max = 1024'
- echo '#net.netfilter.nf_conntrack_timestamp = 0'
- echo
- echo 'fs.file-max = 3263776'
- echo 'fs.aio-max-nr=3263776'
- echo 'fs.mount-max=1048576'
- echo 'fs.mqueue.msg_max=128'
- echo 'fs.mqueue.msgsize_max=131072'
- echo 'fs.mqueue.queues_max=4096'
- echo 'fs.pipe-max-size=8388608'
- ) > /etc/sysctl.conf
- sysctl -p
- ############## SEGURANCA SSH ####################
- cp -p /etc/ssh/sshd_config /etc/ssh/sshd_config_old
- (
- echo 'Include /etc/ssh/sshd_config.d/*.conf'
- echo 'Port 8822'
- echo 'PermitRootLogin no'
- echo 'AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2'
- echo 'PermitEmptyPasswords no'
- echo 'KbdInteractiveAuthentication no'
- echo 'UsePAM yes'
- echo 'X11Forwarding yes'
- echo 'PrintMotd no'
- echo 'AcceptEnv LANG LC_*'
- echo 'Subsystem sftp /usr/lib/openssh/sftp-server'
- echo 'PasswordAuthentication yes'
- echo 'Match Address 192.168.0.0/16,10.0.0.0/8,100.100.64.0.0/10,192.0.2.0/22,2001:db8::/32'
- echo 'PermitRootLogin yes'
- echo
- ) > /etc/ssh/sshd_config
- systemctl restart ssh*
Advertisement
Add Comment
Please, Sign In to add comment