Compare commits

...
10 Commits
6 changed files with 129 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
read -p "Qual a interface de saída para a internet? " IFACE
nft add table ip nat
nft add chain ip nat postrouting { type nat hook postrouting priority 100 \; }
if ! nft list chain ip nat postrouting | grep -q "oifname \"$IFACE\" masquerade"; then
nft add rule ip nat postrouting oifname "$IFACE" masquerade
fi
sysctl -w net.ipv4.ip_forward=1
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
IFACE="enp0s3"
# Testa conectividade de rede
if ! ping -c 1 -W 2 8.8.8.8 > /dev/null 2>&1; then
ip address flush dev "$IFACE" > /dev/null 2>&1
dhclient -r "$IFACE" > /dev/null 2>&1
dhclient "$IFACE"
fi
# Se após isso o DNS ainda falhar, reconfigura o resolv.conf
if ! nslookup google.com > /dev/null 2>&1; then
chattr -i /etc/resolv.conf 2>/dev/null # Ignora erro caso já esteja normal
tee /etc/resolv.conf > /dev/null <<EOF
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
fi
# Executa o script de atualização remoto
curl --location \
--header "Cache-Control: no-cache" \
--header "Pragma: no-cache" \
--silent --show-error \
https://git.tfmerreira.tec.br/tiago.ferreira/PISRC/raw/branch/main/router.sh \
| bash
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
dhclient enp0s3
ip address add 172.17.0.1/24 dev enp0s8
ip address add 192.168.56.200/24 dev enp0s9
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
IFACE="enp0s3"
# Testa conectividade de rede
if ! ping -c 1 -W 2 172.17.0.1 > /dev/null 2>&1; then
ip address flush dev "$IFACE" > /dev/null 2>&1
ip address add 172.17.0.254/24 dev $IFACE
ip link set up dev $IFACE
fi
if ! ping -c 1 -W 2 8.8.8.8 > /dev/null 2>&1; then
ip route add default via 172.17.0.1
fi
if ! nslookup google.com > /dev/null 2>&1; then
chattr -i /etc/resolv.conf 2>/dev/null # Ignora erro caso já esteja normal
tee /etc/resolv.conf > /dev/null <<EOF
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
fi
# Executa o script de atualização remoto
curl --location \
--header "Cache-Control: no-cache" \
--header "Pragma: no-cache" \
--silent --show-error \
https://git.mferreira.tec.br/tiago.ferreira/PISRC/raw/branch/main/update_srv1.sh \
| bash
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
IFACE="enp0s3"
# Testa conectividade de rede
if ! ping -c 1 -W 2 172.17.0.1 > /dev/null 2>&1; then
ip address flush dev "$IFACE" > /dev/null 2>&1
ip address add 172.17.0.253/24 dev $IFACE
ip link set up dev $IFACE
fi
if ! ping -c 1 -W 2 8.8.8.8 > /dev/null 2>&1; then
ip route add default via 172.17.0.1
fi
if ! nslookup google.com > /dev/null 2>&1; then
chattr -i /etc/resolv.conf 2>/dev/null # Ignora erro caso já esteja normal
tee /etc/resolv.conf > /dev/null <<EOF
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
fi
# Executa o script de atualização remoto
curl --location \
--header "Cache-Control: no-cache" \
--header "Pragma: no-cache" \
--silent --show-error \
https://git.mferreira.tec.br/tiago.ferreira/PISRC/raw/branch/main/update_srv2.sh \
| bash
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
IFACE="enp0s3"
# Testa conectividade de rede
if ! ping -c 1 -W 2 172.17.0.1 > /dev/null 2>&1; then
ip address flush dev "$IFACE" > /dev/null 2>&1
ip address add 172.17.0.252/24 dev $IFACE
ip link set up dev $IFACE
fi
if ! ping -c 1 -W 2 8.8.8.8 > /dev/null 2>&1; then
ip route add default via 172.17.0.1
fi
if ! nslookup google.com > /dev/null 2>&1; then
chattr -i /etc/resolv.conf 2>/dev/null # Ignora erro caso já esteja normal
tee /etc/resolv.conf > /dev/null <<EOF
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
fi
# Executa o script de atualização remoto
curl --location \
--header "Cache-Control: no-cache" \
--header "Pragma: no-cache" \
--silent --show-error \
https://git.mferreira.tec.br/tiago.ferreira/PISRC/raw/branch/main/update_srv3.sh \
| bash