TP-Link TL-WR842ND v2 iptables

Post new topic   Reply to topic    DD-WRT Forum Index -> Использование и установка DD-WRT
Author Message
Hamit
DD-WRT Novice


Joined: 15 Feb 2017
Posts: 3

PostPosted: Wed Feb 15, 2017 10:28    Post subject: TP-Link TL-WR842ND v2 iptables Reply with quote
Доброе время суток
В наличии:
Router Model
TP-Link TL-WR842ND v2
Firmware Version
DD-WRT v24-sp2 (04/09/15) std - build 26653
Kernel Version
Linux 3.10.73 #11908 Thu Apr 9 03:30:58 CEST 2015 mips

Настроил на нем соединение trunk

eth0.113 Link encap:Ethernet HWaddr 14:CC:20:94:F8:77
inet addr:10.2.113.151 Bcast:10.2.113.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:45513 errors:0 dropped:8451 overruns:0 frame:0
TX packets:18870 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3926095 (3.7 MiB) TX bytes:3721366 (3.5 MiB)

eth0.1469 Link encap:Ethernet HWaddr 14:CC:20:94:F8:77
inet addr:172.20.0.14 Bcast:172.20.0.15 Mask:255.255.255.252
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:13002 errors:0 dropped:0 overruns:0 frame:0
TX packets:9050 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3892828 (3.7 MiB) TX bytes:811717 (792.6 KiB)

Клиенты получают доступ до интернет vlan 1469 (услуга NAT Internet) через WiFi по DHCP в сети 192.168.123.0/24

Все работает, но
Клиенты из сети 192.168.123.0/24 видят сети 10.0.0.0/8, маршрут на которые принудительно прописан на устройстве:
Destination LAN NET Subnet Mask Gateway Flags Metric Interface
default 0.0.0.0 172.20.0.13 UG 0 eth0.1469 - WiFi
10.0.0.0 255.0.0.0 10.2.113.1 UG 0 eth0.113 - mgmt
10.2.113.0 255.255.255.0 * U 0 eth0.113 - mgmt
169.254.0.0 255.255.0.0 * U 0 LAN & WLAN
172.20.0.12 255.255.255.252 * U 0 eth0.1469 - Traffic
192.168.1.0 255.255.255.0 * U 0 LAN & WLAN
192.168.123.0 255.255.255.0 * U 0 tun0

Задача: запретить доступ из сети 192.168.123.0/24 до сетей 10.0.0.0/8
Средствами web не нашел как это осуществить.
Но нашел способ через командную строку:
iptables -I FORWARD 1 -s 192.168.123.0/24 -d 10.0.0.0/8 -j DROP
тогда доступ пропадает
но после перезагрузки изменения по iftables не сохраняются
пробовал включить данную команду в Command Shell, команда проходит, но запись идет не под номером 1, как прописано, а записывается в конец таблицы:
# iptables -L FORWARD -n --line-number
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0
2 DROP 0 -- 192.168.123.0/24 10.0.0.0/8

Прошу пояснить, каким образом возможно сохранить изменения в iptables?
Или иной способ ограничения доступа до сетей


Last edited by Hamit on Thu Feb 16, 2017 4:10; edited 1 time in total
Sponsor
Hamit
DD-WRT Novice


Joined: 15 Feb 2017
Posts: 3

PostPosted: Wed Feb 15, 2017 10:33    Post subject: Re: TP-Link TL-WR842ND v2 iptables Reply with quote
в скрипт внес вот такие строки:
Firewall

iptables -F
iptables -X
iptables -I FORWARD 1 -s 192.168.123.0/24 -d 10.0.0.0/8 -j DROP
iptables -I INPUT 1 -s 192.168.123.0/24 -d 10.0.0.0/8 -j DROP
iptables -I FORWARD 2 -s 192.168.1.0/24 -d 10.0.0.0/8 -j DROP
iptables -I INPUT 2 -s 192.168.1.0/24 -d 10.0.0.0/8 -j DROP
iptables -I FORWARD 3 -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT
iptables -I INPUT 3 -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT

но он почему не удаляет таблицу iptables, а только добавляет записи:

# iptables -L FORWARD -n --line-numbers
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0
2 ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0
3 DROP 0 -- 192.168.123.0/24 10.0.0.0/8
4 DROP 0 -- 192.168.1.0/24 10.0.0.0/8
5 ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0
Hamit
DD-WRT Novice


Joined: 15 Feb 2017
Posts: 3

PostPosted: Wed Feb 15, 2017 12:40    Post subject: Re: TP-Link TL-WR842ND v2 iptables Reply with quote
в общем, сам написал, сам и решил
видимо после перезагрузки таблица iptables загружается не сразу
в скрипт startup добавил sleep 20
10 мало, 20 хватает

sleep 20;
iptables -I FORWARD 1 -s 192.168.123.0/24 -d 10.0.0.0/8 -j DROP;
iptables -I INPUT 1 -s 192.168.123.0/24 -d 10.0.0.0/8 -j DROP;
iptables -I FORWARD 2 -s 192.168.1.0/24 -d 10.0.0.0/8 -j DROP;
iptables -I INPUT 2 -s 192.168.1.0/24 -d 10.0.0.0/8 -j DROP;

тогда таблица изменяется корректно:

# iptables -L INPUT -n --line-numbers
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 DROP 0 -- 192.168.123.0/24 10.0.0.0/8
2 DROP 0 -- 192.168.1.0/24 10.0.0.0/8
3 ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0

iptables -L FORWARD -n --line-numbers
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 DROP 0 -- 192.168.123.0/24 10.0.0.0/8
2 DROP 0 -- 192.168.1.0/24 10.0.0.0/8
3 ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT 0 -- 0.0.0.0/0 0.0.0.0/0
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Использование и установка DD-WRT All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum