Difference between revisions of "4gcanipv6"

From Radio Amteur Station OH5BZR - WIKI
Jump to: navigation, search
(/etc/hostapd/hostapd.conf)
(/etc/network/interfaces)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
 +
=HARWARE=
 +
- Huawei 3/4G stick E398
 +
- Chinese 2dollars wlan usb tongle's
 +
 +
=IPV4/IPV6 WIFI SUBNETWORK=
 +
 +
https://kindlund.wordpress.com/2007/11/19/configuring-multiple-default-routes-in-linux/<br>
 +
http://www.linuxhorizon.ro/iproute2.html<br>
 +
 +
=agreements needed=
 +
- Elisa 3G/4G phone operators connection "Saunalahti 4G"
 +
- sixxs.prg IPV6 TUNNEL and subnet addressing
  
 
=/etc/network/interfaces=
 
=/etc/network/interfaces=
Line 5: Line 18:
  
 
<code>
 
<code>
auto lo eth0 wwan0 sixxs
+
 
# The primary network interface
+
# MPI2
iface eth0 inet static
+
# This file describes the network interfaces available on your system
        address 192.168.0.40
+
# and how to activate them. For more information, see interfaces(5).
        netmask 255.255.255.0
+
 
        broadcast 192.168.0.255
+
# The loopback network interface
        dns-nameservers 192.168.0.40 192.168.0.41
+
 
        dns-search mpi2.kurrola.dy.fi mpi2.kurrola.dy.fi
+
auto lo eth0 wlan0
        dns-domain mpi1.kurrola.dy.fi mpi2.kurrola.dy.fi
+
#auto wwan0 sixxs
        network 192.168.0.0
+
 
  # routes to wifi hot spots
+
iface lo inet loopback
 +
 
 +
#Primary internet connection
 +
 
 +
iface ppp0 inet wvdial
 +
        post-up sleep 30
 +
        post-up /sbin/shorewall start
 +
        post-up /sbin/iptables -A FORWARD -t mangle -m mark ! --mark 1/1 -j NFQUEUE
 +
        post-up /sbin/iptables -A INPUT -t mangle -m mark ! --mark 1/1 -j NFQUEUE
 +
        post-up /sbin/iptables -A OUTPUT -t mangle -m mark ! --mark 1/1 -j NFQUEUE
 +
        post-up /sbin/ifup sixxs
 +
        pre-down /home/joni/cronjobs/weboff
 +
 
 +
# The primary network interface
 +
 
 +
iface eth0 inet static
 +
address 192.168.0.40
 +
netmask 255.255.255.0
 +
broadcast 192.168.0.255
 +
dns-nameservers 192.168.0.40 192.168.0.41
 +
dns-search mpi2.kurrola.dy.fi mpi2.kurrola.dy.fi
 +
dns-domain mpi1.kurrola.dy.fi mpi2.kurrola.dy.fi
 +
network 192.168.0.0
 +
        up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.254
 +
#       up route add -net 192.168.1.0 netmask 255.255.255.0  gw 192.168.0.40
 
         up route add -net 192.168.1.0 netmask 255.255.255.0  gw 192.168.0.41
 
         up route add -net 192.168.1.0 netmask 255.255.255.0  gw 192.168.0.41
# it's me up route add -net 192.168.1.0 netmask 255.255.255.0  gw 192.168.0.40
+
#       up route add -net 192.168.1.0 netmask 255.255.255.0  gw 192.168.0.253
        up route add -net 192.168.1.0 netmask 255.255.255.0  gw 192.168.0.254
+
#        up route add -net 192.168.1.0 netmask 255.255.255.0  gw 192.168.0.252
# or?
+
# gateway 192.168.0.40
#     up ip route add 192.168.1.40/24 via 192.168.0.254
+
#       post-up ip -4 route add 192.168.0.254 dev eth0
#     up ip route add 192.168.1.40/24 via 192.168.0.41
+
        up ip -4 addr add 192.168.0.20 dev eth0
# GiganetEthernet IPV6
+
#        up ip -4 addr del 192.168.0.20 dev eth0
iface eth0 inet6 static
+
        pre-up echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
        pre-up sleep 10
+
        pre-up echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
        address 2001:14b8:100:8363::40
+
#       post-up ip addr add 192.168.0.20 dev eth0
        netmask 64
