#systat stream tcp nowait guest /usr/sbin/tcpd /bin/ps -auwwx #netstat stream tcp nowait guest /usr/sbin/tcpd /bin/netstat -f inet # # Authentication # #auth stream tcp nowait nobody /usr/sbin/in.identd in.identd -l -e -o #linuxconf stream tcp wait root /bin/linuxconf linuxconf -http
大家看到的这个文件已经修改过的文件,除了telnet 和ftp服务,其他所有的服务都被禁止了.在修改了/etc/inetd.conf之后,使用命令kill -HUP (inetd的进程号),使inetd重新读取配置文件并重新启动即可.
5. ip route的配置 利用linux,一台普通的微机也可以实现高性价比的路由器.首先让我们了解一下linux的查看路由信息的命令: [root@ice /etc]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 202.112.13.204 0.0.0.0 255.255.255.255 UH 0 0 0 eth0 202.117.48.43 0.0.0.0 255.255.255.255 UH 0 0 0 eth1 202.112.13.192 202.112.13.204 255.255.255.192 UG 0 0 0 eth0 202.112.13.192 0.0.0.0 255.255.255.192 U 0 0 0 eth0 202.117.48.0 202.117.48.43 255.255.255.0 UG 0 0 0 eth1 202.117.48.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 0.0.0.0 202.117.48.1 0.0.0.0 UG 0 0 0 eth1 命令netstat -r n 得到输出结果和route -n是一样的.它们操作的都是linux 内核的路由表. 命令cat /proc/net/route的输出结果是以十六进制表示的路由表. [root@ice /etc]# cat /proc/net/route Iface Destination Gateway Flags RefCnt Use Metric Mask eth0 CC0D70CA 00000000 0005 0 0 0 FFFFFFF eth1 2B3075CA 00000000 0005 0 0 0 FFFFFFF eth0 C00D70CA CC0D70CA 0003 0 0 0 C0FFFFF eth0 C00D70CA 00000000 0001 0 0 0 C0FFFFF eth1 003075CA 2B3075CA 0003 0 0 0 00FFFFF eth1 003075CA 00000000 0001 0 0 0 00FFFFF lo 0000007F 00000000 0001 0 0 0 000000F eth1 00000000 013075CA 0003 0 0 0 0000000 通过计算可以知道,下面的这个路由表(十六进制)和前面的路由表(十进制)是一致的. 我们还可以通过命令route add (del )来操作路由表,增加和删除路由信息. 除了上面的静态路由,linux还可以通过routed来实现rip协议的动态路由.我们只需要打开linux的路由转发功能,在/proc/sys/net/ipv4/ip_forward文件中增加一个字符1.
三.网络的安全设置
在这一部分,再次强调一定要修改/etc/inetd.conf,安全的策略是禁止所有不需要的服务.除此之外,还有以下几个文件和网络安全相关.
(1)./etc/ftpusers ftp服务是一个不太安全的服务,所以/etc/ftpusers限定了不允许通过ftp访问linux主机的用户列表.当一个ftp请求传送到ftpd,ftpd首先检查用户名,如果用户名在/etc/ftpusers中,则ftpd将不会允许该用户继续连接.范例文件如下:
# /etc/ftpusers - users not allowed to login via ftp root bin daemon adm lp sync shutdown halt mail news uucp operator games nobody nadmin
(2)/etc/securetty 在linux系统中,总共有六个终端控制台,我们可以在/etc/securetty中设置哪个终端允许root登录,所有其他没有写入文件中的终端都不允许root登录.范例文件如下:
# /etc/securetty - tty's on which root is allowed to login tty1 tty2 tty3 tty4
(3)tcpd的控制登录文件/etc/hosts.allow和/etc/hosts.deny 在tcpd服务进程中,通过在/etc/hosts.allow和/etc/hosts.deny中的访问控制规则来控制外部对linux主机的访问.它们的格式都是 service-list : hosts-list [ : command] 服务进程的名称 : 主机列表 可选,当规则满足时的操作 在主机表中可以使用域名或ip地址,ALL表示匹配所有项,EXCEPT表示除了某些项, PARANOID表示当ip地址和域名不匹配时(域名伪装)匹配该项. 范例文件如下:
# # hosts.allow This file describes the names of the hosts which are # allowed to use the local INET services, as decided # by the '/usr/sbin/tcpd' server. # ALL : 202.112.13.0/255.255.255.0 ftpd: 202.117.13.196 in.telnetd: 202.117.48.33 ALL : 127.0.0.1
在这个文件中,网段202.112.13.0/24可以访问linux系统中所有的网络服务,主机202.117.13.196只能访问ftpd服务,主机202.117.48.33只能访问telnetd服务.本机自身可以访问所有网络服务. 在/etc/hosts.deny文件中禁止所有其他情况: #/etc/hosts.deny ALL : DENY : spawn (/usr/bin/finger -lp @%h | /bin/mail -s "Port Denial noted in %d-%h" root)
在/etc/hosts.allow中,定义了在所有其他情况下,linux所应该执行的操作.spawn选项允许linux系统在匹配规则中执行指定的shell命令,在我们的例子中,linux系统在发现无授权的访问时,将会发送给超级用户一封主题是"Port Denial noted in %d-%h"的邮件,在这里,我们先要介绍一下allow和deny文件中的变量扩展.
如果您对本文有任何疑问或者建议,请到讨论区发表您的意见:
>>
论坛入口 <<
上一页 1 2 3 4 56 下一页
上一篇:Linux 网管 123 --- 第13章. 其他的问题 1.系统损毁 下一篇:如何配置linux与win2000/NT 双重引导
|