目前分類:Ralink SDK (55)

瀏覽方式: 標題列表 簡短摘要
  • iptables -t nat -A PREROUTING -i eth3 -p tcp -m tcp --dport 8080 -j DNAT --to-destination 192.168.150.8:80
  • iptables -t nat -A POSTROUTING -s 192.168.150.0/24 -o eth3 -j MASQUERADE
  • iptables -t nat -A PREROUTING -d 211.72.17.18/32 -p tcp -m tcp --dport 8080 -j DNAT --to-destination 192.168.150.8:80
  • iptables -t nat -A POSTROUTING -s 192.168.150.0/24 -d 192.168.150.8/32 -p tcp --dport 80 -j MASQUERADE

Reference


台南小新 發表在 痞客邦 留言(0) 人氣()

makefile

# test variables
CROSS_COMPILE?=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-
ROMFSDIR?=${shell readlink -f ../../romfs}
all: makefile
        make -f Makefile
Makefile:
ifneq ("", "$(wildcard $@)")
        make -f Makefile $@
else
        AR=$(CROSS_COMPILE)ar CC=$(CROSS_COMPILE)gcc CXX=$(CROSS_COMPILE)g++ \
        LD= NM=$(CROSS_COMPILE)nm OBJCOPY=$(CROSS_COMPILE)objdump \
        RANLIB=$(CROSS_COMPILE)ranlib STRIP=$(CROSS_COMPILE)strip \
        ./configure --host=arm-linux --target=arm-linux --prefix=/usr \
                --without-shadow --disable-etc-default-login \
                --with-zlib=../../lib/zlib-1.2.3 --with-ssl-dir=../openssl-1.0.1f
endif
clean:
        make -f Makefile clean
        rm Makefile
romfs:
        $(ROMFSINST) scp /usr/bin/scp
        $(ROMFSINST) sftp /usr/bin/sftp
        $(ROMFSINST) sftp-server /usr/bin/sftp-server
        $(ROMFSINST) ssh /usr/bin/ssh
        $(ROMFSINST) ssh-add /usr/bin/ssh-add
        $(ROMFSINST) ssh-agent /usr/bin/ssh-agent
        $(ROMFSINST) sshd /usr/bin/sshd
        $(ROMFSINST) ssh-keygen /usr/bin/ssh-keygen
        $(ROMFSINST) ssh-keyscan /usr/bin/ssh-keyscan
        $(ROMFSINST) ssh-keysign /usr/bin/ssh-keysign
        $(ROMFSINST) ssh-pkcs11-helper /usr/bin/ssh-pkcs11-helper
        mkdir -p $(ROMFSDIR)/etc_ro/ssh
        $(ROMFSINST) ssh_config /etc_ro/ssh/ssh_config
        $(ROMFSINST) sshd_config /etc_ro/ssh/sshd_config
        $(ROMFSINST) ssh_host_rsa_key /etc_ro/ssh/ssh_host_rsa_key
        $(ROMFSINST) ssh_host_ecdsa_key /etc_ro/ssh/ssh_host_ecdsa_key
        $(ROMFSINST) ssh_host_ed25519_key /etc_ro/ssh/ssh_host_ed25519_key

Generate key

  • ssh-keygen -t rsa -f ssh_host_rsa_key -N ""
  • ssh-keygen -t ecdsa -f ssh_host_ecdsa_key -N ""
  • ssh-keygen -t dsa -f ssh_host_ed25519_key -N ""

sshd_config

  • 使用原本的 sshd_config 加上下列修改的地方,其它使用預設值即可。
  • HostKey /etc_ro/ssh/ssh_host_rsa_key
  • HostKey /etc_ro/ssh/ssh_host_ecdsa_key
  • HostKey /etc_ro/ssh/ssh_host_ed25519_key
  • PermitRootLogin yes

Run

  • echo "sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin" >> /etc/passwd
  • mkdir -p /var/empty
  • touch /var/log/lastlog
  • /sbin/sshd -E /var/log/sshd.log -f /etc_ro/ssh/sshd_config

.gitignore

Makefile
buildpkg.sh
config.h
-config.h.in
+config.log
config.status
-configure
openbsd-compat/Makefile
openbsd-compat/regress/Makefile
openssh.xml
opensshd.init
survey.sh

