From 43c4595c64a20224533d06a32b794242bd7a98cb Mon Sep 17 00:00:00 2001 From: vascoalvesxyz Date: Mon, 16 Mar 2026 09:29:41 +0000 Subject: [PATCH] sh --- DMZ.sh | 26 ++++++++++++++++++++++++ INTERNAL.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ ROUTER.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 DMZ.sh create mode 100644 INTERNAL.sh create mode 100644 ROUTER.sh diff --git a/DMZ.sh b/DMZ.sh new file mode 100644 index 0000000..7457474 --- /dev/null +++ b/DMZ.sh @@ -0,0 +1,26 @@ +# NETWORKS: +# DMZ: 23.214.219.128/25 +# Internal: 192.168.10.0/24 +# +# MACHINES: +# DNS2: 192.137.16.75 +# EDEN 193.138.212.1 +dns2="192.137.16.75" +eden="193.138.212.1" + +# ============================== +# Router 1 +# INTERFACES: +# - Internet: 87.248.214.97 +# - DMZ: 23.214.219.254 +# - Internal: 192.168.10.254 +# ============================== + +# ============================== +# DMZ +# IP: +# - dns : 23.214.219.129 +# - dns2 : 23.214.219.130 +# - smtp : 23.214.219.131 +# - www : 23.214.219.132 +# - diff --git a/INTERNAL.sh b/INTERNAL.sh new file mode 100644 index 0000000..87efd3e --- /dev/null +++ b/INTERNAL.sh @@ -0,0 +1,58 @@ +# NETWORKS: +# DMZ: 23.214.219.128/25 +# Internal: 192.168.10.0/24 +# +# MACHINES: +# DNS2: 192.137.16.75 +# EDEN 193.138.212.1 +dns2="192.137.16.75" +eden="193.138.212.1" + +# ============================== +# Router 1 +# INTERFACES: +# - Internet: 87.248.214.97 +# - DMZ: 23.214.219.254 +# - Internal: 192.168.10.254 +# ============================== + +# ============================== +# DMZ +# IP: +# - dns : 23.214.219.129 +# - dns2 : 23.214.219.130 +# - smtp : 23.214.219.131 +# - www : 23.214.219.132 +# - +sudo ifconfig enp0s8 23.214.219.254 netmask 255.255.255.128 +sudo ifconfig enp0s9 192.168.10.254 netmask 255.255.255.128 +sudo ifconfig enp0s3 87.248.214.97 netmask 255.255.255.0 + + +sudo iptables -F +sudo iptables -t nat -F +sudo iptables -t mangle -F +sudo sysctl -w net.ipv4.ip_forward=1 +iptables -P INPUT DROP +iptables -P FORWARD DROP +iptables -P OUTPUT ACCEPT +sudo iptables -A INPUT -i lo -j ACCEPT +sudo iptables -A OUTPUT -o lo -j ACCEPT +sudo iptables -t nat -A POSTROUTING -o enp0s3 -j MASQUERADE +#DNS name resolution requests sent to outside servers and want a response: //O ip ainda tem de mudar +sudo iptables -A FORWARD -i enp0s8 -o enp0s3 -s 23.214.219.129 -p udp --sport 53 -m state --state ESTABLISHED,RELATED -j ACCEPT +#SSH connections to the router system that originate from the inside and want an answer:É preciso outra regra uma para a port enp0s9 e o ip do vpn +sudo iptables -A FORWARD -p tcp -dport 22 -m state --state ESTABLISHED,RELATED -j ACCEPT +#The dns server should be able to resolve names using the internet (and others???) +sudo iptables -A FORWARD -i enp0s8 -o enp0s3 -s 23.214.219.129 -p udp --dport 53 -j ACCEPT +sudo iptables -A FORWARD -i enp0s8 -o enp0s3 -s 23.214.219.130 -p udp --dport 53 -j ACCEPT +# Apartir daqui foi só para testar se as conecções funcionavam +sudo iptables -A FORWARD -i enp0s8 -s 23.214.219.129 -p tcp --sport 22 +# Unsure these will work +sudo iptables -A FORWARD -i enp0s9 -s 23.214.219.131 + + +#There might be a need to foward and input to, because of the nat? +#Dont use static ip address for internet related rules +sudo ifconfig enp0s8 23.214.219.129 netmask 255.255.255.128 +sudo ip route add default via 23.214.219.254 \ No newline at end of file diff --git a/ROUTER.sh b/ROUTER.sh new file mode 100644 index 0000000..87efd3e --- /dev/null +++ b/ROUTER.sh @@ -0,0 +1,58 @@ +# NETWORKS: +# DMZ: 23.214.219.128/25 +# Internal: 192.168.10.0/24 +# +# MACHINES: +# DNS2: 192.137.16.75 +# EDEN 193.138.212.1 +dns2="192.137.16.75" +eden="193.138.212.1" + +# ============================== +# Router 1 +# INTERFACES: +# - Internet: 87.248.214.97 +# - DMZ: 23.214.219.254 +# - Internal: 192.168.10.254 +# ============================== + +# ============================== +# DMZ +# IP: +# - dns : 23.214.219.129 +# - dns2 : 23.214.219.130 +# - smtp : 23.214.219.131 +# - www : 23.214.219.132 +# - +sudo ifconfig enp0s8 23.214.219.254 netmask 255.255.255.128 +sudo ifconfig enp0s9 192.168.10.254 netmask 255.255.255.128 +sudo ifconfig enp0s3 87.248.214.97 netmask 255.255.255.0 + + +sudo iptables -F +sudo iptables -t nat -F +sudo iptables -t mangle -F +sudo sysctl -w net.ipv4.ip_forward=1 +iptables -P INPUT DROP +iptables -P FORWARD DROP +iptables -P OUTPUT ACCEPT +sudo iptables -A INPUT -i lo -j ACCEPT +sudo iptables -A OUTPUT -o lo -j ACCEPT +sudo iptables -t nat -A POSTROUTING -o enp0s3 -j MASQUERADE +#DNS name resolution requests sent to outside servers and want a response: //O ip ainda tem de mudar +sudo iptables -A FORWARD -i enp0s8 -o enp0s3 -s 23.214.219.129 -p udp --sport 53 -m state --state ESTABLISHED,RELATED -j ACCEPT +#SSH connections to the router system that originate from the inside and want an answer:É preciso outra regra uma para a port enp0s9 e o ip do vpn +sudo iptables -A FORWARD -p tcp -dport 22 -m state --state ESTABLISHED,RELATED -j ACCEPT +#The dns server should be able to resolve names using the internet (and others???) +sudo iptables -A FORWARD -i enp0s8 -o enp0s3 -s 23.214.219.129 -p udp --dport 53 -j ACCEPT +sudo iptables -A FORWARD -i enp0s8 -o enp0s3 -s 23.214.219.130 -p udp --dport 53 -j ACCEPT +# Apartir daqui foi só para testar se as conecções funcionavam +sudo iptables -A FORWARD -i enp0s8 -s 23.214.219.129 -p tcp --sport 22 +# Unsure these will work +sudo iptables -A FORWARD -i enp0s9 -s 23.214.219.131 + + +#There might be a need to foward and input to, because of the nat? +#Dont use static ip address for internet related rules +sudo ifconfig enp0s8 23.214.219.129 netmask 255.255.255.128 +sudo ip route add default via 23.214.219.254 \ No newline at end of file