Debian-linux-内核升级+路由代理

来源:互联网 发布:ip地址精确定位软件 编辑:程序博客网 时间:2024/05/16 13:48
 

临时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

原创粉丝点击