Debug

  • /opt/buildroot-gcc483_arm/usr/bin/arm-linux-ld -o ssh ssh.o readconf.o clientloop.o sshtty.o sshconnect.o sshconnect2.o mux.o -L. -Lopenbsd-compat/ -L/home/enos/workspace/amr1000/source/user/openssh-7.7p1/../openssl-1.0.1f/lib -L../../lib/zlib-1.2.3 -Wl,--fatal-warnings -L/home/enos/workspace/amr1000/source/uClibc-0.9.33.2/lib -L/home/enos/workspace/amr1000/source/lib/lib -Wl,--fatal-warnings -L/home/enos/workspace/amr1000/source/uClibc-0.9.33.2/lib -L/home/enos/workspace/amr1000/source/lib/lib -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack  -lssh -lopenbsd-compat  -lcrypto -ldl -lutil -lz  -lcrypt 
    /opt/buildroot-gcc483_arm/usr/bin/arm-linux-ld: unrecognized option '-Wl,--fatal-warnings'
    /opt/buildroot-gcc483_arm/usr/bin/arm-linux-ld: use the --help option for usage information
    make[4]: *** [ssh] Error 1
    make[4]: Leaving directory `/home/enos/workspace/amr1000/source/user/openssh-7.7p1'
    make[3]: *** [all] Error 2
    make[3]: Leaving directory `/home/enos/workspace/amr1000/source/user/openssh-7.7p1'
    make[2]: *** [openssh-7.7p1] Error 2
    make[2]: Leaving directory `/home/enos/workspace/amr1000/source/user'
    make[1]: *** [all] Error 2
    make[1]: Leaving directory `/home/enos/workspace/amr1000/source/user'
    make: *** [user_only] Error 2
    
    arm-linux-ld 有問題,不知問題在那裏,設定 LD=,直接使用 arm-linux-gcc 就沒問題了。
  • /opt/buildroot-gcc483_arm/usr/bin/arm-linux-gcc -o sshd sshd.o auth-rhosts.o auth-passwd.o audit.o audit-bsm.o audit-linux.o platform.o sshpty.o sshlogin.o servconf.o serverloop.o auth.o auth2.o auth-options.o session.o auth2-chall.o groupaccess.o auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o auth2-none.o auth2-passwd.o auth2-pubkey.o monitor.o monitor_wrap.o auth-krb5.o auth2-gss.o gss-serv.o gss-serv-krb5.o loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o sftp-server.o sftp-common.o sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o sandbox-seccomp-filter.o sandbox-capsicum.o sandbox-pledge.o sandbox-solaris.o -L. -Lopenbsd-compat/ -L/home/enos/workspace/amr1000/source/user/openssh-7.7p1/../openssl-1.0.1f/lib -L../../lib/zlib-1.2.3 -Wl,--fatal-warnings -L/home/enos/workspace/amr1000/source/uClibc-0.9.33.2/lib -L/home/enos/workspace/amr1000/source/lib/lib -Wl,--fatal-warnings -L/home/enos/workspace/amr1000/source/uClibc-0.9.33.2/lib -L/home/enos/workspace/amr1000/source/lib/lib -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack  -lssh -lopenbsd-compat  -lcrypto -ldl -lutil -lz  -lcrypt  
    auth.o: In function `allowed_user':
    auth.c:(.text+0xd18): undefined reference to `getspnam'
    auth-shadow.o: In function `auth_shadow_pwexpired':
    auth-shadow.c:(.text+0x138): undefined reference to `getspnam'
    openbsd-compat//libopenbsd-compat.a(xcrypt.o): In function `xcrypt':
    xcrypt.c:(.text+0x58): undefined reference to `getspnam'
    openbsd-compat//libopenbsd-compat.a(xcrypt.o): In function `shadow_pw':
    xcrypt.c:(.text+0xd8): undefined reference to `getspnam'
    collect2: error: ld returned 1 exit status
    make[4]: *** [sshd] Error 1
    make[4]: Leaving directory `/home/enos/workspace/amr1000/source/user/openssh-7.7p1'
    make[3]: *** [all] Error 2
    make[3]: Leaving directory `/home/enos/workspace/amr1000/source/user/openssh-7.7p1'
    make[2]: *** [openssh-7.7p1] Error 2
    make[2]: Leaving directory `/home/enos/workspace/amr1000/source/user'
    make[1]: *** [all] Error 2
    make[1]: Leaving directory `/home/enos/workspace/amr1000/source/user'
    make: *** [user_only] Error 2
    
    SDK 沒有支援 shadow password,設定 --without-shadow 就可以了。
  • # ssh manager@127.0.0.1
    manager@127.0.0.1's password:
    Permission denied, please try again.
    manager@127.0.0.1's password:
    Permission denied, please try again.
    manager@127.0.0.1's password:
    manager@127.0.0.1: Permission denied (publickey,password,keyboard-interactive).
    
    這是因為 root group 權限沒開,在 sshd_config 加上 PermitRootLogin yes 即可。
  • /opt/buildroot-gcc483_arm/usr/bin/arm-linux-gcc -O2 -fomit-frame-pointer -pipe  -Dlinux -D__linux__ -Dunix -DEMBED -I/home/enos/workspace/amr1000/source/uClibc-0.9.33.2/app_headers/include -I/home/enos/workspace/amr1000/source/lib/include -DCONFIG_UCLIBC_0_9_33_2 -mcpu=cortex-a7 -I/home/enos/workspace/amr1000/source  -pipe -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset   -I. -I.. -I. -I./.. -I/home/enos/workspace/amr1000/source/user/openssh-7.7p1/../openssl-1.0.1f/include -I../../lib/zlib-1.2.3  -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE -DHAVE_CONFIG_H -c bsd-nextstep.c
    In file included from /home/enos/workspace/amr1000/source/uClibc-0.9.33.2/app_headers/include/rpc/types.h:61:0,
                     from ../includes.h:115,
                     from bsd-nextstep.c:25:
    /home/enos/workspace/amr1000/source/uClibc-0.9.33.2/app_headers/include/stdlib.h:470:1: warning: ‘rpl_malloc’ attribute directive ignored [-Wattributes]
     extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
     ^
    /home/enos/workspace/amr1000/source/uClibc-0.9.33.2/app_headers/include/stdlib.h:475:6: warning: ‘rpl_malloc’ attribute directive ignored [-Wattributes]
          __THROW __attribute_malloc__ __wur;
          ^
    In file included from /home/enos/workspace/amr1000/source/uClibc-0.9.33.2/app_headers/include/rpc/types.h:61:0,
                     from ../includes.h:115,
                     from bsd-nextstep.c:25:
    /home/enos/workspace/amr1000/source/uClibc-0.9.33.2/app_headers/include/stdlib.h:503:1: warning: ‘rpl_malloc’ attribute directive ignored [-Wattributes]
     extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur;
     ^
    In file included from /home/enos/workspace/amr1000/source/uClibc-0.9.33.2/app_headers/include/resolv.h:64:0,
                     from ../openbsd-compat/getrrsetbyname.h:59,
                     from ../openbsd-compat/openbsd-compat.h:44,
                     from ../includes.h:174,
                     from bsd-nextstep.c:25:
    /home/enos/workspace/amr1000/source/uClibc-0.9.33.2/app_headers/include/stdio.h:197:6: warning: ‘rpl_malloc’ attribute directive ignored [-Wattributes]
          __THROW __attribute_malloc__ __wur;
          ^
    
    只要在 configure 前面加上 ac_cv_func_malloc_0_nonnull=yes 即可,但是卻會產生另一個問題 xrecallocarray: out of memory,要修改 channels.c 的 channel_clear_adm_permitted_opens 及 channel_clear_permitted_opens。所以就不要理它了。

Reference


台南小新 發表在 痞客邦 留言(0) 人氣()


台南小新 發表在 痞客邦 留言(0) 人氣()

修改 Makefile

@@ -53,7 +53,7 @@
 # but we use a local copy if we don't find it.
 #
 #KERNELSRC=/lib/modules/`uname -r`/build/
-KERNELSRC?=./linux
+KERNELSRC=$(ROOTDIR)/$(LINUXDIR)
 OSFLAGS?= -DLINUX -I$(KERNELSRC)/include/
 #
 # Uncomment the following to use the kernel interface under Linux
@@ -112,7 +112,7 @@
 MANDIR?=$(DESTDIR)${PREFIX}/share/man
 
 
-all: $(EXEC) pfc $(CONTROL_EXEC)
+all: $(EXEC)
 
 clean:
        rm -f $(OBJS) $(EXEC) pfc.o pfc $(CONTROL_EXEC)
  • 修正 KERNELSRC 目錄位置
  • 移除 pfc 及 xl2tpd-control,因為用不到,這樣就可以不用 libpcap。

台南小新 發表在 痞客邦 留言(0) 人氣()

@@ -22,7 +22,7 @@ server.modules              = (
 ##                              "mod_trigger_b4_dl",
                                 "mod_auth",
 #                               "mod_status",
-##                              "mod_setenv",
+                                "mod_setenv",
 ##                              "mod_fastcgi",
 ##                              "mod_proxy",
 ##                              "mod_simple_vhost",
@@ -368,3 +368,9 @@ ssi.extension              = ( ".shtml" )
 ## the above is same as:
 #var.a=1
 
+$HTTP["url"] != "" {
+  setenv.add-response-header = ( "Cache-Control" => "no-store, no-cache, must-revalidate, post-check=0, pre-check=0" )
+  etag.use-inode = "disable"
+  etag.use-mtime = "disable"
+  etag.use-size = "disable"
+}

台南小新 發表在 痞客邦 留言(0) 人氣()

--- a/source/vendors/Mediatek/MT7623/config/256M_256M_config.uclibc0933-3.10.20.x
+++ b/source/vendors/Mediatek/MT7623/config/256M_256M_config.uclibc0933-3.10.20.x
@@ -145,7 +145,8 @@ UCLIBC_HAS_IPV6=y
 UCLIBC_HAS_RPC=y
 UCLIBC_HAS_FULL_RPC=y
 # UCLIBC_HAS_REENTRANT_RPC is not set
-# UCLIBC_USE_NETLINK is not set
+UCLIBC_USE_NETLINK=y
+UCLIBC_SUPPORT_AI_ADDRCONFIG=y
 UCLIBC_HAS_BSD_RES_CLOSE=y
 UCLIBC_HAS_COMPAT_RES_STATE=y
 UCLIBC_HAS_EXTRA_COMPAT_RES_STATE=y

--- a/source/uClibc-0.9.33.2/libc/inet/ifaddrs.c
+++ b/source/uClibc-0.9.33.2/libc/inet/ifaddrs.c
@@ -37,6 +37,8 @@
 #include 
 #include 
 
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
 #include "netlinkaccess.h"

--- a/source/uClibc-0.9.33.2/libc/inet/if_index.c
+++ b/source/uClibc-0.9.33.2/libc/inet/if_index.c
@@ -34,6 +34,8 @@
 #include 
 #include 
 
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
 #include "netlinkaccess.h"

台南小新 發表在 痞客邦 留言(0) 人氣()

modify Makefile.linux

@@ -20,6 +21,7 @@
 # installed, you need to get iptables sources from http://netfilter.org/
 # ./configure them and build them then miniupnpd will build using :
 # $ IPTABLESPATH=/path/to/iptables-1.4.1 make -f Makefile.linux
+IPTABLESPATH=$(ROOTDIR)/user/iptables-1.4.21
 #
 #CFLAGS = -O -g -DDEBUG
 CFLAGS ?= -Os

enable IPv6

@@ -7,6 +7,7 @@
 #
 # options can be passed to genconfig.sh through CONFIG_OPTIONS :
 # $ CONFIG_OPTIONS="--ipv6 --igd2" make -f Makefile.linux
+CONFIG_OPTIONS=--ipv6
 #
 # To install use :
 # $ DESTDIR=/dummyinstalldir make -f Makefile.linux install
@@ -107,6 +109,7 @@
 CPPFLAGS := $(CPPFLAGS) -DIPTABLES_143
 # the following sucks, but works
 LDLIBS = $(IPTABLESPATH)/libiptc/.libs/libip4tc.o
+LDLIBS += $(IPTABLESPATH)/libiptc/.libs/libip6tc.o
 #LDLIBS = $(IPTABLESPATH)/libiptc/.libs/libiptc.a
 else # ifeq ($(TEST), 1)
 LDLIBS = $(IPTABLESPATH)/libiptc/libiptc.a

修改 genconfig.sh,開啟 IPv6 時會需要 getifaddrs(),所以 USE_GETIFADDRS 同時也要開啟。

@@ -502,6 +502,7 @@
 echo "/* Enable IP v6 support */" >> ${CONFIGFILE}
 if [ -n "$IPV6" ]; then
        echo "#define ENABLE_IPV6" >> ${CONFIGFILE}
+       echo "#define USE_GETIFADDRS" >> ${CONFIGFILE}
 else
        echo "/*#define ENABLE_IPV6*/" >> ${CONFIGFILE}
 fi

modify upnpdescstrings.h

#define ROOTDEV_FRIENDLYNAME          OS_NAME " router"
#define ROOTDEV_MANUFACTURER            OS_NAME
#define ROOTDEV_MANUFACTURERURL         OS_URL
#define ROOTDEV_MODELNAME                       OS_NAME " router"
#define ROOTDEV_MODELDESCRIPTION        OS_NAME " router"
#define ROOTDEV_MODELURL                        OS_URL

enable configuration of manufacturer info

@@ -7,6 +7,7 @@
 #
 # options can be passed to genconfig.sh through CONFIG_OPTIONS :
 # $ CONFIG_OPTIONS="--ipv6 --igd2" make -f Makefile.linux
+CONFIG_OPTIONS=--vendorcfg
 #
 # To install use :
 # $ DESTDIR=/dummyinstalldir make -f Makefile.linux install

/etc/miniupnpd.conf

  • 等號後面不可以加雙引號。
  • serial: 沒有則後面空白。
  • uuid: 讀取 /proc/sys/kernel/random/uuid。
  • ext_ifname: WAN_IF
  • listening_ip: LAN_IF
  • enable_upnp: 開啟 upnp
friendly_name=
manufacturer_name=
manufacturer_url=
model_name=
model_description=
model_url=
uuid=
serial=
model_number=

Debug

  • miniupnpd -d & 可以顯示更多訊息
  • miniupnpd 直接跑 daemon,訊息比較少。

bugs

/opt/buildroot-gcc483_arm/usr/bin/arm-linux-gcc -mcpu=cortex-a7 -O2 -fomit-frame-pointer -pipe  -Dlinux -D__linux__ -Dunix -DEMBED -I/home/enos/workspace/fgn1300/source/uClibc-0.9.33.2/app_headers/include -I/home/enos/workspace/fgn1300/source/lib/include -DCONFIG_UCLIBC_0_9_33_2 -mcpu=cortex-a7 -I/home/enos/workspace/fgn1300/source  -fno-strict-aliasing -fno-common -Wall -Wextra -Wstrict-prototypes -Wdeclaration-after-statement -D_GNU_SOURCE  -c -o netfilter/iptcrdr.o netfilter/iptcrdr.c
Package libssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libssl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libssl' found
netfilter/iptcrdr.c:16:21: fatal error: xtables.h: No such file or directory
 #include 
                     ^
compilation terminated.
make[3]: *** [netfilter/iptcrdr.o] Error 1
make[3]: Leaving directory `/home/enos/workspace/fgn1300/source/user/miniupnpd-2.0.20180412'
make[2]: *** [miniupnpd-2.0.20180412] Error 2
make[2]: Leaving directory `/home/enos/workspace/fgn1300/source/user'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/enos/workspace/fgn1300/source/user'
make: *** [user_only] Error 2

modify Makefile.linux, add IPTABLESPATH.

台南小新 發表在 痞客邦 留言(0) 人氣()

server.bind = "[::]"

只要新增這一行就可以同時使用 IPv6 及 IPv4。

Reference


台南小新 發表在 痞客邦 留言(0) 人氣()

cat /proc/sys/net/nf_conntrack_max

Reference


台南小新 發表在 痞客邦 留言(0) 人氣()

  • stateful packet inspection,SPI
  • Stateful firewall,狀態防火牆

IPv4

  • iptables -A INPUT -i lo -j ACCEPT
  • iptables -A INPUT -i br0 -j ACCEPT
  • iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
  • iptables -A FORWARD -i br0 -j ACCEPT
  • iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
  • iptables -P INPUT DROP
  • iptables -P OUTPUT ACCEPT
  • iptables -P FORWARD DROP

IPv6

  • ip6tables -A INPUT -i lo -j ACCEPT
  • ip6tables -A INPUT -i br0 -j ACCEPT
  • ip6tables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
  • ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT
  • ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT
  • ip6tables -A FORWARD -i br0 -j ACCEPT
  • ip6tables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
  • ip6tables -P INPUT DROP
  • ip6tables -P OUTPUT ACCEPT
  • ip6tables -P FORWARD DROP

封包狀態

  • NEW:一個新的連線封包 (建立新連線後的第一個封包)
  • ESTABLISHED:成功建立的連線,即建立追蹤連線後所有封包狀態 (跟在 NEW 封包後面的所有封包)
  • RELATED:新建連線,由 ESTABLISHED session 所建立的新獨立連線 (ex. ftp-data 連線)
  • INVALID:非法連線狀態的封包 (DROP 封包)
  • UNKOWN:不明連線狀態的封包

Reference


台南小新 發表在 痞客邦 留言(0) 人氣()


台南小新 發表在 痞客邦 留言(0) 人氣()

modify Makefile

  • all: ndppd
    #all: ndppd ndppd.1.gz ndppd.conf.5.gz
    
    只需要執行檔,其它不用。
  •  ${CXX} -o ndppd ${LDFLAGS} ${LIBS} ${OBJS} -L$(ROOTDIR)/uClibc++-0.2.4/src -luClibc++ -static
    #       ${CXX} -o ndppd ${LDFLAGS} ${LIBS} ${OBJS}
    
    原廠的路徑有問題,而且沒包含 -luClibc++ 會造成 undefined reference to `std::vector 的錯誤。加上 static 就不會出現 ndppd: can't load library 'libstdc++.so.6' 錯誤。
  • romfs:
            $(ROMFSINST) /sbin/ndppd
    
    安裝位置。

