顯示具有 Ubuntu 標籤的文章。 顯示所有文章
顯示具有 Ubuntu 標籤的文章。 顯示所有文章

星期一, 4月 15, 2013

Ubuntu pptp server

1. install pptpd service
sudo apt-get install pptpd

2. iptables rules
-A INPUT -i xyz0 -p tcp -m state --state NEW --dport 1723 -j ACCEPT

-A INPUT -i xyz0 -p gre -j ACCEPT
-A OUTPUT -i xyz0 -p gre -j ACCEPT
-A INPUT -i xyz0 -p tcp --sport 1723 -s xxx.xxx.xxx.xxx -j ACCEPT
-A OUTPUT -i xyz0 -p tcp --dport 1723 -d xxx.xxx.xxx.xxx -j ACCEPT

xyz0 is the out interface.
xxx.xxx.xxx.xxx is the pptp server address

3. /etc/pptpd.conf
modify localip & remoteip

localip xxx.xxx.xxx.xxx
remoteip 192.168.x.51-59

xxx.xxx.xxx.xxx is the pptp server address

4. /etc/ppp/chap-secrets
add one entry for pptpd

# client server secret IP addresses
"user" pptpd "password" *

5. start pptpd service

星期二, 3月 12, 2013

Use tmpfs in Ubuntu to speed up

Why? Sometime, you will use USB stick to boot up to another testing Ubuntu distribution, but the USB stick as main disk is really slow. So, I choose to use Linux tmpfs to avoid un-necessary access.

/etc/fstab
tmpfs           /tmp            tmpfs   defaults,noatime,mode=1777      0       0

tmpfs           /var/spool      tmpfs   defaults,noatime,mode=1777      0       0
tmpfs           /var/tmp        tmpfs   defaults,noatime,mode=1777      0       0

星期日, 10月 21, 2012

Pandaboard mldonkey server

1. the original mldonkey with precise has bug.
https://bugs.launchpad.net/ubuntu/+source/mldonkey/+bug/1060007

2. try to build for my own.
   - get mldonkey-3.1.3.tar.bz2 from official site
   - extract & get build depend package
     apt-get install build-essential checkinstall ocaml-nox ocaml-native-compilers zlib1g-dev
   - change CXXFLAGS -O2 to -Os
   - ./configure --disable-multinet
   - make -j2
   - copy ./mlnet to /usr/bin/mlnet (to replace the old one)

3. regarding the password for remote user.
    - telnet 127.0.0.1 4000
    - useradd admin xxxx (xxxx is password you want)

Ref: https://help.ubuntu.com/community/MLDonkey
       http://mldonkey.sourceforge.net/Quickstart_guide
       http://mldonkey.sourceforge.net/CompilationProblems

Pandaboard - fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped

1. add smsc95xx.turbo_mode=N in /boot/boot.script

2.  /etc/sysctl.conf
    - vm.min_free_kbytes = 16384 32768
    - vm.vfs_cache_pressure = 200  300

3.  update systcl
    - sudo sysctl -p

lsmod result in Ubuntu precise on Pandaboard


ppp_deflate             4867  0
zlib_deflate           21306  1 ppp_deflate
bsd_comp                5569  0
ppp_async               7602  1
crc_ccitt               1628  1 ppp_async
xt_tcpudp               2573  29
xt_state                1384  1
iptable_filter          1733  1
ipt_MASQUERADE          1954  1
iptable_nat             4528  1
nf_nat                 19315  2 ipt_MASQUERADE,iptable_nat
nf_conntrack_ipv4      14233  4 iptable_nat,nf_nat
nf_conntrack           85255  5 xt_state,ipt_MASQUERADE,iptable_nat,nf_nat,nf_conntrack_ipv4
nf_defrag_ipv4          1594  1 nf_conntrack_ipv4
ip_tables              13212  2 iptable_filter,iptable_nat
x_tables               19387  6 xt_tcpudp,xt_state,iptable_filter,ipt_MASQUERADE,iptable_nat,ip_tables
dm_crypt               18016  0
wl12xx                174783  0
mac80211              490889  1 wl12xx
cfg80211              203992  2 wl12xx,mac80211
wl12xx_sdio             3829  0
compat                  3663  4 wl12xx,mac80211,cfg80211,wl12xx_sdio
gpio_keys               9031  0
leds_gpio               3788  0

Pandaboard disable ondemand cpu governor

1. sudo update-rc.d ondemand disable

2. modify rc.local
# By default this script does nothing.
#set scaling_governor to userspace
echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo userspace > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
# set cpufreq to 800Mhz
echo 800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
echo 800000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_setspeed

Openbravo POS note in Lucid (ARMv7)

RXTX could use the repo's package

but, RXTXComm.jar need to be put in /usr/lib/jvm/java-6-openjdk/jre/lib/ext

librxtxParallel.so, librxtxSerial.so need to be put in /usr/lib/jvm/java-6-openjdk/jre/lib/arm

Use TestSerialPort to do the test.
1. javac *.java
2. java ListCommPorts (check result)

Ubuntu ttySx default only root & dialout have permission to use.
so, the openbravo user need to join dialout group.

