вторник, 27 декабря 2011 г.

GRE Tunnel on Mikrotik and OpenWRT

У нас есть сторона Site1(Mikrotik) с локальной подсетью 10.1.101.0/24 и другая сторона Site2(OpenWRT) с подсетью 10.1.202.0/24. Нам нужно сделать доступ из одной локальной сети в сети в другую локальную сеть.





Site1 RouterBOARD
[user1@MikroTik] > 
/interface gre add name=myGre remote-address=192.168.90.1 local-address=192.168.80.1
[user1@MikroTik] > 
/ip address add address= 172.16.1.1/30 interface=myGre
[user1@MikroTik] > 
/ip route add dst-address=10.1.202.0/24 gateway=172.16.1.2


Site2 OpenWRT




root@OpenWrt:~# chmod -x /etc/init.d/firewall   // отключить файерволл
root@OpenWrt:~# df -h
root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install ip // установить пакет ip
root@OpenWrt:~# opkg install kmod-gre // установить пакет  kmod-gre
root@OpenWrt:~# insmod ip_gre
root@OpenWrt:~# lsmod
root@OpenWrt:~# vi /etc/init.d/tunnel // создать файл
#!/bin/sh /etc/rc.common
START=90
insmod ip_gre
ip tunnel add  myGre  mode gre local 192.168.90.1 remote 192.168.80.1 ttl 255
post-down ip tunnel del myGre  
ip link set   myGre  up
ip a a 172.168.1.2/30 dev myGre  
iptables -I FORWARD -i   myGre  -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1024
iptables -I FORWARD -o   myGre  -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1024
ip r a 10.1.101.0/24 via  172.168.1.1
root@OpenWrt:~# chmod +x /etc/init.d/tunnel
root@OpenWrt:~# /etc/init.d/tunnel enable
root@OpenWrt:~# reboot

среда, 7 сентября 2011 г.

Vpn client OpenWRT (TODO)

Редактировать
 /etc/ppp/options.pptp
#
    lock

    #
    # We don't need the tunnel server to authenticate itself
    #
    noauth

    #
    # Turn off transmission protocols we know won't be used
    #
    nobsdcomp
    nodeflate
   
    #
    # We want MPPE
    # (option naming specific to ppp 2.4.0 with unofficial patch)
    #
    #mppe-40
    #mppe-128
    #mppe-stateless
    debug   
    #
    # We want a sane mtu/mru
    # (ppp 2.4.0 with unofficial patch)
    #
    #mtu 1000
    #mru 100


 ___
Редактировать
 /etc/ppp/ip-up.d/route_up

#!/bin/bash
H=`ps aux | grep 'pppd pty' | grep -v grep | awk '{print $14}'`
DG=`route -n | grep UG | awk '{print $2}'`
DEV=`route -n | grep UG | awk '{print $8}'`
route add -host $H gw $DG dev $DEV
route del default $DEV
route add default dev ppp0


 _______


 /etc/ppp/ip-down.d/route_down

#!/bin/bash
H=`route -n | grep UGH | awk '{print $1}'`
DG=`route -n | grep UGH | awk '{print $2}'`
DEV=`route -n | grep UGH | awk '{print $8}'`
route del -host $H
route add default gw $DG dev $DEV




vi /etc/init.d/custom-user-startup
kill $(pgrep pppd)
sleep 20
pppd pty "pptp 195.234.200.251 --nolaunchpppd" file /etc/ppp/options.pptp user test777  password 777


root@OpenWrt:~# vi /etc/config/network

config interface loopback
        option ifname   lo
        option proto    static
        option ipaddr   127.0.0.1
        option netmask  255.0.0.0

config interface lan
        option ifname   eth0
        option type     bridge
        option proto    static
        option ipaddr   192.168.1.1
        option netmask  255.255.255.0

config interface wan
        option ifname   eth1
        option 'proto' 'dhcp'

        #option 'proto' 'static'

        #option 'defaultroute' '0'
        #option 'peerdns' '0'
        #option 'dns' '195.234.200.253'
        #option 'ipaddr'  '195.234.203.134'
        #option 'netmask' '255.255.255.248'
        #option 'gateway' '195.234.203.129'

        option 'macaddr' '00E04C77E13C'

config 'interface' 'vpn'
        option 'proto' 'pptp'
        option 'ifname' 'pptp-vpn'
        option 'username' 'test777
        option 'password' '777'
        option 'server' '195.234.200.251'
        option 'buffering' '1'

config switch eth0
        option enable_vlan      1

config switch_vlan
        option device   eth0
        option vlan     1
        option ports    "0 1 2 3 4"

среда, 31 августа 2011 г.

Прошивка TP-Link TL-WR841ND

TFTP install

Beware that this installation method needs a TTL level serial console and a working TFTP server and should not be attempted unless you have experience with this sort of thing or are eager to learn :)
This is taken more or less verbatim from https://forum.openwrt.org/viewtopic.php?id=24203, thanks to dl3daz.
- Download http://downloads.openwrt.org/backfire/10.03/ar71xx/openwrt-ar71xx-tl-wr841nd-v5-squashfs-factory.bin to your TFTP server. - Hook your routers WAN ethernet port up to your network - Hook up the serial console as explained in the section "serial console" and do the "tpl" trick to get console access - Now we need to set router and server IP addresses (here named ROUTERIP and SERVERIP, substitute these with the real IP addresses). Type in the console:
setenv ipaddr ROUTERIP
setenv serverip SERVERIP
printenv
- Double check that the output of printenv lists the IP addresses you just set. Now we can load the firmware over TFTP with "tftpboot 0x80000000 openwrt-ar71xx-tl-wr841nd-v5-squashfs-factory.bin":
ar7240> tftpboot 0x80000000 openwrt-ar71xx-tl-wr841nd-v5-squashfs-factory.bin
Using eth0 device
TFTP from server 192.168.32.253; our IP address is 192.168.32.246
Filename 'openwrt-ar71xx-tl-wr841nd-v5-squashfs-factory.bin'.
Load address: 0x80000000
Loading: checksum bad
#################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ######################################################
done
Bytes transferred = 3932160 (3c0000 hex)
- Note the "3c0000" in the last line (your number may differ). Now execute the following commands, if necessary replacing 3c0000 with the number you got from tftpboot:
ar7240> erase 0x9f020000 +0x3c0000
...
ar7240> cp.b 0x80000000 0x9f020000 0x3c0000
ar7240> bootm 0x9f020000