Answer the question
In order to leave comments, you need to log in
Configuring access from the local network to the external, how to properly configure NAT?
Greetings.
Problem following:
there is a debian-server. there was a desire to put SQUID on it. Put the second network card.
Configured network interfaces (eth0 - looks to the local network, eth1 - to the Internet). Here is the config /etc/network/interfaces
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
allow-hotplug eth0
auto eth0
iface eth0 inet static
address 192.168.1.102
netmask 255.255.255.0
#gateway 192.168.1.102
auto eth1
iface eth1 inet static
address xx.xx.xx.xx(статический адрес от провайдера)
netmask 255.255.252.0
gateaway xx.xx.xx.xx(шлюз провайдера)
dns-nameservers xx.xx.xx.xx yy.yy.yy.yy(DNS сервера провайдера)
hwaddress ether Mac адрес карты
post-up /etc/nat
#!/bin/sh
# Включаем форвардинг пакетов
echo 1 > /proc/sys/net/ipv4/ip_forward
# Разрешаем трафик на loopback-интерфейсе
iptables -A INPUT -i lo -j ACCEPT
# Разрешаем доступ из внутренней сети наружу
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
# Включаем NAT
iptables -t nat -A POSTROUTING -o eth1 -s 192.168.1.0/24 -j MASQUERADE
# Разрешаем ответы из внешней сети
iptables -A FORWARD -i eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Запрещаем доступ снаружи во внутреннюю сеть
iptables -A FORWARD -i eth1 -o eth0 -j REJECT
Answer the question
In order to leave comments, you need to log in
Well, proxies and nat are usually not connected in any way, moreover, it is even harmful to connect them. Remove the iptables config from post-up altogether.
If you still need nat, then understand iptables, it is configured differently, copying the first script that comes across from the Internet will not work. First, at the beginning of the script, you need to reset all chains (-F) and explicitly set the default policies (-P). Second, both INPUT and OUTPUT (and in certain cases FORWARD) are allowed for lo. Thirdly, well, iptables does not work, well, remove the extra reject-accept from it (your last two lines).
Try manually on some PC to put in the provider's DNS or 8.8.8.8 (better for verification). if dnsmasq is on the same server, then you must at least allow access in the INPUT, OUTPUT chains, possibly FILTER
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question