Hi there,
I'm trying to setup routed mode for my IPTV Provider KPN.
It's working out pretty well.
It requires me to setup VLAN4 (tagged) on the WAN interface and setup a NAT rule for it.
I have been following this guide (dutch):
http://netwerkje.com/routed-iptv
So far I have:
/jffs/scripts/wan-start:
/jffs/scripts/vlan4.script:
And the extra dhcp options for my IPTV receivers.
/jffs/configs/dnsmasq.conf.add:
Upon reboot VLAN4 comes up like it should
And the route gets added:
Almost done now.
Except for the last part where I need to setup extra nat rules:
# NAT
add action=masquerade chain=srcnat dst-address=10.142.64.0/18 out-interface=vlan16.4
add action=masquerade chain=srcnat dst-address=213.75.112.0/21 out-interface=vlan16.4
I suppose iptables would be able to do the trick.
In the above example the out-interface should be vlan4.
Can anyone with some experience with iptables share some knowledge on how to add these destination addresses to the nat-chain with output interface vlan4?
Thanks in advance!
I'm trying to setup routed mode for my IPTV Provider KPN.
It's working out pretty well.
It requires me to setup VLAN4 (tagged) on the WAN interface and setup a NAT rule for it.
I have been following this guide (dutch):
http://netwerkje.com/routed-iptv
So far I have:
/jffs/scripts/wan-start:
Code:
#!/bin/sh
# Leave VOIP traffic tagged for original router
/usr/sbin/robocfg vlan 7 ports "0t 3t"
# Setup VLAN4 on the CPU as well so we can talk to it
/usr/sbin/robocfg vlan 4 ports "0t 4u 8t"
# Add VLAN4 as a physical interface
/sbin/vconfig add eth0 4
# Request an IP-address and setup static routes
udhcpc -i vlan4 -O msstaticroutes -O staticroutes -V IPTV_RG -s /jffs/scripts/vlan4.script -p /var/run/vlan4.pid -b -O33 -O249
/jffs/scripts/vlan4.script:
Code:
#!/bin/sh
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"
set_classless_routes() {
local max=128
local type
while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do
[ ${1##*/} -eq 32 ] && type=host || type=net
echo "udhcpc: adding route for $type $1 via $2"
/sbin/route add -$type "$1" gw "$2" dev "$interface"
max=$(($max-1))
shift 2
done
}
case "$1" in
deconfig)
/sbin/ifconfig $interface 0.0.0.0
;;
leasefail|nak)
echo "Failed to obtain lease..."
;;
renew|bound)
/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
[ -n "$staticroutes" ] && set_classless_routes $staticroutes
[ -n "$msstaticroutes" ] && set_classless_routes $msstaticroutes
;;
esac
exit 0
And the extra dhcp options for my IPTV receivers.
/jffs/configs/dnsmasq.conf.add:
Code:
dhcp-option=vendor:,1,IPTV_RG
dhcp-option=28,192.168.1.255
Upon reboot VLAN4 comes up like it should
Code:
vlan4 Link encap:Ethernet HWaddr E0:3F:49:0A:D6:D8
inet addr:10.228.192.83 Bcast:10.228.255.255 Mask:255.255.192.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:661107 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:891204369 (849.9 MiB) TX bytes:692 (692.0 B)
And the route gets added:
Code:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
213.75.112.0 10.228.192.1 255.255.248.0 UG 0 0 0 vlan4
10.228.192.0 0.0.0.0 255.255.192.0 U 0 0 0 vlan4
Almost done now.
Except for the last part where I need to setup extra nat rules:
# NAT
add action=masquerade chain=srcnat dst-address=10.142.64.0/18 out-interface=vlan16.4
add action=masquerade chain=srcnat dst-address=213.75.112.0/21 out-interface=vlan16.4
I suppose iptables would be able to do the trick.
In the above example the out-interface should be vlan4.
Can anyone with some experience with iptables share some knowledge on how to add these destination addresses to the nat-chain with output interface vlan4?
Thanks in advance!