Pos 420
This presentation is the property of its rightful owner.
Sponsored Links
1 / 42

POS/420 PowerPoint PPT Presentation


  • 86 Views
  • Uploaded on
  • Presentation posted in: General

POS/420. Introduction to Unix. Joshua Margolin – April 2, 2013 (Week 4) University of Phoenix Mililani Campus. Agenda: Week 4. Installations Week 4 Virtual Private Server Anonymous Proxy Server Firewall Open VPN (Time Permitting). What is a Virtual Private Server?.

Download Presentation

POS/420

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Pos 420

POS/420

Introduction to Unix

Joshua Margolin – April 2, 2013 (Week 4)

University of Phoenix Mililani Campus


Agenda week 4

Agenda: Week 4

  • Installations

  • Week 4

    • Virtual Private Server

      • Anonymous Proxy Server

      • Firewall

      • Open VPN (Time Permitting)


What is a virtual private server

What is a Virtual Private Server?

  • VPS is a virtual machine provide by an internet hosting service.

  • VPS runs on software on the same physical computer as other customer’s virtual machines.

  • Can have multiple servers on one physical machine.

  • Advantage

    • Cheap

    • Space

    • Easy to setup


Why is vps important

Why is VPS important?

  • Companies are moving towards “Cloud Computing.”

  • Amazon uses Virtual Private Servers on the backend.

  • Many of Amazon’s data centers rely on VPS technology.

    • Get a job with Amazon and you could be configuring Linux on a VPS.


What is a proxy

What is a Proxy?

  • Proxy is a server that acts as an intermediary device between a client and server. (Middleman)

  • Intercepts and inspects data before sending to recipient.

  • Makes connection on behalf of the source.

  • Machine that talks to the outside world ensuring no computer has direct access to internal computers.

    • Common Uses

      • Keep machines anonymous for security (Anonymous Proxy)

      • Packet scanning (Firewall Proxy)

      • Speed up access to resources via caching (Web Proxy)


What is a proxy1

What is a Proxy?


Proxy installation

Proxy Installation

  • [email protected]:/#

    • This = root prompt

  • [email protected]:~# cd ..

    • Cd .. Command moves up one directory

  • [email protected]:/# ls –a

    • ls –a command displays folders and files horizontally.

  • [email protected]:/# cd /etc/apt

    • Changes to apt directory

  • Simply type:

    • [email protected]:/etc/apt# apt-get update


Proxy installation1

Proxy Installation

  • apt-get update

    • Updates the software on VPS. This is necessary to make sure all software tools are installed on VPS.

  • [email protected]:/etc/apt# apt-get install wget

    • wget is a built in program that retrieves content from web servers.

  • [email protected]:/etc/apt# wget http://www.dorkatron.com/docs/POS420/proxy.sh

    • This is a script that will install apache (webserver), and squid (proxy)


Proxy installation2

Proxy Installation

  • [email protected]:/etc/apt# chmod a+x proxy.sh

    • By changing permissions chmod a+x will allow the file proxy.sh to become executable

      • (a) = all users/groups/others (x) = executable

  • [email protected]:/etc/apt# ./proxy.sh

    • Will execute the following contained in the script.


Proxy installation3

Proxy Installation

  • Proxy.sh

    • apt-get update

    • apt-get install apache2

    • apt-get install squid3

    • touch /etc/squid3/squid_passwd

    • chmod +r /etc/squid3/squid_passwd

    • /etc/init.d/apache2 stop

    • update-rc.d -f apache2 remove

    • cd /etc/squid3

    • htpasswd /etc/squid3/squid_passwd account1

    • htpasswd /etc/squid3/squid_passwd account2

    • rm squid.conf

    • wget http://www.dorkatron.com/docs/POS420/squid.conf

    • /etc/init.d/squid3 restart


Proxy installation4

Proxy Installation

  • Script will execute.

    • Will see the following:

      • Do you want to continue [Y/N]? (hit y and press enter)

      • New Password:

      • Re-type new Password:

        • Passwords are for user accounts

        • Repeat process for second user account

    • VI file editor will open up squid.conf

      • Squid.conf = config file for proxy server


