2018年12月12日 星期三
Debian rootfs for Arm64
https://wiki.debian.org/Arm64Port
sudo qemu-debootstrap --arch=arm64 --keyring /usr/share/keyrings/debian-archive-keyring.gpg --variant=buildd --exclude=debfoster stretch debian-arm64
http://ftp.debian.org/debian
2018年12月10日 星期一
Ubuntu rootfs howto
1. Preparing the packages in host
sudo apt-get install debootstrap qemu-user-static
2. Download the packages for ubuntu rootfs
debootstrap_dir=ubuntu-arm64-bonic
sudo debootstrap --arch arm64 --foreign bionic "$debootstrap_dir" \
http://ports.ubuntu.com/ubuntu-ports \
3. Install the packages/ second-stage
sudo mkdir -p "${debootstrap_dir}/usr/bin"
sudo cp "$(which qemu-aarch64-static)" "${debootstrap_dir}/usr/bin"
sudo chroot "$debootstrap_dir" /debootstrap/debootstrap --second-stage
4. Remove the passwd of root
sudo chroot "$debootstrap_dir"
Edit /etc/passwd and /etc/shadow, remove the "*" in between ":" and ":" in root:....
5. Enable UART console
sudo chroot ${debootstrap_dir}
ln -sf /lib/systemd/system/serial-getty\@.service /lib/systemd/system/getty.target.wants/
6. /etc/network/interfaces
sudo apt install ifupdown
vi /etc/network/interface
-----
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
# The intranet network interface
auto eth1
iface eth1 inet static
address 10.19.132.49
netmask 255.255.254.0
7. Add locale
sudo vi /etc/locale.gen
umakrk en_US.UTF-8 UTF-8 and zh_TW.UTF-8 UTF-8
sudo locale-gen
source.list
==================================================
deb http://tw.ports.ubuntu.com/ bionic main restricted universe multiverse
deb http://tw.ports.ubuntu.com/ bionic-updates main restricted universe multiverse
deb http://tw.ports.ubuntu.com/ubuntu-ports bionic main restricted
deb http://tw.ports.ubuntu.com/ubuntu-ports bionic-updates main restricted
deb-src http://tw.ports.ubuntu.com/ubuntu-ports bionic main restricted universe multiverse
deb-src http://tw.ports.ubuntu.com/ubuntu-ports bionic-updates main restricted universe multiverse
deb http://tw.ports.ubuntu.com/ubuntu-ports bionic universe
deb http://tw.ports.ubuntu.com/ubuntu-ports bionic-updates universe
deb http://tw.ports.ubuntu.com/ubuntu-ports bionic multiverse
deb http://tw.ports.ubuntu.com/ubuntu-ports bionic-updates multiverse
deb http://tw.ports.ubuntu.com/ bionic-security main restricted universe multiverse
SNAT
================================
echo "Setting IP Masquerading...."
echo 1 > /proc/sys/net/ipv4/ip_forward
WAN_IP=`ifconfig eth0 | grep "inet addr:" | cut -d ":" -f 2 | cut -d " " -f 1`
echo "Setting iptables..... "
/sbin/iptables -F
/sbin/iptables -t nat -F
/sbin/iptables -P FORWARD DROP
# Block access to 208.46.65.0/24
/sbin/iptables -A OUTPUT -d 208.48.65.0/24 -j DROP
/sbin/iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
/sbin/iptables -A FORWARD -d 192.168.0.0/24 -j ACCEPT
/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to-source ${WAN_IP}
#172.23.68.32
/sbin/iptables -A FORWARD -s 172.23.68.32 -j ACCEPT
/sbin/iptables -A FORWARD -d 172.23.68.32 -j ACCEPT
/sbin/iptables -t nat -A POSTROUTING -s 172.23.68.32 -j SNAT --to-source ${WAN_IP}
Route table
============================
ip route add 10.0.0.0/8 via 10.19.132.1
ip route del default
ip route add default via 10.19.132.49(Z2X)
rc.local
=============
ln -fs /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service
touch /etc/rc.local
chmod 755 /etc/rc.local
EDIT /etc/rc.local
-----
#!/bin/bash
echo "test rc " > /var/test.log
exit 0
2011年9月26日 星期一
修改 MSS 解決 Linux PPPOE NAT 後部份網頁無法瀏覽問題
引用自
http://ppc52776.blogspot.com/2011/04/mss-linux-pppoe-nat.html
參考資料 http://www.akadia.com/services/pppoe_iptables.html
--------------------------
有用 Linux 當作家裡 ADSL 分享器/防火牆 的人應該會發現
有些網頁透過 NAT 後就是無法開啟
但是如果直接在 Linux 主機上卻又可以正常開啟
解決方法:
在 Linux Firewall 上增加以下 rule:
搞定
為什麼呢?
這主要原因是因為 ppp 網路的 MTU 問題
MTU 的功能在於指定最大可傳輸的單一封包大小
當使用 ADSL(PPP) 時
會再封包裡另外增加 PPP 的 Header 導致單一封包會超過上限
為了解決此問題
一般會把 PPP 的 MTU 設定為原本 Ethernet MTU - 8 也就是 1492
TCP 傳輸方式有自動切割與組合封包的特性
MTU 的值就會被拿來當作 TCP 預設切割的大小(MSS)
MSS = Maximum Segment Size
每次建立 TCP 連線時
雙方會於 handshaking 時互相告知對方允許的 MSS 最後以小的為主
但 NAT 後的 PC 看到的是自己的 MTU 也就是 1500 而非 1492
因此會給對方過大的 MSS 建議
正常來說~當路由器收到大於自己可處理最大封包時
會透過 ICMP 回應給 sender
sender 接下來就會嘗試較小的 MSS
但大多數 ISP 會擋掉 ICMP 導致 sender 傻傻一直等待直到 timeout...
參考資料 http://www.akadia.com/services/pppoe_iptables.html
--------------------------
有用 Linux 當作家裡 ADSL 分享器/防火牆 的人應該會發現
有些網頁透過 NAT 後就是無法開啟
但是如果直接在 Linux 主機上卻又可以正常開啟
解決方法:
在 Linux Firewall 上增加以下 rule:
iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
搞定
為什麼呢?
這主要原因是因為 ppp 網路的 MTU 問題
MTU 的功能在於指定最大可傳輸的單一封包大小
當使用 ADSL(PPP) 時
會再封包裡另外增加 PPP 的 Header 導致單一封包會超過上限
為了解決此問題
一般會把 PPP 的 MTU 設定為原本 Ethernet MTU - 8 也就是 1492
TCP 傳輸方式有自動切割與組合封包的特性
MTU 的值就會被拿來當作 TCP 預設切割的大小(MSS)
MSS = Maximum Segment Size
每次建立 TCP 連線時
雙方會於 handshaking 時互相告知對方允許的 MSS 最後以小的為主
但 NAT 後的 PC 看到的是自己的 MTU 也就是 1500 而非 1492
因此會給對方過大的 MSS 建議
正常來說~當路由器收到大於自己可處理最大封包時
會透過 ICMP 回應給 sender
sender 接下來就會嘗試較小的 MSS
但大多數 ISP 會擋掉 ICMP 導致 sender 傻傻一直等待直到 timeout...
2011年8月30日 星期二
2011年1月2日 星期日
VCD 2 avi
mencoder vcd://2 -ovc xvid -xvidencopts vhq=2:bvhq=1:chroma_opt:quant_type=mpeg:bitrate=200:interlacing -oac mp3lame -lameopts br=96:cbr:mode=3 -ffourcc xvid -o /tmp/倉頡造字1.avi
2010年11月29日 星期一
SNAT 的設定方式
echo "Setting IP Masquerading and HD parameters...."
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "Setting iptables..... "
/sbin/iptables -F
/sbin/iptables -t nat -F
/sbin/iptables -P FORWARD DROP
# Block access to208.46.65.0/24
/sbin/iptables -A OUTPUT -d 208.48.65.0/24 -j DROP
/sbin/iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
/sbin/iptables -A FORWARD -d 192.168.0.0/24 -j ACCEPT
/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to-source 172.23.68.61
#NTHU
/sbin/iptables -A FORWARD -s 172.23.68.32 -j ACCEPT
/sbin/iptables -A FORWARD -d 172.23.68.32 -j ACCEPT
/sbin/iptables -t nat -A POSTROUTING -s 172.23.68.32 -j SNAT --to-source 172.23.68.61
2010年8月23日 星期一
訂閱:
文章 (Atom)