Reference


台南小新 發表在 痞客邦 留言(0) 人氣()

make[4]: Entering directory `/home/enos/workspace/fgn1300/source/user/iptables-1.4.21'
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /home/enos/workspace/fgn1300/source/user/iptables-1.4.21/build-aux/missing --run aclocal-1.11 -I m4
/home/enos/workspace/fgn1300/source/user/iptables-1.4.21/build-aux/missing: line 52: aclocal-1.11: command not found
WARNING: `aclocal-1.11' is missing on your system.  You should only need it if
         you modified `acinclude.m4' or `configure.ac'.  You might want
         to install the `Automake' and `Perl' packages.  Grab them from
         any GNU archive site.
 cd . && /bin/sh /home/enos/workspace/fgn1300/source/user/iptables-1.4.21/build-aux/missing --run automake-1.11 --foreign
/home/enos/workspace/fgn1300/source/user/iptables-1.4.21/build-aux/missing: line 52: automake-1.11: command not found
WARNING: `automake-1.11' is missing on your system.  You should only need it if
         you modified `Makefile.am', `acinclude.m4' or `configure.ac'.
         You might want to install the `Automake' and `Perl' packages.
         Grab them from any GNU archive site.
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /home/enos/workspace/fgn1300/source/user/iptables-1.4.21/build-aux/missing --run autoconf
configure.ac:12: error: possibly undefined macro: AM_INIT_AUTOMAKE
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:14: error: possibly undefined macro: AM_PROG_CC_C_O
configure.ac:15: error: possibly undefined macro: AC_DISABLE_STATIC
configure.ac:17: error: possibly undefined macro: AM_PROG_LIBTOOL
configure.ac:90: error: possibly undefined macro: AM_CONDITIONAL
make[4]: *** [configure] Error 1
make[4]: Leaving directory `/home/enos/workspace/fgn1300/source/user/iptables-1.4.21'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/enos/workspace/fgn1300/source/user/iptables-1.4.21'
make[2]: *** [iptables-1.4.21] Error 2
make[2]: Leaving directory `/home/enos/workspace/fgn1300/source/user'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/enos/workspace/fgn1300/source/user'
make: *** [user_only] Error 2
解決方法:sudo apt-get install automake

