linux下配置静态路由
Internet------(eth1)router1(eth2)------(eth1)router2(eth0)------(eth0)router3(eth1)------(eth0)pc
上面就是我的网络拓扑结构,其中路由器1是用来连接外部网络的一台linux机器,图中所有路由器都是普通的pc机,这些pc都安装了ubuntu桌面系统,除了最右边的pc,其余的pc都装了3张网卡(其中一张备用)。
由于Debian系的网卡配置跟Redhat系很不一样,Redhat是放在/etc/sysconfig/network-scripts目录下面的一大堆文件里面。而Debian系的网卡配置则是存在/etc/network/interfaces这个文件里面,而且不管你有多少块网卡,系统都把配置统统放在这个文件里。下面就来看一下这个文件的内容。
首先,我们来看router1的配置:
auto lo
iface lo inet loopback
iface lo inet6 loopback
auto eth0
iface eth0 inet static
address 192.168.2.1
network 192.168.2.0
netmask 255.255.255.0
broadcast 192.168.2.255
up route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.2.2
down route del -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.2.2
up route add -net 192.168.4.0 netmask 255.255.255.0 gw 192.168.2.2
down route del -net 192.168.4.0 netmask 255.255.255.0 gw 192.168.2.2
iface eth0 inet6 static
address 2000:2::1
netmask 64
up route -A inet6 add 2000:3::/64 gw 2000:2::2
up route -A inet6 add 2000:4::/64 gw 2000:2::2
down route -A inet6 del 2000:3::/64 gw 2000:2::2
down route -A inet6 del 2000:4::/64 gw 2000:2::2
auto eth1
iface eth1 inet dhcp
上面的配置中,
auto说明lo接口跟eth0接口会在系统启动时被自动配置;lo为一个本地回环(loopback)地址,这里分别设置了v4和v6两个loopback;static说明这是一个静态的IP配置;后面配置的作用在于在接口启用的时候,添加两条静态路由,
相关文档:
GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具。或许,各位比较喜欢那种图形
界面方式的,像VC、BCB等IDE的调试,但如果你是在UNIX平台下做软件,你会发现GDB这个
调试工具有比VC、BCB的图形化调试器更强大的功能。所谓“寸有所长,尺有所短”就是这
个道理。
一 ......
/*
* linux/fs/inode.c
*
* (C) 1991 Linus Torvalds
*/
#include <string.h>
#include <sys/stat.h> // 文件状态头文件
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <asm/system.h>
......
/*
* ioctl.c 文件实现了输入/输出控制系统调用ioctl(),该函数
* 主要是调用函数tty_ioctl()对终端的IO进行控制
*/
/*
* linux/fs/ioctl.c
*
* (C) 1991 Linus Torvalds
*/
#include <string.h>
#include <errno.h>
#include <s ......
V] 零起点学习Linux系列培训视频 -1 (寒冰作品)
http://www.boobooke.com/v/bbk1301
[V] 零起点学习Linux系列培训视频 -2 (寒冰作品)
http://www.boobooke.com/v/bbk1304
[V] 零起点学习Linux系列培训视频 -3 (寒冰作品)
http://www.boobooke.com/v/bbk1305
[V] 零起点学习Linux系列培训视频 -4 (寒冰作品)
......
查看系统的磁盘信息:
fdisk -l
[root@localhost home]# fdisk -l
Disk /dev/hda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 979 7759395 ......