Proxy installation5

Proxy Installation

  • Scroll down to http_port 3128

    • Port 3128 is the port the proxy server will use.

    • Acl user1 proxy_auth account1

    • Acl user2 proxy_auth account2

    • These are the two accounts passwords were created for.

    • Tcp_outgoing_address 123.123.123.123 user1

    • Tcp_outgoing_address 123.123.123.124 user2

    • Change outgoing address to IP assigned to your server.


Proxy installation6

Proxy Installation

  • Proxy Testing

    • Settings Control Panel

    • Internet Options

    • Connections

    • LAN settings

    • Check mark use a Proxy

    • Put in address and port 3128

    • Run browser put in account1 and password

    • www.google.com type in what is my IP address


Proxy completion

Proxy Completion

  • Congratulations Linux Guru. You have successfully completed this training module


What is a firewall

What is a Firewall?

  • Either software or hardware based

  • Keeps networks secure

  • Works based on predetermined rules

    • Port security

    • Stateful packet inspection

      • Records all connections and determines connection state

      • Connections must be initiated by source/client and not receivers.


What is a firewall1

What is a Firewall?


Firewall installation

Firewall Installation

  • [email protected]:~# wget http://www.configserver.com/free/csf.tgz

  • [email protected]:~# tar -xzf csf.tgz

    • Tar –xzf is the command to uncompress an archived file

    • x = extract z = filter the archive through gzip f=archive file name

  • [email protected]:~# cd csf

  • [email protected]:~/csf# sh install.sh

    • Sh install.sh is a script that configures csf firewall for the OS the VPS is running.


Firewall installation1

Firewall Installation

  • OOPS! can’t find perl module. Google the error!

  • Google “can't locate lwp/useragent.pm in @inc (@inc contains”

  • It appears other people have had the same issue!

  • Advantage of Linux is since its open source someone is bound to have the same problem. Google has the answers.


Firewall installation2

Firewall Installation

  • [email protected]:~/csf# apt-get install libwww-perl

  • [email protected]:~/csf# sh install.sh

    • Next, test whether you have the required iptables modules:

    • [email protected]:~/csf# perl /etc/csf/csftest.pl

      • RESULT: csf should function on this server

  • [email protected]:~/csf# cd ..

  • [email protected]:~# cd ..

  • [email protected]:/# cd etc

  • [email protected]:/etc/csf# vi csf.conf


Firewall installation3

Firewall Installation

  • Csf.conf

    • Edit conf file by reading instructions.

      • Change from testing mode to live mode.

      • Add 3128 proxy port to TCP IN/OUT.

      • Save changes

      • Restart csf

        • [email protected]:/etc/csf# csf –r

        • [email protected]:/etc/csf# lfd –r

          • Lfd (login Failure Daemon) logging software that logs failed loggings and brute force attacks.


Firewall installation4

Firewall Installation

  • Check mail to see if you have any hacker attacks!

    • [email protected]:/etc/csf# mail

    • N 2 [email protected] Sun Mar 17 02:01 23/926 lfd on yourdomain: Excessive resource usage: proxy (3204 (Parent PID:3201))

      • Oops! this MSG will fill up mailbox real quick. Message means that logging server is flagging what it thinks is suspicious activity due to VPS memory limitations. We will disable this alert.

      • Go back and edit csf.conf

        • Scroll down and set PT_USERPROC, PT_USERMEM, and PT_USERTIME = “0”

        • Restart csf and lfd.


Firewall installation5

Firewall Installation

  • No hacker attempts so lets create one.

    • Have person next to you, SSH to your VPS but enter wrong password.

    • Log into your VPS.

    • Login to mail.

    • Investigate the mail msg.


Firewall completion

Firewall Completion

  • Congratulations Linux Guru. You have successfully completed this training module.


What is a virtual private network

What is a Virtual Private Network?

  • A VPN is a virtual point to point connection between a client and receiver through the use of dedicated connections and encryption.

  • Protects the confidentiality of information.

    • Common uses

      • Private and secure connection between your home computer and your online banking website. This is known as Secure Socket Layer (SSL)

      • Government uses for the protection of classified information in transmit.

      • Corporations use it to communicate between regional offices.