+
#        pre-down ip addr del 192.168.0.20 dev eth0
        dns-nameservers 2001:14b8:100:8363::40 2001:14b8:100:8363::41
+
#        post-down echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore
#ipv4 4G
+
#       post-down echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce
iface wwan0 inet dhcp
+
        mtu 1500
        pre-up /usr/bin/qmicli -d /dev/cdc-wdm? --wds-start-network=internet --client-no-release-cid
+
 
        post-up shorewall start
+
iface eth0 inet6 static
#ipv6
+
pre-up sleep 10
iface sixxs inet manual
+
address 2001:14b8:100:8363::40
        pre-up invoke-rc.d aiccu start
+
netmask 64
        up sleep 1
+
dns-nameservers 2001:14b8:100:8363::40 2001:14b8:100:8363::41
        up ip link set mtu 1280 dev $IFACE
+
# gateway 2001:14b8:100:8363::41
        post-down invoke-rc.d aiccu stop
+
        post-up ip -6 addr add 2001:14b8:100:8363::20 dev eth0
         post-up shorewall6 start
+
#    post-up ip -6 addr add 2001:14b8:100:8363::20 dev eth0
# wifi
+
#    pre-down ip -6 addr del 2001:14b8:100:8363::20 dev eth0
iface wlan0 inet static
+
 
         address 192.168.1.40
+
 
         netmask 255.255.255.0
+
iface wlan0 inet static
        broadcast 192.168.1.255
+
address 192.168.1.40
         network 192.168.1.0
+
netmask 255.255.255.0
#     up ip route add 192.168.1.40/24 via 192.168.0.40
+
broadcast 192.168.1.255
 +
network 192.168.1.0
 +
#        up ip route add 192.168.1.0/24 dev wlan0       
 +
 
 +
#iface br0 inet static
 +
# network 192.168.0.0
 +
# address 192.168.0.40
 +
# broadcast 192.168.0.255
 +
# netmask 255.255.255.0
 +
# bridge_ports eth0 wlan0
 +
# dns-nameservers 192.168.0.40 192.168.0.41
 +
# dns-search mpi1.kurrola.dy.fi mpi2.kurrola.dy.fi
 +
# dns-domain mpi1.kurrola.dy.fi mpi2.kurrola.dy.fi
 +
#      gateway 192.168.0.40
 +
#address 192.168.0.253
 +
#dns-nameservers 193.229.0.40 193.229.0.42
 +
 
 +
iface wwan0 inet dhcp
 +
pre-up /usr/bin/qmicli -d /dev/cdc-wdm? --wds-start-network=internet --client-no-release-cid
 +
post-up /sbin/shorewall start
 +
        post-up /sbin/iptables -A FORWARD -t mangle -m mark ! --mark 1/1 -j NFQUEUE
 +
        post-up /sbin/iptables -A INPUT -t mangle -m mark ! --mark 1/1 -j NFQUEUE
 +
        post-up /sbin/iptables -A OUTPUT -t mangle -m mark ! --mark 1/1 -j NFQUEUE
 +
        post-up /sbin/ifup sixxs
 +
        post-down /home/joni/cronjobs/weboff
 +
        #post-down /sbin/ifdown sixxs
 +
 
 +
iface sixxs inet manual
 +
pre-up invoke-rc.d aiccu start
 +
up sleep 1
 +
up ip link set mtu 1280 dev $IFACE
 +
post-down invoke-rc.d aiccu stop
 +
         post-down /home/joni/cronjobs/weboff
 +
post-up shorewall6 start
 +
        post-up /home/joni/cronjobs/webon
 +
         #post-up /sbin/iptables -A FORWARD -t mangle -m mark ! --mark 1/1 -j NFQUEUE
 +
         #post-up /sbin/iptables -A INPUT -t mangle -m mark ! --mark 1/1 -j NFQUEUE
 +
         #post-up /sbin/iptables -A OUTPUT -t mangle -m mark ! --mark 1/1 -j NFQUEUE
 +
 
 +
 
 +
 
 
</code>
 
</code>
  

Latest revision as of 13:05, 21 February 2015

HARWARE

- Huawei 3/4G stick E398 - Chinese 2dollars wlan usb tongle's

IPV4/IPV6 WIFI SUBNETWORK