for autologon & auto-launch openbravo-pos
/etc/lxdm/lxdm.conf need to be modified
[base]
autologin=opos
session=/opt/openbravopos-2.30/start.sh

Pandaboard Ubuntu 12.04 precise note

My goal is make an device that be my wireless access point, transmission daemon, mldonkey daemon & samba server in my home.

1. first I take a look the following info as reference.
    http://drizztcp.wordpress.com/category/pandaboard/

2. Grab the Ubuntu 12.04 image from http://cdimage.ubuntu.com/releases/12.04/release/. I choose http://cdimage.ubuntu.com/releases/12.04/release/ubuntu-12.04-preinstalled-server-armhf+omap4.img.gz for  my Pandaboard A2.

3. Make bootable SDCard & following the install instruction. https://wiki.ubuntu.com/ARM/OmapDesktopInstall

4. Now, I have an bootable Panda.

5. Configuration the hostapd.  I don't want just take my panda as AP only. So, I decide to run dhcpd on wlan0.
  5.1 dhcp-server part:
     5.1.1. apt-get install isc-dhcp-server
     5.1.2 modify /etc/default/isc-dhcp-server
        - INTERFACES="wlan0"
     5.1.3 modify /etc/dhcp/dhcpd.conf
        - option domain-name "myhome.net";
        - option domain-name-servers 168.95.192.1, 168.95.1.1; (for my Hinet DNS)
        - subnet 192.168.0.0 netmask 255.255.255.0 {
              range 192.168.0.100 192.168.0.150;
              option subnet-mask 255.255.255.0;
              option broadcast-address 192.168.0.255;
              option routers 192.168.0.254;
            }
  5.2 hostapd part:
    5.2.1 /etc/network/interfaces We need wlan0 has static ip to be the rule of dhcp-server.
       - auto wlan0
          iface wlan0 inet static
          address 192.168.0.254
          netmask 255.255.255.0
          network 192.168.0.0
          broadcast 192.168.0.255
    5.2.2 /etc/hostapd/hostapd.conf
        - interface=wlan0
          driver=nl80211
          ssid=panda-wifi
          hw_mode=g
          ieee80211n=1  # enable 802.11n support.
          wmm_enabled=1
          #ht_capab=[HT40-][HT40+] #Ti wl1271 only up to 65Mbps. HT40 will cause module hang.
          channel=5
          macaddr_acl=0
          #0 is allow all connection, 1 is deny all connect, only accept in hostspd.accept
          accept_mac_file=/etc/hostapd/hostapd.accept
          deny_mac_file=/etc/hostapd/hostapd.deny
          auth_algs=1
          ignore_broadcast_ssid=0
          wpa=2
          wpa_passphrase=xxxxxx #choose the password you want.
          wpa_key_mgmt=WPA-PSK
          wpa_pairwise=TKIP
          rsn_pairwise=CCMP
    5.2.3 touch /etc/hostapd/hostapd.accept & /etc/hostapd/hostapd.deny to let hostapd daemon running.
  OK, we have wlan0 & hostapd work now. Next, I want the pppoe work. Zyxel P874 seems performance is not good enough for P2P.
6. PPPoE on eth0
  6.1 install ppp, pppoe support
       - apt-get install ppp pppconfig pppoe pppoeconf
  6.2 /etc/ppp/peers/dsl-provider
       - pty "/usr/sbin/pppoe -I eth0 -T 80 -m 1452"
         noipdefault
         usepeerdns
         defaultroute         
         user "????????@ip.hinet.net"
  6.3 /etc/ppp/chap-secrets, /etc/ppp/pap-secrets
       - "????????@ip.hinet.net" * "??????"
  6.4 /etc/network/interfaces
       - add dsl-provider section
          auto dsl-provider
          iface dsl-provider inet ppp
          provider dsl-provider
    6.5 PPPoE keepalive.sh (for auto-reconnect)
#!/bin/sh

# keepalive.sh

# This is a keepalive script for the Casema cable modems. This script was
# lifted from the /usr/doc/HOWTO/unmaintained/mini/Dynamic-IP-Hacks
# document. There should be an entry in your crontab looking like:
# */2 * * * * /etc/ppp/keepalive.sh
# to run this script every 2 minutes to see if your connection is still
# up, if not, gracefully kill the pppd process and remake it.
# Modify paths as necessary.


if [ -f /var/run/ppp0.pid ]; then
testing=$(ping -c4 -l4 168.95.192.1 2>&1 | grep "0 packets")
if [ "$testing" != "" ]; then
        /usr/bin/poff -a
        sleep 10
        /usr/bin/pon dsl-provider
fi
else
        /usr/bin/pon dsl-provider
fi
    6.6 /etc/crontab
        - */2 *    * * *   root    /etc/ppp/keepalive.sh  (for auto-reconnect)

