查看完整版本: 自动生成/etc/ethers

问天 2008-3-31 01:41

自动生成/etc/ethers

首先,写一个C文件比如mk_ethers.c[code]#include <stdlib.h>
#include <stdio.h>
main ()
{
                int i;
                        for(i=2;i<255;i++)
                printf("10.0.0.%d\t00:00:00:00:00:00\n",i);
}[/code]编译成功后,执行:
mk_ethers > /tmp/ethers.tmp
就得到原始的ethers文件了,修改后拷入 /etc 目录下即可。

[[i] 本帖最后由 问天 于 2008-3-31 01:51 编辑 [/i]]

问天 2008-3-31 01:47

记得拷入 /etc 目录下,要改名为 ethers

:lol

问天 2008-3-31 01:57

用bash更简单:[code]for((i=2;i<=254;i++));
do echo -e "10.0.0.$i\t00:00:00:00:00:00" >> /tmp/ethers.tmp;
done[/code]或[code]for((i=2;i<=254;i++));
do echo -e "10.0.0.$i\t00:00:00:00:00:00";
done > /tmp/ethers.tmp[/code]区别是一个用 >> 追加,一个用 > 一次产生完整的。
页: [1]
查看完整版本: 自动生成/etc/ethers