Lab 3 Securing Networking

Goal: To build skills with the Netfilter packet filter

Sequence 1: Applying simple packet filtering to a host

Scenario: A host (stationX) requires protection by packet filtering. This host has only one network interface, so no packet forwarding is involved.

Deliverable: Packet filter rules successfully limit connections to stationX for SSH services only.

System Setup: Install the iptables-ipv6 package. See the Appendix for more information on installing packages.

Instructions:

1. Work with a lab partner, and determine who of you has the role of stationX (192.168.0.X), and who has stationY (192.168.0.Y).

Install the iptables-ipv6package. See the Appendix for more information on installing packages.

a. [root@stationX]# yum -y install iptables-ipv6

[root@stationY]# yum -y install iptables-ipv6

2. Ensure localhost IPv6 connectivity through tcp_wrappers.

a. On both systems, add to /etc/hosts.allow:

ALL: [::1]

3. Ensure the SSH service is running on stationX.

a. [root@stationX]# service sshd status
sshd (pid 5563 5561 2536) is running...

4. Confirm exposed ports on stationX from stationY:

[root@stationY]# nmap stationX

5. Confirm stationX can establish SSH connections to stationY. Note: you may have a user account on each system, with the username of student. If so, then the password is student. Create an unprivileged user account if needed: it is strongly discouraged to login to the system as root, even using SSH.

a. [root@stationY]# ssh student@stationX
student@stationX's password:
[student@stationX]$ exit

6. On stationX, apply a new default policy of DROP on the INPUT chain of the filter table.

a. [root@stationX]# iptables -P INPUT DROP

7. From stationX, attempt an ssh connection to localhost using IPv4 (127.0.0.1). Set the , so that it only waits for ten seconds. This should eventually fail.

a. [root@stationX]# ssh -o ConnectTimeout=10 127.0.0.1

8. Now try the IPv6 address for localhost on stationX (::1). This should eventually work. Be patient, as there are other services timing out as we will discover later.

a. [root@stationX]# ssh -o ConnectTimeout=10 ::1

9. From stationY verify that you can ping the link-local IPv6 address of stationX.

Get the IPv6 address from stationX by looking at the output of the ip command (run on stationX, of course). It should provide something like the following, with the IPv6 address in bold. Note: the IPv6 address uses the interface MAC address for uniqueness, where:

fe80::2(2nd column of MAC):(3rd column)ff:fe(4th column):(5th column)(6th column)

# ip addr sh dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc
pfifo_fast qlen 1000
link/ether 00:0d:60:8e:25:f3 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.X/24 brd 192.168.0.255 scope global eth0
inet6
fe80::20d:60ff:fe8e:25f3/64 scope link
valid_lft forever preferred_lft forever

Once you have the IPv6 address, from stationY ping stationX using ping6:

[root@stationY]# ping6 -I eth0 -c 3 fe80::20d:60ff:fe8e:25f4

Replacing fe80::20d:60ff:fe8e:25f4 with the IPv6 address of stationX.

10. Allow all incoming local connections (lo) on stationX.

a. [root@stationX]# iptables -A INPUT -i lo -j ACCEPT

11. On stationX, allow connections to the SSH service from stationY and from server1. Remember that DNS names should not be used.

a. [root@stationX]# iptables -A INPUT -s 192.168.0.Y -p tcp --dport ssh -j ACCEPT
b. [root@stationX]# iptables -A INPUT -s 192.168.0.254 -p tcp --dport ssh -j ACCEPT

12. Now view your iptables rules. This may take a minute to complete. Can you figure out what the problem might be? You may need to review the Fault Analysis slides for hints on commands that might be useful here. Once you have found the problem, fix it.

a. [root@stationX]# iptables -L

b. strace may prove useful here, as it allows us to view the files and commands that iptables may be using when it hangs.

[root@stationX]# strace iptables -L

You should find lines that include files such as /lib/libresolv.so.2 and /lib/libnss_dns.so.2 as well as a connection to the IP address of your DNS server. This appears to be a DNS problem, so we need to add entries for the DNS server:

[root@stationX]# iptables -A INPUT -s 192.168.0.254 -p udp --sport 53 -j ACCEPT
[root@stationX]# iptables -A INPUT -s 192.168.0.254 -p tcp --sport 53 -j ACCEPT

13. Allow ESTABLISHED and RELATED packets on stationX.

a. [root@stationX]# iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

14. From stationY, confirm that only the SSH port is exposed on stationX:

[root@stationY]# nmap -v -P0 stationX

This may take some time to complete, but give it a couple of minutes. Would merely an attempt to connect to stationX, from stationY using ssh prove that our Netfilter configuration is effective? Why? Why not?

a. We could prove that our configuration is effective in allowing ssh, but it is impossible to determine that it was actually blocking other ports from that one test.

15. Confirm that stationX can establish connections to stationY, and that stationX can still resolve host names.

a. [root@stationX]# ssh student@stationY
student@stationY's password:
[student@stationY]$ exit

b. [root@stationX]# dig stationY.example.com

16. On stationX, save your configuration and view the iptables configuration file just created.