7. To be an Wireless router
    7.1 /etc/sysctl.conf
       - enable IPv4 forward
          net.ipv4.ip_forward=1
    7.2 add iptable rule.
       - wlan0 as LAN (192.168.0.xxx/24) , ppp0 as Internet connection
       7.2.1 /etc/firewall-rules
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A POSTROUTING -s 192.168.0.0/24 -o ppp0 -j MASQUERADE
COMMIT
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i wlan0 -s 127.0.0.1/8 -j DROP
-A OUTPUT -o wlan0 -d 127.0.0.1/8 -j DROP
-A INPUT -i ppp0 -s 127.0.0.1/8 -j DROP
-A OUTPUT -o ppp0 -d 127.0.0.1/8 -j DROP
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -s 127.0.0.0/8 -d 127.0.0.0/8 -i lo -j ACCEPT
-A INPUT -i ppp0 -p tcp -m tcp --dport 22 -j ACCEPT
#for transmission package
-A INPUT -i ppp0 -p tcp -m tcp --dport 9091 -j ACCEPT
-A INPUT -i ppp0 -p tcp -m tcp --dport 51413 -j ACCEPT
#for FTP
-A INPUT -i wlan0 -p tcp -m tcp --dport 20 -j ACCEPT
-A INPUT -i wlan0 -p tcp -m tcp --dport 21 -j ACCEPT
# for SSH
-A INPUT -i wlan0 -p tcp -m tcp --dport 22 -j ACCEPT
#for SMB/CIFS
-A INPUT -i wlan0 -p tcp -m tcp --dport 139 -j ACCEPT
-A INPUT -i wlan0 -p tcp -m tcp --dport 445 -j ACCEPT
#for transmission package
-A INPUT -i wlan0 -p tcp -m tcp --dport 4001 -j ACCEPT
-A INPUT -i wlan0 -p tcp -m tcp --dport 9091 -j ACCEPT
#for SMB/CIFS
-A INPUT -i wlan0 -p udp -m udp --dport 137 -j ACCEPT
-A INPUT -i wlan0 -p udp -m udp --dport 138 -j ACCEPT
#deny hacker scan
-A INPUT -p tcp --tcp-flags ALL NONE -j DROP
-A FORWARD -p tcp --tcp-flags ALL NONE -j DROP
-A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
-A FORWARD -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
-A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
-A FORWARD -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
-A INPUT -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
-A FORWARD -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
-A INPUT -p tcp --tcp-flags ACK,FIN FIN -j DROP
-A FORWARD -p tcp --tcp-flags ACK,FIN FIN -j DROP
-A INPUT -p tcp --tcp-flags ACK,URG URG -j DROP
-A FORWARD -p tcp --tcp-flags ACK,URG URG -j DROP
# icmp allow list
-A INPUT -p icmp --icmp-type 0 -j ACCEPT
-A INPUT -p icmp --icmp-type 3 -j ACCEPT
-A INPUT -p icmp --icmp-type 3/4 -j ACCEPT
-A INPUT -p icmp --icmp-type 4 -j ACCEPT
-A INPUT -p icmp --icmp-type 11 -j ACCEPT
-A INPUT -p icmp --icmp-type 12 -j ACCEPT
-A INPUT -p icmp --icmp-type 14 -j ACCEPT
-A INPUT -p icmp --icmp-type 16 -j ACCEPT
-A INPUT -p icmp --icmp-type 18 -j ACCEPT
COMMIT
     7.2.2 /etc/network/interfaces
        - modify dsl-provider section.
           auto dsl-provider
           iface dsl-provider inet ppp
           pre-up iptables-restore < /etc/firewall-rules
           provider dsl-provider

8. install transmission daemon & do basic setting.

BTW, I upgrade the kernel to 3.4.0 (from PPA) & upgrade the tiwlan-wl12xx-dkms, tiwlan-wl12xx-firmware to help wl1271 more stable.

Done...

星期一, 10月 15, 2012

Upgrade lucid to precise

1. boot.scr mmc init 2;fatload mmc 2 80200000 uImage;bootm 0x80200000 setenv bootargs console=ttyO2,115200n8 mem=512M@0x80000000 root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait mpurate=${mpurate} ethaddr=${ethaddr} omapdss.def_disp=dvi omapfb.mode=dvi:800x600MR-16@60 vram=4M --no-log ps: --no-log is workaround for "init: Failed to create pty - disabling logging for job"

2. apt sources.list modify /etc/apt/sources.list, replace lucid to precise

3. do dist-upgrade apt-get dist-upgrade -o APT::Immediate-Configure=false during dist-upgrade, some configuration file will be changed

4. mkdir lib/modules dir mkdir -p /lib/modules/2.6.37-gb0042ce touch /lib/modules/2.6.37-gb0042ce/modules.dep

5. remove old udev net rules rm /etc/udev/rules.d/70-persistent-net.rules

6. do backup tar cvpf gogobox-ubuntu-precise-20121015.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/mnt --exclude=/sys /

星期日, 3月 27, 2011

Ubuntu Backup/Restore

reference from: http://ubuntuforums.org/showthread.php?t=81311

1. Gen the Tar file:
tar cvpf sendai-backup.tar --exclude=/proc --exclude=/lost+found --exclude=/sendai-backup.tar --exclude=/mnt --exclude=/sys /

2. Restore the tar to target
tar xvpf sendai-backup.tar -C /

3. mkdir the exclude dir
mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys