atftp --trace --option "timeout 1" --option "mode octet" --put --local-file openwrt-brcm47xx-squashfs.trx 192.168.1.1
#ssh root@192.168.0.30
root@192.168.0.30's password:
BusyBox v1.15.3 (2010-11-12 00:01:06 PST) built-in shell (ash)
Enter 'help' for a list of built-in commands.
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| WIRELESSFREEDOM
Backfire (10.03.1-rc4, r24045) --------------------
* 1/3 shot Kahlua In a shot glass, layer Kahlua
* 1/3 shot Bailey's on the bottom, then Bailey's,
* 1/3 shot Vodka then Vodka.
---------------------------------------------------
root@OpenWrt:~#
root@OpenWrt:~# cat /etc/config/network
#### VLAN configuration
config switch eth0
option enable 1
config switch_vlan eth0_0
option device "eth0"
option vlan 0
option ports "1 2 3 5*" #default vlan, LAN1-3,
# - 5*, ,
#
#http://wiki.openwrt.org/doc/uci/network/switch
config switch_vlan eth0_1
option device "eth0"
option vlan 1
option ports "0 5" # WAN
config switch_vlan eth0_2
option device "eth0"
option vlan 2
option ports "4 5" # vlan2, DMZ
#### Loopback configuration
config interface loopback
option ifname "lo"
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
#### LAN configuration
config interface lan
option type bridge
option ifname "eth0.0"
option proto static
option ipaddr 192.168.0.30
option netmask 255.255.255.0
#### DMZ configuration
config interface dmz
option ifname "eth0.2"
option proto static
option ipaddr 192.168.100.1
option netmask 255.255.255.0
#### WAN configuration
config interface wan
option ifname "eth0.1"
option proto static
option ipaddr 1.2.3.4
option netmask 255.255.255.0
option gateway 1.2.3.1
config include
option path /etc/firewall.user
#!/bin/sh
ext_if="eth0.1"
ext_ip="1.2.3.4"
int_if="br-lan"
int_ip="192.168.0.30"
LAN="192.168.0.0/24"
dmz_if="eth0.2"
dmz_ip="192.168.100.1"
dmz_server="192.168.100.2"
lo_if="lo"
lo_ip="127.0.0.1"
IPTABLES="/usr/sbin/iptables"
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT DROP
$IPTABLES -P FORWARD DROP
$IPTABLES -N bad_tcp_packets
$IPTABLES -N icmp_packets
#chain icmp_packets ( echo reply[request)
$IPTABLES -A icmp_packets -p icmp -s 0/0 --icmp-type 8 -j ACCEPT
$IPTABLES -A icmp_packets -p icmp -s 0/0 --icmp-type 0 -j ACCEPT
#chain bad_tcp_packets ( iptables #)
$IPTABLES -A bad_tcp_packets -p tcp --tcp-flags SYN,ACK SYN,ACK -m state --state NEW -j REJECT --reject-with tcp-reset
$IPTABLES -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j DROP
#chain PREROUTING ( destination address IP)
$IPTABLES -t nat -A PREROUTING -p tcp -d $ext_ip -m multiport --dport 8001,31187,20113,20118 -j \
DNAT --to-destination $dmz_server
$IPTABLES -t nat -A PREROUTING -p tcp -d $ext_ip -m multiport --dport 80 -j DNAT \
--to-destination $dmz_server:8001
$IPTABLES -t nat -A PREROUTING -p udp -d $ext_ip -m multiport --dport 20113,20118 -j \
DNAT --to-destination $dmz_server
$IPTABLES -t nat -A PREROUTING -p icmp -d $ext_ip -j DNAT --to-destination $dmz_server
#FORWARD
$IPTABLES -A FORWARD -p tcp -j bad_tcp_packets
$IPTABLES -A FORWARD -p tcp -i $ext_if -o $dmz_if -s 0/0 -d $dmz_server -m multiport --dport 80,8001,31187,20113,20118 -j \ ACCEPT
$IPTABLES -A FORWARD -p udp -i $ext_if -o $dmz_if -s 0/0 -d $dmz_server -m multiport --dport 20113,20118 -j ACCEPT
$IPTABLES -A FORWARD -p tcp -i $int_if -o $dmz_if -s $LAN -d $dmz_server -m multiport --dport 31187,3389 -j ACCEPT
$IPTABLES -A FORWARD -p icmp -i $int_if -o $dmz_if -s $LAN -d $dmz_server -j icmp_packets
$IPTABLES -A FORWARD -p icmp -i $ext_if -o $dmz_if -s 0/0 -d $dmz_server -j icmp_packets
$IPTABLES -A FORWARD -p ALL -i $dmz_if -o $int_if -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -p ALL -i $dmz_if -o $ext_if -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -p icmp -i $dmz_if -o $ext_if -j icmp_packets
#INPUT
$IPTABLES -A INPUT -p tcp -j bad_tcp_packets
$IPTABLES -A INPUT -p icmp -j icmp_packets
$IPTABLES -A INPUT -p tcp -i $int_if -s $LAN -m multiport --dport 22,80 -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $dmz_if -s $dmz_server -j ACCEPT
#OUTPUT
$IPTABLES -A OUTPUT -p tcp -j bad_tcp_packets
$IPTABLES -A OUTPUT -p icmp -o $ext_if -d 0/0 -j icmp_packets
$IPTABLES -A OUTPUT -p ALL -s $lo_ip -j ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $int_ip -d $LAN -j ACCEPT
$IPTABLES -A OUTPUT -p icmp -o $dmz_if -d $dmz_server -j icmp_packets
#POSTROUTING
$IPTABLES -t nat -A POSTROUTING -o $ext_if -j SNAT --to-source $ext_ip
root@OpenWrt:~# reboot
Source: https://habr.com/ru/post/109976/
All Articles