https://kindlund.wordpress.com/2007/11/19/configuring-multiple-default-routes-in-linux/
http://www.linuxhorizon.ro/iproute2.html

agreements needed

- Elisa 3G/4G phone operators connection "Saunalahti 4G" - sixxs.prg IPV6 TUNNEL and subnet addressing

/etc/network/interfaces

- giganet ethernet 192.168.0.0/24
- wlan subnet 192.168.01.0/24, wlan wifi hotspots at 192.168.0.254 chanel 9, 192.168.0.40 chane 6, 192.168.0.41 chanel 3, hostapd

  1. MPI2
  2. This file describes the network interfaces available on your system
  3. and how to activate them. For more information, see interfaces(5).
  1. The loopback network interface

auto lo eth0 wlan0

  1. auto wwan0 sixxs

iface lo inet loopback

  1. Primary internet connection

iface ppp0 inet wvdial

       post-up sleep 30
       post-up /sbin/shorewall start
       post-up /sbin/iptables -A FORWARD -t mangle -m mark ! --mark 1/1 -j NFQUEUE
       post-up /sbin/iptables -A INPUT -t mangle -m mark ! --mark 1/1 -j NFQUEUE
       post-up /sbin/iptables -A OUTPUT -t mangle -m mark ! --mark 1/1 -j NFQUEUE
       post-up /sbin/ifup sixxs
       pre-down /home/joni/cronjobs/weboff
  1. The primary network interface

iface eth0 inet static address 192.168.0.40 netmask 255.255.255.0 broadcast 192.168.0.255 dns-nameservers 192.168.0.40 192.168.0.41 dns-search mpi2.kurrola.dy.fi mpi2.kurrola.dy.fi dns-domain mpi1.kurrola.dy.fi mpi2.kurrola.dy.fi network 192.168.0.0

       up route add -net 192.168.1.0 netmask 255.255.255.0  gw 192.168.0.254
  1. up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.40
       up route add -net 192.168.1.0 netmask 255.255.255.0  gw 192.168.0.41
  1. up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.253
  2. up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.252
  3. gateway 192.168.0.40
  4. post-up ip -4 route add 192.168.0.254 dev eth0
       up ip -4 addr add 192.168.0.20 dev eth0
  1. up ip -4 addr del 192.168.0.20 dev eth0
       pre-up echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
       pre-up echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
  1. post-up ip addr add 192.168.0.20 dev eth0
  2. pre-down ip addr del 192.168.0.20 dev eth0
  3. post-down echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore
  4. post-down echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce
       mtu 1500

iface eth0 inet6 static pre-up sleep 10 address 2001:14b8:100:8363::40 netmask 64 dns-nameservers 2001:14b8:100:8363::40 2001:14b8:100:8363::41

  1. gateway 2001:14b8:100:8363::41
       post-up ip -6 addr add 2001:14b8:100:8363::20 dev eth0
  1. post-up ip -6 addr add 2001:14b8:100:8363::20 dev eth0
  2. pre-down ip -6 addr del 2001:14b8:100:8363::20 dev eth0


iface wlan0 inet static address 192.168.1.40 netmask 255.255.255.0 broadcast 192.168.1.255 network 192.168.1.0

  1. up ip route add 192.168.1.0/24 dev wlan0
  1. iface br0 inet static
  2. network 192.168.0.0
  3. address 192.168.0.40
  4. broadcast 192.168.0.255
  5. netmask 255.255.255.0
  6. bridge_ports eth0 wlan0
  7. dns-nameservers 192.168.0.40 192.168.0.41
  8. dns-search mpi1.kurrola.dy.fi mpi2.kurrola.dy.fi
  9. dns-domain mpi1.kurrola.dy.fi mpi2.kurrola.dy.fi
  10. gateway 192.168.0.40
  11. address 192.168.0.253
  12. dns-nameservers 193.229.0.40 193.229.0.42

iface wwan0 inet dhcp pre-up /usr/bin/qmicli -d /dev/cdc-wdm? --wds-start-network=internet --client-no-release-cid post-up /sbin/shorewall start

       post-up /sbin/iptables -A FORWARD -t mangle -m mark ! --mark 1/1 -j NFQUEUE
       post-up /sbin/iptables -A INPUT -t mangle -m mark ! --mark 1/1 -j NFQUEUE
       post-up /sbin/iptables -A OUTPUT -t mangle -m mark ! --mark 1/1 -j NFQUEUE
       post-up /sbin/ifup sixxs
       post-down /home/joni/cronjobs/weboff
       #post-down /sbin/ifdown sixxs