台南小新 發表在 痞客邦 留言(0) 人氣()

修改 Makefile

  • CFLAGS:=-Wall -Wunused -Werror 改成 CFLAGS+=-Wall -Wunused
  • CC:=gcc 移除
  • KERNEL_INCLUDES?=include/ 改成 KERNEL_INCLUDES?=$(ROOTDIR)/$(LINUXDIR)/include/

Bugs

In file included from /home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/linux/preempt.h:9:0,
                 from /home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/linux/spinlock.h:50,
                 from /home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/linux/mm_types.h:8,
                 from /home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/linux/kmemcheck.h:4,
                 from /home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/linux/skbuff.h:18,
                 from /home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/linux/netfilter.h:5,
                 from /home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/uapi/linux/netfilter_bridge.h:7,
                 from /home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/linux/netfilter_bridge.h:4,
                 from /home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/uapi/linux/netfilter_bridge/ebtables.h:16,
                 from /home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/linux/netfilter_bridge/ebtables.h:15,
                 from include/ebtables_u.h:27,
                 from communication.c:23:
/home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/linux/thread_info.h:13:1: warning: empty declaration [enabled by default]
 struct timespec;
 ^
/home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/linux/thread_info.h:14:1: warning: empty declaration [enabled by default]
 struct compat_timespec;
 ^
