RHCE-配置SSH访问

server和desktop都需要配置,本文档只记录server配置

 [root@server0 ~]# systemctl stop firewalld.service       停止firewalld防火墙服务

 [root@server0 ~]# systemctl disable firewalld.service              关闭firewalld防火墙服务

rm '/etc/systemd/system/basic.target.wants/firewalld.service'

rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'

 [root@server0 ~]# systemctl mask firewalld.service              隐藏firewalld防火墙服务

ln -s '/dev/null' '/etc/systemd/system/firewalld.service'

[root@server0 ~]# systemctl enable iptables.service               启动iptables防火墙服务(开机自启)

ln -s '/usr/lib/systemd/system/iptables.service' '/etc/systemd/system/basic.target.wants/iptables.service'

 [root@server0 ~]# systemctl start iptables.service                开启iptables防火墙服务

[root@server0 ~]# iptables -F                                                     清空iptables防火墙策略

 [root@server0 ~]# iptables -A INPUT -s 172.25.1.0/24 -j REJECT   ///增加入方向拒绝策略,-A策略方向,-s地址列表,-j策略名称

 [root@server0 ~]# iptables -L                                                    查看iptables防火墙策略

Chain INPUT (policy ACCEPT)

target     prot opt source               destination         

REJECT     all  --  172.25.1.0/24        anywhere             reject-with icmp-port-unreachable

 

Chain FORWARD (policy ACCEPT)

target     prot opt source               destination         

 

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination         

 [root@server0 ~]# service iptables save                                                   保存策略配置

iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

 [root@server0 ~]# systemctl restart iptables.service             重启iptables防火墙服务

[root@server0 ~]# systemctl status iptables.service                             查询运行状态

iptables.service - IPv4 firewall with iptables

   Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled)

   Active: active (exited) since Tue 2018-04-24 10:03:04 CST; 10min ago

  Process: 3957 ExecStop=/usr/libexec/iptables/iptables.init stop (code=exited, status=0/SUCCESS)

  Process: 4007 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)

 Main PID: 4007 (code=exited, status=0/SUCCESS)

 

Apr 24 10:03:04 server0.example.com systemd[1]: Starting IPv4 firewall with iptables...

Apr 24 10:03:04 server0.example.com iptables.init[4007]: iptables: Applying firewall rules: [  OK  ]

Apr 24 10:03:04 server0.example.com systemd[1]: Started IPv4 firewall with iptables.

[root@server0 ~]#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值