Debian-linux-核心升級+路由代理

來源:互聯網
上載者:User
 

臨時IP和掩碼設定:
ifconfig 查看網卡及ip狀態

ifconfig eth0 192.168.0.233 netmask 255.255.255.0

臨時設網關:
route add -net 0 gw 192.168.0.100

固定設定IP
vim /etc/network/interfaces  內容如下:

auto eth0 eth1 
iface eth0 inet static
        address 192.168.0.176
        netmask 255.255.255.0 
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        dns-nameservers 202.96.128.86

iface eth1 inet static
        address 外網ip
        netmask 外網掩碼 
        network 外網網段
        broadcast 外網廣播位址
        gateway 外網網關
        dns-nameservers 202.96.128.86

編寫apt源
deb http://debian.cn99.com/debian unstable main
deb http://debian.cn99.com/debian/ stable main 
apt-get dist-upgrade
apt-get update
安裝編譯組件
apt-get install gcc
apt-get install make
apt-get install curl
apt-get install perl
apt-get install modules-init-tools
下載核心源碼 wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.3.tar.bz2
下載iptables wget http://ftp.netfilter.org/pub/iptables/iptables-1.3.6.tar.bz2
下載iptables補丁wget http://ftp.netfilter.org/pub/patch-o-matic-ng/snapshot/patch-o-matic-ng-20061124.tar.bz2
解壓到/usr/src/
tar -xvzf linux-2.6.18.3.tar.bz2 /usr/src
tar -xvzf iptables-1.3.6.tar.bz2 /usr/src
tar -xvzf patch-o-matic-ng-20061124.tar.bz2 /usr/src
cd /usr/src/patch-o-matic-ng-20061124 補丁目錄
export KERNEL_DIR=/usr/src/2.6.18.3
export IPTABLES_DIR=/usr/src/iptables-1.3.6
./runme --download
./runme connlimit 只打這個connlimit補丁。
apt-get install linux-headers-2.6.18-*   尋找一下debian官方的核心
apt-get install linux-headers-2.6.18-3-686  下載debian官方的核心
cp /usr/src/linux-headers-2.6.18-3-686/.config /usr/src/linux-2.6.18.3 複製debian官方已經設定好的.config
cd linux-2.6.18.3
make-menuconfig     選中network----裡面新加的補丁 connlimit
make 
make modules_install 
mkinitrd -o /boot/initrd.img-2.6.18 2.6.18.3
複製System.map 到/boot
改名為System.map-2.6.18
複製arch/i386/boot/bzImage 到/boot
bzImage 改名成 vmlinuz-2.6.18 
最後改grub添加新核心
vim /boot/grub/menu.list

iptables -A FORWARD -i eth0 -p tcp --syn -m connlimit --connlimit-above 25 -j REJECT
eth0是這邊的內網網卡,自己改。 試用connlimit

以下是代理路由的幾個常用命令

iptables -t nat -a POSTROUTING -s 192.168.0.0/24 -o eth1 -j snat --to 外網ip       IP偽裝

iptables -p input tcp -dport 135 -j DROP   封連接埠

echo 1 > /proc/sys/net/ipv4/ip_forward   手動開啟轉寄  

編輯/etc/network/options
ip_forward=yes
這樣每次開機就自動開啟轉寄功能了

編輯/etc/rc.local
編輯此檔案寫入防火牆儲存就可以每次開機啟用自己編的iptables策略了
安裝iptraf 流量簡單查看工具
apt-get install iptraf

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.