Tizim yadrosini sozlash.
Quyidagi faylni oching:
vi /etc/sysctl.d/gateway.conf
Unga qatorni qo'shing:
net.ipv4.ip_forward=1
Sozlamani qo'llang:
sysctl -p /etc/sysctl.d/gateway.conf
Bitta tarmoq adapteri uchun siz boshqa hech narsa qilishingiz shart emas -
Ubuntu Internet shlyuzi vazifasini bajaradi. Bir nechta tarmoq adapterlari uchun
biz xavfsizlik devorini sozlaymiz.
Xavfsizlik devorini sozlash.
Odatda, Debian-ga asoslangan Linux-da netfilter xavfsizlik devori iptables
yordam dasturi yordamida boshqariladi.
Iptables
O'rnatish Internet ens160 interfeysi orqali tuzilganligi asosida amalga
oshiriladi:
iptables -t nat -A POSTROUTING -o ens160 -j
MASQUERADE
Agar server mahalliy va global tarmoqlarga kirish uchun turli xil tarmoq
interfeyslaridan foydalansa, biz yana ikkita qoida yaratishimiz kerak bo'lishi
mumkin:
iptables -A FORWARD -i ens32 -o ens160 -j ACCEPT
* ichki tarmoq uchun ens32 va tashqi uchun ens160 ishlatiladi, deb taxmin
qilinadi.
IPptables sozlamalarini saqlaymiz:
Portni yo'naltirish
Tarmoq so'rovlarini NAT orqasida va tashqi tarmoqqa to'g'ridan-to'g'ri kirish
imkoniyati bo'lmagan serverga yo'naltirish uchun zarur.
Iptables
Konfiguratsiya ikkita buyruq bilan amalga oshiriladi:
yoki buni qilishingiz mumkin:
iptables -A FORWARD -i ens32 -o ens160 -m state --state
RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i ens32 -o ens160 -j ACCEPT
apt-get install iptables-persistent
netfilter-persistent save
iptables -t nat -A PREROUTING -p tcp -m tcp -d
10.8.232.111 --dport 25 -j DNAT --to-destination
192.168.0.15:8025
iptables -t nat -A POSTROUTING -p tcp -m tcp -s
192.168.0.15 --sport 8025 -j SNAT --to-source
10.8.232.111:25
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport
25 -j DNAT --to-destination 192.168.0.15:8025
iptables -A FORWARD -p tcp -d 192.168.0.15 --dport
8025 -m state --state NEW,ESTABLISHED,RELATED -j
ACCEPT
* bu erda eth0 tashqi tarmoq interfeysi.
Portga ruxsat berish:
* so'rovni tarjima qiladigan portga ruxsat berishimizga e'tibor bering, chunki
POSTROUTING va PREROUTING zanjirlari FILTER zanjirigacha ishlaydi va
shuning uchun biz kirish portini (25) emas, balki paket tayinlanganini ochishimiz
kerak. (8025).
Qoidalarga rioya qilishni unutmang:
Nazorat savollari
1.
Internet shlyuzi deganda nimani tushinasiz va uning vazifasini tushintiring?
2.
Proksi server shlyuzi deganda nimani tushinasiz va uning vazifasini
tushintiring?
3.
Ubuntu da internet shlyuzi qanday sozlanadi?
4.
Tarmoq porti deganda nimani tushinasiz ?
5.
Xavfsizlik devoir nima va uni vazifasini tushintiring ?
iptables -I INPUT 1 -p tcp --dport 8025 -j ACCEPT
netfilter-persistent save