配置iptables

[root@master ~]# service iptables status
iptables:未运行防火墙。
[root@master ~]# service iptables start
iptables:应用防火墙规则:                                 [确定]


单个IP的命令是
iptables -I INPUT -s 192.168.1.4 -j DROP  --拒绝192.168.1.4的访问


从192.168.1.5 发起ssh

[root@slave1 ~]# ssh root@192.168.1.100
The authenticity of host '192.168.1.100 (192.168.1.100)' can't be established.
RSA key fingerprint is 58:8b:d9:7f:86:3d:6c:9a:0a:69:e9:0b:26:06:eb:a2.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.100' (RSA) to the list of known hosts.
root@192.168.1.100's password: 
Last login: Mon May 18 16:47:47 2015 from oem-20140503syk

此时可以 查看192.168.1.100上的ip规则
[root@master ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
DROP       all  --  192.168.1.4          0.0.0.0/0           
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination  



默认开始防火墙后的情况:

service iptables status可以查看到iptables服务的当前状态
/etc/init.d/iptables stop
/etc/init.d/iptables start


[root@slave1 ~]# service iptables status
iptables:未运行防火墙。


touch /etc/sysconfig/iptables


jrhppt02:/etc/sysconfig# service iptables status
iptables: Firewall modules are not loaded.



/sbin/modprobe iptable_filter --添加模块


没加载模块:

jrhppt02:/proc# lsmod 
Module                  Size  Used by
nfnetlink               4200  0 
bluetooth              99271  0 
rfkill                 19255  1 bluetooth
xenfs                   5705  1 
microcode             112685  0 
xen_netfront           19033  0 
i2c_piix4              12608  0 
i2c_core               31084  1 i2c_piix4
ext4                  374405  1 
jbd2                   93427  1 ext4
mbcache                 8193  1 ext4
xen_blkfront           15495  2 
pata_acpi               3701  0 
ata_generic             3837  0 
ata_piix               24601  0 
dm_mirror              14384  0 
dm_region_hash         12085  1 dm_mirror
dm_log                  9930  2 dm_mirror,dm_region_hash
dm_mod                 84337  2 dm_mirror,dm_log
jrhppt02:/proc# 



jrhppt02:/proc#  modprobe ip_tables
You have mail in /var/spool/mail/root
jrhppt02:/proc# lsmod 
Module                  Size  Used by
ip_tables              17831  0 
nfnetlink               4200  0 
bluetooth              99271  0 
rfkill                 19255  1 bluetooth
xenfs                   5705  1 
microcode             112685  0 
xen_netfront           19033  0 
i2c_piix4              12608  0 
i2c_core               31084  1 i2c_piix4
ext4                  374405  1 
jbd2                   93427  1 ext4
mbcache                 8193  1 ext4
xen_blkfront           15495  2 
pata_acpi               3701  0 
ata_generic             3837  0 
ata_piix               24601  0 
dm_mirror              14384  0 
dm_region_hash         12085  1 dm_mirror
dm_log                  9930  2 dm_mirror,dm_region_hash
dm_mod                 84337  2 dm_mirror,dm_log

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

scan724

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值