What is a virtual private network1

What is a Virtual Private Network?


Vpn installation

VPN Installation

  • What is OpenVPN?

    • OpenVPN is an open source software application that implements a VPN.

    • Uses a custom security protocol that uses SSL/TLS for key exchange.

    • OpenVPN allows peers to authenticate to each other using pre-shared (secret key) and certificates.

      • Secret key is called “symmetric encryption.”

        • Asymmetric is used to encrypt (protect) the secret key during key exchange.

        • Symmetric is used to encrypt and decrypt information once key exchange has been established.


Vpn installation1

VPN Installation

  • What [email protected]:~# apt-get install openvpn

    • Copy easy-rsa into the correct place

      • cp -R /usr/share/doc/openvpn/examples/easy-rsa /etc/openvpn

      • Easy-rsa is the folder that will hold the certifications and secret keys.

      • Cp –R = command for copying directories recursively (will copy all files and directories)


Vpn installation2

VPN Installation

  • Generate Keys

    • cd /etc/openvpn/easy-rsa/2.0

    • ./vars (./=execute file in current directory)

      • Permission denied

        • chmod +x vars

    • ./clean-all

      • source the vars script first (i.e. "source ./vars")

        • source ./vars ./clean-all

    • ./build-ca

    • ./build-key-server server

    • ./build-key client

    • ./build-dh (Use DIFFIE-HELLMAN encryption algorithm)


Vpn installation3

VPN Installation

  • Apply iptables rules

    • iptables are the tables provided by the Linux kernel firewall

    • Linux comes with a built in kernel firewall called iptables. We use CSF as a wrapper which provides management of the iptables for us. However, in order for OpenVPN to work we must enter specific iptable commands.

    • Forward the IP

      • Vi /etc/sysctl.conf

        • Configuration file for setting system variables

        • #net.ipv4.ip_forward=1

          • Remove the #. This will enable packet forwarding for IPv4 for OpenVPN to work.


Vpn installation4

VPN Installation

  • Run the forward

    • [email protected]:/etc/csf# Sysctl –p

      • Should see the following result:

        • Net.ipv4.ip_forward=1

  • Create iptables rules

    • Iptables –t nat –A POSTROUTING –s 10.8.0.0/24 –o venet0 –j MASQUERADE

      • -t specifies the packet matching table which command should use

      • Nat – packet matching table that defines how packet should be routed.

      • -A specifies one or more chain rules.

      • POSTROUTING – altering a packet as it goes out

      • -s source address and subnet mask

      • -o out interface

      • venet0– interface packet will use to go out.

      • -j jump target Specifies target of the rule i.e., what to do if the packet matches it.

      • MASQUERADE translates the private IP address to public.


Vpn installation5

VPN Installation

ETHERNET2 +------------+ +-------------+

to ISP provider | Linux #1 | ETHERNET1 | Anybox |

| | | |

<--------- venet0 | IP Tables |venet0 -------- NIC CARD | Virtual |

| MASQ. | | Tun/TAP |

198.147.X.X | | 10.8.X.X | Card |

+------------+ +-------------+

In the above drawing, a Linux box with IP_MASQUERADING is installed as Linux #1 and is connected to the Internet via Ethernet2 It has an assigned public IP address of 198.147.X.X. It also has another network interface (venet0) connected to allow incoming network traffic be it from a ETHERNET1 connection.


Vpn installation6

VPN Installation

ETHERNET2 +------------+ +-------------+

to ISP provider | Linux #1 | ETHERNET1 | Anybox |

| | | |

<--------- venet0 | IP Tables |venet0 -------- NIC CARD | Virtual |

| MASQ. | | Tun/TAP |

198.147.X.X | | 10.8.X.X | Card |

+------------+ +-------------+

The second system (which does not need to be Linux) connects into the Linux #1 box and starts its network traffic to the Internet. This second machine does NOT have a publicly assigned IP address from the Internet, so it uses say 10.8.X.X


Vpn installation7

VPN Installation

ETHERNET2 +------------+ +-------------+