/home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/linux/thread_info.h:19:1: warning: empty declaration [enabled by default]
 struct restart_block {
 ^
/home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/linux/thread_info.h:51:13: error: storage class specified for parameter ‘do_no_restart_syscall’
 extern long do_no_restart_syscall(struct restart_block *parm);
             ^
/home/enos/workspace/fgn1300/source/linux-3.10.20.x/include/linux/thread_info.h:54:29: fatal error: asm/thread_info.h: No such file or directory
 #include 
                             ^
compilation terminated.
make[3]: *** [communication.o] Error 1
make[2]: *** [ebtables-v2.0.10-4] Error 2
make[1]: *** [all] Error 2
make: *** [user_only] Error 2

這是因為 CFLAGS 少了一些參數,把 CFLAGS:= 改成 CFLAGS+=,這樣會繼承從 top makefile 傳來的參數,這樣就不會出錯了。

Reference


台南小新 發表在 痞客邦 留言(0) 人氣()

Building

  • export PATH=$PATH:/opt/buildroot-gcc483_arm/usr/bin
  • ./configure --host=arm-linux --target=arm-linux --prefix=/usr
  • make
  • make install DESTDIR=~/workspace/project/source/romfs

Reference

makefile

# test variables
CROSS_COMPILE?=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-
ROMFSDIR?=${shell readlink -f ../../romfs}

all: Makefile
        make -f Makefile

Makefile:
        AS= AR=$(CROSS_COMPILE)ar CC=$(CROSS_COMPILE)gcc CXX=$(CROSS_COMPILE)g++ \
        NM=$(CROSS_COMPILE)nm LD=$(CROSS_COMPILE)ld OBJCOPY=$(CROSS_COMPILE)objdump \
        RANLIB=$(CROSS_COMPILE)ranlib STRIP=$(CROSS_COMPILE)strip \
        ./configure --host=arm-linux --target=arm-linux --prefix=/usr  --enable-static=yes

all-recursive:
        make -f Makefile all-recursive

all-am:
        make -f Makefile all-am

install:
        make -f Makefile install

install-am:
        make -f Makefile install-am

install-exec-am:
        make -f Makefile install-exec-am

install-data-am:
        make -f Makefile install-data-am

clean:
        make -f Makefile clean
        rm Makefile

clean-am:
        make -f Makefile clean-am

clean-recursive:
        make -f Makefile clean-recursive

romfs:
        make -f Makefile install DESTDIR=${ROMFSDIR}
        rm -rf ${ROMFSDIR}/usr/include
        rm -rf ${ROMFSDIR}/usr/lib/pkgconfig
        rm -rf ${ROMFSDIR}/usr/share

台南小新 發表在 痞客邦 留言(0) 人氣()

  • [*] Networking support --->
  •   Network options --->
  •     [*] Network packet filtering framework (Netfilter) --->
  •       Core Netfilter Configuration --->
  •         [*] Supply CT list in procfs (OBSOLETE)
  •       IP: Netfilter Configuration --->
  •         [*] IPv4 connection tracking support (required for NAT)
  •         [*]   proc/sysctl compatibility with old connection tracking

台南小新 發表在 痞客邦 留言(0) 人氣()

# iptables -L -n -v
iptables v1.4.10: can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
  • [*] Networking support --->
  •   Network options --->
  •     [*] Network packet filtering framework (Netfilter) --->
  •       IP: Netfilter Configuration --->
  •         [*] IP tables support (required for filtering/masq/NAT)
  •         [*]   Packet filtering

台南小新 發表在 痞客邦 留言(0) 人氣()

  • busybox init 讀取 /etc_ro/inittab 根據 ::sysinit:/etc_ro/rcS 去執行 /etc_ro/rcS
  • /etc_ro/rcS 會執行 init_system start 做初始化
  • init_system 第一個執行 internet.sh

firewall

  • (0)init_system start
  • (1)init_internet()
  • (2)do_system("internet.sh")
  • (3)ralink_init make_wireless_config rt2860 (寫參數檔)
  • (3)ralink_init make_wireless_config rtdev
  • (3)ralink_init make_wireless_config wifi3
  • (3)insmod -q mt_wifi
  • (2)do_system("/etc_ro/lighttpd/www/cgi-bin/wireless.cgi init")

firewall

  • (0)init_system start
  • (1)init_internet()
  • (2)do_system("/etc_ro/lighttpd/www/cgi-bin/firewall.cgi init")
  • (3)firewall_init()
  • (4)iptablesAllFilterClear()
  • (4)iptablesAllFilterRun()
  • (5)iptablesIPPortFilterRun()
  • (5)iptablesMACFilterRun(): filter(mac_filter)
  • (5)iptablesWebsFilterRun()
  • (5)iptablesRemoteManagementRun()
  • (5)iptablesMaliciousFilterRun()
  • (4)iptablesAllNATClear()
  • (4)iptablesAllNATRun()

nvram_daemon

  • signal(SIGTSTP, dhcpcHandler)
  • killall -SIGTSTP nvram_daemon
  • system("/etc_ro/lighttpd/www/cgi-bin/firewall.cgi init")

台南小新 發表在 痞客邦 留言(0) 人氣()

  • libpcap download: http://www.tcpdump.org/release/libpcap-1.8.1.tar.gz
  • tar zxvf libpcap-1.8.1.tar.gz -C source/lib
  • modify source/lib/Makefile
    --- Makefile.bak      2018-01-25 15:33:57.342892926 +0800
    +++ Makefile    2018-01-25 15:34:02.125887255 +0800
    @@ -101,7 +101,7 @@
         DIRS += libjpeg-turbo-1.4.0
     endif
     ifeq ($(CONFIG_LIB_LIBPCAP_FORCE),y)
    -    DIRS += libpcap-1.0.0
    +    DIRS += libpcap-1.8.1
     endif
     ifeq ($(CONFIG_LIB_LIBEVENT_FORCE),y)
          DIRS += libevent-2.0.2-alpha
    @@ -236,7 +236,7 @@
            @$(MAKE) -C libjpeg shared
     endif
     ifeq ($(CONFIG_LIB_LIBPCAP_FORCE),y)
    -       @$(MAKE) -C libpcap-1.0.0 shared
    +       @$(MAKE) -C libpcap-1.8.1 shared
     endif
     ifeq ($(CONFIG_LIB_LIBJPEG_TURBO_FORCE),y)
            @$(MAKE) -C libjpeg-turbo-1.4.0 shared
    @@ -651,7 +651,7 @@
            @$(MAKE) -C libjpeg-turbo-1.4.0 clean
     endif
     ifeq ($(CONFIG_LIB_LIBPCAP_FORCE),y)
    -       $(MAKE) -C libpcap-1.0.0 clean
    +       $(MAKE) -C libpcap-1.8.1 clean
     endif
     ifeq ($(CONFIG_LIB_LIBEVENT_FORCE),y)
            $(MAKE) -C libevent-2.0.2-alpha clean
    
  • cp source/lib/libpcap-1.0.0/makefile source/lib/libpcap-1.8.1
  • modify source/lib/libpcap-1.8.1/makefile
--- libpcap-1.0.0/makefile    2017-03-31 14:34:27.000000000 +0800
+++ libpcap-1.8.1/makefile      2018-01-25 15:25:59.634900545 +0800
@@ -1,7 +1,7 @@
 TOPDIR=../
 include $(TOPDIR)Rules.mak
 
-CONFOPTS= --host=mipsel-linux --with-pcap
+CONFOPTS= --host=arm-linux --with-pcap=linux
 
 LIB_LDFLAGS := $(subst -z defs,,$(LDFLAGS))

台南小新 發表在 痞客邦 留言(0) 人氣()


台南小新 發表在 痞客邦 留言(0) 人氣()

1 23