4gcanipv6

From Radio Amteur Station OH5BZR - WIKI
Revision as of 13:05, 21 February 2015 by 127.0.0.1 (talk) (/etc/network/interfaces)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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