Jump to content

Recommended Posts

Posted

помогите чайнику с настройкой NAT

нужно чтоб linux все что приходило с интерфейса eth1 (192.168.100.80) перебрасывал на 192.168.100.80:8000 на этом порту сидит прокси

 

в интернете кучу страниц перебрал. везде написано запишите в фаервор какую нить строчку, а там в этом фаерволе папок и файлов куча

 

Posted (edited)

 

iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE

iptables --append FORWARD --in-interface eth1 -j ACCEPT

iptables -A INPUT -i eth1 -j ACCEPT

iptables -A OUTPUT -o eth1 -j ACCEPT

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT --to 192.168.100.80:8000

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 8000

 

вот это будет правильно ?

Edited by diesels
Posted
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to 192.168.100.80:8000

а если надо с нескольких портов перебрасывать то надо через запятую их перечислять

типа так:

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80, 25, 110 -j REDIRECT --to 192.168.100.80:8000

 

[root@intel_serv ~]# iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to 192.168. 100.80:8000

iptables v1.3.7: IP address not permitted

 

Try `iptables -h' or 'iptables --help' for more information.

 

Posted

то тогда сделать три строчки вида

 

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8000

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 25 -j REDIRECT --to-port 8000

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 110 -j REDIRECT --to-port 8000

 

Posted

Вот полный конфиг сквида.

 

acl all src 0.0.0.0/0.0.0.0

acl manager protocache_object

acl autosib src 192.168.100.0/24

acl Komers-1 src 192.168.100.3

acl lena src 192.168.100.6

 

# acl to_localhost dst 127.0.0.0/8

acl SSL_ports port 443 # https

acl SSL_ports port 563 # snews

acl Rsync_ports port 873

acl Jabber_ports port 5222 5223

acl Safe_ports port 80 # http

acl Safe_ports port 21 # ftp

acl Safe_ports port 443 # https

acl Safe_ports port 70 # gopher

acl Safe_ports port 210 # wais

acl Safe_ports port 1025-65535 # unregistered ports

acl Safe_ports port 280 # http-mgmt

acl Safe_ports port 488 # gss-http

acl Safe_ports port 563 # snews

acl Safe_ports port 591 # filemaker

acl Safe_ports port 777 # multiling http

acl Safe_ports port 631 # cups

acl Safe_ports port 873 # rsync

acl Safe_ports port 901 # SWAT

acl Safe_ports port 110 # mail

acl Safe_ports port 25 # mail

acl CONNECT method CONNECT

 

http_port 192.168.100.80:8000

http_access allow Komers-1

http_access allow lena

http_access deny all

 

visible_hostname 192.168.100.80

 

cache_mgr aleksey@wslan.ru

 

 

cache_access_log /var/log/squid/access.log

cache_log /var/log/squid/cache.log

cache_store_log /var/log/squid/store.log

 

 

http_accel_host virtual

http_accel_port 80

http_accel_uses_host_header on

Posted (edited)

в гугль, но вообще:

 

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

 

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 8000

 

iptables -A FORWARD -o eth1 -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

 

iptables -A FORWARD -i eth1 -o eth0 -p tcp --dport 25 -j ACCEPT

iptables -A FORWARD -i eth1 -o eth0 -p tcp --dport 110 -j ACCEPT

{последнюю строчку повторять для нужных служб}

Edited by redrum
Posted

Не стоит использовать редирект, если у вас прокся не на той же машине, что и гейт, с которого вы редиректите пакеты. Читаем в man iptables, что делает редирект и какие аргументы принимает:

REDIRECT

This target is only valid in the nat table, in the PREROUTING and OUT-

PUT chains, and user-defined chains which are only called from those

chains. It redirects the packet to the machine itself by changing the

destination IP to the primary address of the incoming interface

(locally-generated packets are mapped to the 127.0.0.1 address).

 

То бишь пакетик будет переброшен на праймари адрес того интерфейса, с которого пришел (на тот порт, который указали в --to-ports в редиректе).

Рекомендую пользовать обычный таргет DNAT и им перекидывать на проксю.

Posted (edited)

нужно чтоб linux все что приходило с интерфейса eth1 (192.168.100.80) перебрасывал на 192.168.100.80:8000 на этом порту сидит прокси

тут как раз всё нормально :)

Edited by redrum
Posted
Не стоит использовать редирект, если у вас прокся не на той же машине, что и гейт, с которого вы редиректите пакеты. Читаем в man iptables, что делает редирект и какие аргументы принимает:

REDIRECT

This target is only valid in the nat table, in the PREROUTING and OUT-

PUT chains, and user-defined chains which are only called from those

chains. It redirects the packet to the machine itself by changing the

destination IP to the primary address of the incoming interface

(locally-generated packets are mapped to the 127.0.0.1 address).

 

То бишь пакетик будет переброшен на праймари адрес того интерфейса, с которого пришел (на тот порт, который указали в --to-ports в редиректе).

Рекомендую пользовать обычный таргет DNAT и им перекидывать на проксю.

т.е. если на сервер на 80 порт идет запрос с адреса, с адреса 192.168.100.100 то этот запрос перекидывается на порт 8000 и при этом у запроса меняеться ИП адрес.

 

Мне Dnat ни о чем не говорит. может напишешь как будет выглядеть ком***, я попробую и сравним что лучше.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...
На сайте используются файлы cookie и сервисы аналитики для корректной работы форума и улучшения качества обслуживания. Продолжая использовать сайт, вы соглашаетесь с использованием файлов cookie и с Политикой конфиденциальности.