iface sixxs inet manual pre-up invoke-rc.d aiccu start up sleep 1 up ip link set mtu 1280 dev $IFACE post-down invoke-rc.d aiccu stop

       post-down /home/joni/cronjobs/weboff

post-up shorewall6 start

       post-up /home/joni/cronjobs/webon
       #post-up /sbin/iptables -A FORWARD -t mangle -m mark ! --mark 1/1 -j NFQUEUE
       #post-up /sbin/iptables -A INPUT -t mangle -m mark ! --mark 1/1 -j NFQUEUE
       #post-up /sbin/iptables -A OUTPUT -t mangle -m mark ! --mark 1/1 -j NFQUEUE


shorewall

-masq needed

shorewall6

keepUP script to cron tab

- prerequsite: sudo apt-get wvdial aiccu glib-networking-common libqmi - first if IPV4 dose not work start's Huawei E398 reset and setup - if aiccu ipv6 tunnel not respond restart's IPV%

bug's: dose not detect problem's in DNS and BIND, DNS and BIND need's

own restart and cheking as weel !

crontab

#!/bin/bash
DATE=`date`
PASS="`ping -I wwan0 -c 2 195.197.95.175 | grep -oP '\d+(?=% packet loss)'`"
echo "PASS IPV4: $PASS"
if [ "0" != "$PASS" ] ; then
   echo "$(date) [KeepWwan0OnD] Warning: IPV4 connection lost at -- restart"  >> /var/log/syslog
       /home/joni/wwanREPAIR
       sleep 60
       if ! ['0' -eq "$(ping -I wwan0 -c 2 195.197.95.175 | grep -oP '\d+(?=% packet loss)')"]; then
            echo "$(date) [KeepWwan0OnScript] Waiting for IPV4 connection going up" >> /var/log/syslog
       else 
            echo "$(date) [KeepWwan0OnScript] IPV4 Connection ON" >> /var/log/syslog
       fi
    fi
# IPV6
DATE=`date`
PASS6="`ping6 -I sixxs -c 2 2a00:1450:400f:804::1009 | grep -oP '\d+(?=% packet loss)'`"
echo "PASS IPV6: $PASS6"
if [ "0"  != "$PASS6" ]; then
       echo "$(date) [KeepWwan0OnScript]  Warning: IPV6 connection lost -- restart" >> /var/log/syslog
       ifdown sixxs
       sleep 10
       ifup sixxs
       sleep 10
       webon
       if ! ["0" -eq "$(echo ping6 -I sixxs -c 2 2a00:1450:400f:804::1009 | grep -oP '\d+(?=% packet loss)')"]; then
            echo "$(date) [KeepWwan0OnScript]  Waiting for IPV6 connection going up" >> /var/log/syslog
       else 
            echo "$(date) [KeepWwan0OnScript]  IPV6 Connection on" >> /var/log/syslog
       fi
   fi

wwanREPAIR

If modem stucks at most cases if hardreset done first and after delay it's driver and device itself re-installed it will go on. If computer harware/ubuntu can not detect modem you need to re-start whole machine.


#!/bin/sh
ifdown sixxs
ifdown wwan0
wvdial hardreset
sleep 30
usb_modeswitch -v 12d1 -p 1505 -V 12d1 -P 1506 -M "55534243123456780000000000000011062000000100000000000000000000" -n 1 -W
sleep 40
ifup wwan0
sleep 10
ifup sixxs

/etc/wvdial.conf

[Dialer hardreset]
Modem = /dev/ttyUSB1
Init1 = AT+CFUN=1,1
Dial Attempts = 10

/etc/network/interfaces

  1. ipv4 4G

iface wwan0 inet dhcp

      pre-up /usr/bin/qmicli -d /dev/cdc-wdm? --wds-start-network=internet --client-no-release-cid
      post-up shorewall start

/etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
macaddr_acl=1
accept_mac_file=/etc/hostapd.accept
ssid=KURROAIR
hw_mode=g
channel=3
wpa=2
wpa_passphrase=kovaamenee
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
wpa_ptk_rekey=600