a. [root@stationX]# service iptables save; restorecon -R /etc/sysconfig

b. [root@stationX]# cat /etc/sysconfig/iptables

c. [root@stationX]# iptables -vL --line-numbers

17. Go back through the lab and switch stations. stationX will become stationY, and stationY will become stationX. By the end of the lab, you should both have the same rules.

18. After both you and your lab partner have completed this sequence, configure a default installed set of Netfilter rules for IPv4, and disable the IPv6 Netfilter rules.

a. [root@stationX]# lokkit -q --enabled

b. [root@stationX]# service iptables restart

c. [root@stationX]# service ip6tables stop

d. [root@stationX]# chkconfig ip6tables off

RH253读书笔记(3)-Lab 3 Securing Networking的更多相关文章

  1. RH253读书笔记(8)-Lab 8 Securing Data

    Lab 8 Securing Data Goal: Gain familiarity with encryption utilities Sequence 1: Using SSH keys with ...

  2. RH253读书笔记(1)-Lab 1 System Monitoring

    Lab 1 System Monitoring Goal: To build skills to better assess system resources, performance and sec ...

  3. RH253读书笔记(6)-Lab 6 Implementing Web(HTTP) Services

    Lab 6 Implementing Web(HTTP) Services Goal: To implement a Web(HTTP) server with a virtual host and ...

  4. RH253读书笔记(2)-Lab 2 System Resource Access Controls

    Lab 2 System Resource Access Controls Goal: To become familiar with system resource access controls. ...

  5. RH253读书笔记(4)-Lab 4 The Domain Name System

    Lab 4 The Domain Name System Goal: To install and configure a DNS server System Setup: Throughout th ...

  6. RH253读书笔记(5)-Lab 5 Network File Sharing Services

    Lab 5 Network File Sharing Services Goal: Share file or printer resources with FTP, NFS and Samba Se ...

  7. RH253读书笔记(7)-Lab 7 Electronic Mail

    Lab 7 Electronic Mail Goal: To build common skills with MTA configuration Estimated Duration: 90 min ...

  8. RH253读书笔记(9)-Lab 9 Account Management Methods

    Lab 9 Account Management Methods Goal: To build skills with PAM configuration Sequence 1: Track Fail ...

  9. RH033读书笔记(16)-Lab 17 Installation and Administration Tools

    Lab 17 Installation and Administration Tools Goal: Become familiar with system configuration tools a ...

随机推荐

  1. 谷歌下解决Pop遮罩层无法遮挡滚动栏下问题

    今天用pop的弹出窗体里,出现一个问题,当网页出现滚动栏里,不能遮挡住,解决Pop遮罩层无法遮挡滚动栏下问题. 可通过下载获取改动后的代码----->进入下载

  2. 将Excel数据表到数据库表

    假设你有大量的数据要导入到数据库表,恐怕是没有效率的写程序,作为用于数据操纵,Excel在这方面有优势,但是,如何将其结合起来?将Excel数据表到数据库表,就是本篇博客的目的. 首先去下载MySQL ...

  3. Web服务器Raspkate的RESTful API

    基于轻量型Web服务器Raspkate的RESTful API的实现 在上一篇文章中,我们已经了解了Raspkate这一轻量型Web服务器,今天,我们再一起了解下如何基于Raspkate实现简单的RE ...

  4. PHP --字符串编码转换(自动识别原编码)

    /** * 对数据进行编码转换 * @param array/string $data 数组 * @param string $output 转换后的编码 */ function array_icon ...

  5. android面试题 不单单为了面试也是一次非常好的学习

    以以下试题都是在网上找的总结出来的,谢谢大家的分享!希望,我们共同进步,找到自己梦想的公司: 1.android dvm 的进程和Linux的进程,应用程序的进程是否为同一个概念: 答:dvm是dal ...

  6. android贴士Toast

    转载请注明出处:http://blog.csdn.net/droyon/article/details/42009015 我们可以用androd提供toast控制,但在使用过程中,给我们发了很多Toa ...

  7. c++学习笔记4,调用派生类的顺序构造和析构函数(一个)

    测试源代码: //測试派生类的构造函数的调用顺序何时调用 //Fedora20 gcc version=4.8.2 #include <iostream> using namespace ...

  8. 苹果Swift编程语言新手教程【中文版】

    文件夹 1 简单介绍 2 Swift入门 3 简单值 4 控制流 5 函数与闭包 6 对象与类 7 枚举与结构 1 简单介绍 Swift是供iOS和OS X应用编程的新编程语言,基于C和Objecti ...

  9. Java Swing 绝对布局管理方法,null布局(转)

    首先把相关容器的布局方式设为 setLayout(null); 然后调用组件的  setBounds() 方法 设置button的位置为(100,100) 长宽分别为 60,25 jButton.se ...

  10. Android异步任务

    本文主要探讨Android平台提供的各种异步载入机制,包括它们的适用场景.用法等. 1. AsynTask AsynTask适用于最长能够持续几秒钟的短时间的操作,对于长时间的操作,建议使用java. ...