to ISP provider | Linux #1 | ETHERNET1 | Anybox |

| | | |

<--------- venet0 | IP Tables |venet0 -------- NIC CARD | Virtual |

| MASQ. | | Tun/TAP |

198.147.X.X | | 10.8.X.X | Card |

+------------+ +-------------+

With IP Masquerade and the routing configured properly, this second machine "Anybox" can interact with the Internet as if it was directly connected to the Internet with a few small exceptions [noted later].


Vpn installation8

VPN Installation

ETHERNET2 +------------+ +-------------+

to ISP provider | Linux #1 | ETHERNET1 | Anybox |

| | | |

<--------- venet0 | IP Tables |venet0 -------- NIC CARD | Virtual |

| MASQ. | | Tun/TAP |

198.147.X.X | | 10.8.X.X | Card |

+------------+ +-------------+

I tell machine ANYBOX that Linux box is its gateway.

When a packet comes into the Linux box from ANYBOX, it will assign the packet to a new TCP/IP source port number and insert its own IP address inside the packet header, saving the originals. The MASQ server will then send the modified packet over the ETHERNET interface onto the Internet.


Vpn installation9

VPN Installation

ETHERNET2 +------------+ +-------------+

to ISP provider | Linux #1 | ETHERNET1 | Anybox |

| | | |

<--------- venet0 | IP Tables |venet0 -------- NIC CARD | Virtual |

| MASQ. | | Tun/TAP |

198.147.X.X | | 10.8.X.X | Card |

+------------+ +-------------+

When a packet returns from the Internet into the Linux box, Linux examines if the port number is one of those ports that was assigned above. If so, the MASQ server will then take the original port and IP address, put them back in the returned packet header, and send the packet to ANYBOX.

The host that sent the packet will never know the difference. 


Vpn installation10

VPN Installation

  • Create the VPS OpenVPN configuration file

    • [email protected]:/etc/openvpn# wgethttp://www.dorkatron.com/docs/POS420/server.conf

    • vi /etc/openvpn/server.conf

      • port 1194

      • proto tcp

      • dev tun

      • ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt

      • cert /etc/openvpn/easy-rsa/2.0/keys/server.crt

      • key /etc/openvpn/easy-rsa/2.0/keys/server.key

      • dh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem

      • server 10.8.0.0 255.255.255.0

      • ifconfig-pool-persist ipp.txt

      • push "redirect-gateway def1"

      • push "dhcp-option DNS 10.8.0.1"

      • client-to-client

      • duplicate-cn

      • keepalive 10 120

      • comp-lzo

      • user nobody

      • group nogroup

      • persist-key

      • persist-tun

      • status openvpn-status.log

      • log /var/log/openvpn.log

      • verb 3


Vpn installation11

VPN Installation

  • Start OpenVPN

    • [email protected]:/etc/openvpn# openvpn server.conf

      • starts openvpn using server.conf file

  • Create the PC OpenVPN Configuration file

    • cd /etc/openvpn/easy-rsa/2.0/keys/

    • wget http://www.dorkatron.com/docs/POS420/client.conf


Vpn installation12

VPN Installation

  • Config.conf

    • clientdev tunproto tcpremote 198.147.XX.XXX 1194resolv-retry infinitenobindpersist-keypersist-tunca ca.crtcert client.crtkey client.keycomp-lzoverb 3redirect-gatewayscript-security 2


Vpn installation13

VPN Installation

  • Reboot

    • vi /etc/rc.local

    • Write the following contents above “exit o”

      • iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o venet0 -j MASQUERADE


Vpn installation14

VPN Installation

  • Download Certs and Keys

  • Caution! Use secure means! Keys and certs are not encrypted. SFTP or SSH.

    • client.conf

    • ca.crt

    • client.crt

    • client.key

  • Reboot VPS

  • Install Wireshark

  • Install OpenVPN client on desktop

  • Move Certs and Keys into OpenVPN config folder


Vpn installation15

VPN Installation

  • Configure the client.ovpn file


Vpn completion

VPN Completion

  • Congratulations Linux Guru. You have successfully completed this training module.


  • Login