gate# uname -a FreeBSD gate 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Thu Nov 1 06:48:52 OMST 2012 root@gate:/usr/obj/usr/src/sys/GATE amd64
cd /sys/amd64/conf cp GENERIC GATE ee GATE device pf device pflog options ALTQ options ALTQ_CBQ options ALTQ_RED options ALTQ_RIO options ALTQ_HFSC options ALTQ_PRIQ options ALTQ_NOPCC
make kernel KERNCONF=GATE
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=389b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_UCAST,WOL_MCAST,WOL_MAGIC> inet 192.168.1.2 netmask 0xffffff00 broadcast 192.168.1.255 re1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=389b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_UCAST,WOL_MCAST,WOL_MAGIC> inet 192.168.63.26 netmask 0xfffffff8 broadcast 192.168.63.31 nfe0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=82008<VLAN_MTU,WOL_MAGIC,LINKSTATE> inet 10.1.1.30 netmask 0xffffff00 broadcast 10.1.1.255
ee /etc/rc.conf pf_enable=«YES» pf_rules=«/etc/pf.conf» squid_enable=«YES» reboot
cat pf.conf # , int_if - , ext_if - . int_if=«nfe0» ext_if=«re1» ext_if2=«re0» int_net=«10.1.1.0/24» freeBSD=«10.1.1.30» icmp_types=«{ echoreq, unreach}» http=«80» https=«443» ssh=«22» # . gw1=«192.168.63.25» gw2=«192.168.1.1» # , . #, - ip- . to_ertel=«{10.1.1.42, 10.1.1.33, 10.1.1.4, 10.1.1.12, 10.1.1.5, 10.1.1.48, 10.1.1.25, 10.1.1.3, 10.1.1.243, 10.1.1.5 }» to_trans=«{ 10.1.1.27, 10.1.1.2, 10.1.1.181, 10.1.1.46, 10.1.1.39, 10.1.1.27, 10.1.1.31, 10.1.1.113 }» # - , set block-policy drop set skip on lo # . scrub in all # - nat on $ext_if inet from any to any -> ($ext_if) # - nat on $ext_if2 inet from any to any -> ($ext_if2) # SQUID rdr on $int_if inet proto tcp from any to any port www -> 127.0.0.1 port 3128 block in from any to any block out from any to any # antispoof quick for $int_if inet # pass out on $int_if from any to $int_net # ( ) pass in quick on $int_if route-to ($ext_if2 $gw2) from $to_trans to !$int_net keep state pass in quick on $int_if route-to ($ext_if $gw1) from $to_ertel to !$int_net keep state # (quick) pass in quick on $int_if from $int_net to $int_if pass in quick on $int_if route-to { ($ext_if $gw1), ($ext_if2 $gw2)} round-robin sticky-address proto tcp from $int_net to any flags S/SA keep state # sticky-address RicoX # icmp udp pass in on $int_if route-to { ($ext_if $gw1), ($ext_if2 $gw2) } round-robin proto { udp, icmp } from $int_net to any keep state # "" pass out on $ext_if proto tcp from any to any flags S/SA modulate state pass out on $ext_if proto { udp, icmp } from any to any keep state pass out on $ext_if2 proto tcp from any to any flags S/SA modulate state pass out on $ext_if2 proto { udp, icmp } from any to any keep state # IP $ext_if1 $ext_gw1 # $ext_if2 $ext_gw2 pass out on $ext_if route-to ($ext_if2 $gw2) from $ext_if2 to any pass out on $ext_if2 route-to ($ext_if $gw1) from $ext_if to any
#pass in on $int_if route-to { ($ext_if $gw1), ($ext_if2 $gw2) } round-robin proto { udp, icmp } from $int_net to any keep state
pass out route-to ($ext_if $gw1) from $int_if to any pass out route-to ($ext_if2 $gw2) from $int_if to any
cat er_conn.sh #!/bin/sh GW1=«192.168.63.25» if1=«192.168.63.26» # /sbin/pfctl -d # №2 /sbin/pfctl -e -f /etc/pf.conf.dom # - /sbin/route del default # - №2 /sbin/route add default $GW1
cat squid.conf http_port 127.0.0.1:3128 transparent icp_port 0 hierarchy_stoplist cgi-bin ? acl QUERY urlpath_regex cgi-bin \? no_cache deny QUERY cache_mem 256 MB maximum_object_size 8092 KB maximum_object_size_in_memory 512 KB cache_dir ufs /bkp/var/squid/cache 2048 64 256 cache_access_log /bkp/var/squid/access.log cache_log /bkp/var/squid/cache.log cache_store_log /bkp/var/squid/store.log cache_mgr root@xxx.ru cache_effective_user squid cache_effective_group squid visible_hostname gate coredump_dir /bkp/var/squid/cache pid_filename /var/run/squid/squid.pid acl our_networks src 10.1.1.0/24 http_access allow our_networks
gate# cat do_dhcp #!/bin/sh arp -an | grep < > > /usr/arp.txt # IFS IFS=« » cat /usr/arp.txt | while read line do set -- $line; echo -e «host $1 { hardware ethernet $4; fixed-address $2; }\n» done
cat dhcpd.txt >> /usr/local/etc/dhcpd.conf
Source: https://habr.com/ru/post/177767/
All Articles