Вы находитесь на странице: 1из 608

Version 3.86 Are you using the most current PDF version of this how-to?

Version numbers are located at the top right of this page

The latest and great version is always available at my homepage http://woodel.com Setting up a Linux Server, Start to Finish, using Webmin. By Kevin Elwood

This how-to assumes your looking to setup a Linux Server, not a Linux Desktop. For use without a keyboard, mouse, or GUI interface. After setup completes you will be remotely managing it, and will not have a need for the monitor and keyboard once you have finished the initial setup. This how-to also assumes you are connected to the internet, and have at least (2) computers on the same network. It also assumes you will have at least (2) hard-drives in the server, one for the O.S. and one for the data. Only one network card is needed until the optional \ advanced section. For every download link, I offer an alternative source (from my server) so that you may follow this how-to exactly, down to the same versions I used. Newer is better, and youre encouraged to upgrade after you complete this how-to. But for continuity and flow, I provide a link to the same exact versions used in this how-to. Also due to upgrades some versions may no longer be available, if you run into this just use the links to my server, this will ensure matching print screens, or go to webmin.com and find the newer link. This how-to covers everything from the most basic setup, to a full blown server. You can choose how far to go in this step by step how-to, even setting your Linux box up as your Router, Samba FileServer, Firewall, DNS, HTTP, HTTPS, FTP, VMWare Server, backup solution, and more. No table-of-contents, it is assumed you will follow this how-to, step by step, as each page builds off the previous ones. If you skip a page, you could miss an installer or file called for later in the how-to. I hope you will find this how-to helpful. I will try my best to respond via email at kevinthecomputerguy@gmail.com if you have questions, I will try my best to respond to all of them, but please try my BLOG first. With any luck that will turn into a knowledge base. My stuff will always be free for personal use, but if you would still like to contribute, you can donate money towards this, or one of my other how-to's

*Special thanks to: Bill M., Mike J., Julio C., NathanR., Tim R., James M., Melissa E., Peter B., ggaron, till, sammydee, Mad Professor, AdamLis, Mihai Marinof, Lani78, Jordan Sissel, Jerome1232, Drdos2006, and of course Jamie Cameron (Webmin \ Usermin), Putty, Cobian Backup, Debian Linux, Ubuntu, Ubuntuforums.org and the millions of people that make Linux possible.

- OK... Lets begin

Although this guide was created using Debian, it will also help Ubuntu users. You will run into some problems with Ubuntus firewall (UFW) and Ubuntus Network Manager. Ubuntus local email and the way Ubuntu restarts services. Ubuntu uses vi not vim. But these arent major problems, the work a rounds and differences are fairly minor, you can email me or read my blog for help. For a step-by-step install, please use Debian 5.xx

Start by downloading and burning the latest stable Debian 5 .iso from http://www.debian.org/CD/http-ftp/ Or from my sever (32 bit) http://t3.woodel.com/my-linux-how-to/debian-503-i386-CD-1.iso (64 bit) http://t3.woodel.com/my-linux-how-to/debian-503-amd64-CD-1.iso

* You only need CD #1 , if there is more than one to choose from

*Due to upgrades some versions may no longer be available, if you run into this just use the links to my server, this will ensure matching printscreens. Or go to debian.org and find the newer link.

Before you begin the install Remove any unwanted \ unneeded hardware. Such as zip drives, sound cards, etc

Disable any useless BIOS options, such as com ports, integrated sound cards, etc Disable any Keyboard or Mouse warnings Disable any power management features If your BIOS has an OS option, choose Other

Remove all hard drives except the one youre planning on being the OS drive. This will ensure you do not format the wrong drive, and help make this how-to a little smaller and easier to follow. It is assumed you only have one network card at this point. If you have more than one, you may want to remove or disable them. The second NIC wont be used until the optional \ advanced sections, and can interfere with the eth numbering and firewall setup pre optional \ advanced section.

Boot the computer off the Debian install CD, and choose Install

Do not choose Graphical Install you dont want that, just choose Install.

Everything in this how-to is case sensitive, so if I use lower-case, then use lower-case. If you see something in capital letters, make sure to use capitals. Basically copy it exactly as you see it.

Choose a unique name for the computer, I did deb32server1 To me that means, Debian, 32bit, Server, first one of several Think of it as your computers first name, and on the next page we will set the last name. You can make something up, we will be referring to this computer by its IP address anyway so the name is somewhat meaningless, as long as the name is unique, so that you dont have a same name conflict with another computer on your network.

You can even use

deb32server1

just like I did

This is private to your network, it doesnt matter if you copy me exactly it may even help make the how-to a little easier to follow.

Choose a domain name for the computer, I did

diy.lan

Which to me means, Do It Yourself . Local Area Network You can make something up. Its almost like a last name for your computers. Its totally private to your network. But just like your family, youre going to want to have all the same last name on all your computers.

10

Which makes this computers full name Which to me means

deb32server1.diy.lan

Debian, 32bit, Server, first one of several, on a custom do it yourself Local Network

We will be referring to this computer by its IP address for now anyway, so this isnt too important at this point.

Much later on in the how-to, when we setup a Local Dynamic DNS server (which is optional and advanced) you might find it easier to follow the how-to, if you also use diy.lan It doesnt have to end with .lan you could make something up. I just think it will help the flow of the how-to if you chose something ending in .lan

11

Choose your time zone

12

Choose Guided use entire disk

13

If you removed all the other hard-drives pre install, you should only see one option here.

14

Choose All files in one partition

15

16

17

Choose a password for the account named root (choose a very strong password here)

18

Created a second user, so you dont always have to login as root. Here I used the name wood You can use anything you want

19

I like to keep the username the same as the full name, this can help avoid confusion later on.

20

Choose a password for the account you just created (Choose a very strong password here, this user will have more rights than a normal user)

21

22

23

24

25

You should be able to leave this blank, and click Continue If you have a proxy, chances are you would know what to do here anyway.

26

27

Using the Space bar on your keyboard, un-check Desktop environment. Make sure to un-check everything. With the exception of Standard

system

We will install most of these things later in the how-to, dont be tempted to click on them now. And most importantly, do not choose Desktop environment. This is a server how-to, not a desktop how-to.

28

29

Remove the CD, and press Continue

30

Did you see this screen? If not you probably didnt remove the CD. Make sure you are not booting off the CD anymore.

31

If everything goes right, you should get a lot of text on the screen and finally a login prompt like this one. Please ignore that mine says debian-1 at the bottom left. I am just at a different computer today. If you were expecting that to say; deb32server1 login : you are right I am just at a different computer today. Your screen will say your computer name, followed by a login prompt This wont interrupt the flow of anything at this point

32

Login as username root with the password you specified during setup. *Note, if you cant login as root, login as your username, and type sudo

before every command

33

Type vim /etc/apt/sources.list *Note, if you get an error, some versions of Linux might want you to type Then hit the Enter key on your keyboard (there is always a space after vim)

vi

instead of

vim

34

* If you dont see anything on the screen (the contents of that file) then you typed something wrong. ** When you see the screen above, you know you typed it correctly Press the insert key on your keyboard to allow you to type inside the file Use the # symbol to comment out un-wanted lines Comment out any lines that have cdrom in them

When you are finished press the Esc key on your keyboard, this will take you out of insert mode and should move your cursor to the bottom left of the screen

35

Then press the : key You should see this symbol on the bottom left of your screen

wq! So that it reads :wq!


Then type

In the bottom left corner of the screen

Then press the enter key It should then save the changes to that file, and exit you back to the command prompt. It will say something like filename written You wont need to use that vim editor very often after we complete the setup. But if youre stuck on it and cant get it to work. Do a Google search on Linux vi editor there should be some good examples that will help you on the previous page. Only if youre stuck.

36

What that did was tell the computer to not use the CD when looking for software. Now run apt-get update so it will both realize your cd-rom changes, and go look on the internet for the newest software sources. This only looks for new sources it doesnt actually go get them. (there is always a space after apt-get)

37

As long as youre connected to the internet, you should see something like this.

This next step is optional. After an do an apt-get upgrade

apt-get update you will almost always want to

Thats the command that actually goes out and installs the newest versions. But if you want your screens to match mine exactly, you might want to hold off on this step until your further into the setup and more comfortable with the screens. I will leave this as optional right now, and rest assured we will perform one later. Newer is better, but doing it now could put you at a version that doesnt match this how-to.

38

Pick your poison :- )

If you have chosen to upgrade now, here is how. Type apt-get upgrade for your computer. and it will go get any approved updates that are available

(there is always a space after apt-get)

If it finds something, you will probably be asked to type Either way, youre ready for the next page.

or

YES

and hit enter.

39

Now we are going to install some packages (software) Type

apt-get install samba smbfs ssh dhcp3-server openssl dnsutils apt-show-versions

(there is always a space after apt-get) (there is a space between each installer above) (this is the hard-way, later on in the how-to we will get into copying and pasting) Type it word for word

40

Its going to tell you that you need some additional installers, and it will prompt you to go get them. When asked make sure you type Y for yes and hit enter. *note, you do not have to specify whether you want 64 or 32 bit installers, apt-get will decide for you based on your system. This is an excellent feature.

41

The install of Samba is going to ask you a few questions on screen. A GUI box will come up, without any mouse support. So use the TAB key on your keyboard to move around it, and the enter key to choose things like next, continue, and OK.

Enter the same name you did before.

Im going to use

diy.lan

42

Choose No to this

43

The DHCP server software will warn you that its being installed as non-authorative. This is fine You will also get a warning during reboots that DHCP Server failed to start. This isn't an error and can be ignored it wont actually load unless we tell it to, so ignore any thoughts you might have about this for now. We will come back to it much later in the how-to. You are almost ready to remove the keyboard and the monitor. We just need to set a static IP address (or reserve a DHCP one) If you type ifconfig and hit enter, it will show your current eth0 (Ethernet) IP address (inet addr) as well as your MAC address (HWadrr)

44

You should see something like this.

45

If youre familiar with setting up DHCP reservations from your router, you just need the MAC address and you will know what to do from here. If youre not familiar with how to do that and just want to set a local static IP address, here is how. Note, later on in this how-to its assumed you have a static IP address, so you may want to setup a static address, even if you know how to do DHCP reservations. First chose an IP address that isnt part of your DHCP scope. For example, if your router is handing out IP addresses in a pool of 192.168.2.2 through -192.168.2.100 then you wouldnt want to use any of those available 98 addresss in that pool (.2 through .100) But you could safely choose anything above that pool, such as 192.168.2.101, 192.168.2.102, etc just as long as it isnt in the range of the available IP addresses to the DHCP server pool of addresses.

46

If you dont know how to check what IP range your router is handing out, just add 100 to the IP address you currently have. This is sloppy, but will most likely work. For example, if you automatically got an IP address of 192.168.2.72 its probably safe to set a static address of 192.168.2.172, as most address pools are not larger than 100 (100 higher than what you currently have) This is sloppy, but should work if this all sounds French to you. Giving this a lot of extra thought can help with future problems, for example on my network anything above a .100 address means its a server or printer of some kind. Anything above .200 means its wireless. Setting up meaning to these can be of great importance later on, as your network starts to grow. If all those numbers look French to you, just remember to make sure you give your Linux box an IP address that is on your same network. For example If youre on a 192.168.2.xxx network address 192.168.2.111 (replace 111 with the IP address you want) netmask 255.255.255.0 network 192.168.2.0 broadcast 192.168.2.255 gateway 192.168.2.1

If youre on a 192.168.1.xxx network address 192.168.1.111 (replace 111 with the IP address you want) netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 If youre on a 192.168.0.xxx network address 192.168.0.111 (replace 111 with the IP address you want) netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 gateway 192.168.0.1

47

If youre on a 10.10.10.xxx network address 10.10.10.111 (replace 111 with the IP address you want) netmask 255.255.255.0 network 10.10.10.0 broadcast 10.10.10.255 gateway 10.10.10.1

To enter a static IP address type (there is a space after vim)

vim /etc/network/interfaces

48

You should see something like this

Find the area that says iface eth0 inet dhcp hit the insert button on your keyboard Change it to say static instead of dhcp and add the following lines iface eth0 inet static address 192.168.2.111 (the IP address you want) netmask 255.255.255.0 network 192.168.2.0 broadcast 192.168.2.255 gateway 192.168.2.1

49

Thats it, you just have to tell the editor to save it Press Type

esc

on your keyboard, this should drop your cursor to the bottom left of the screen.

:wq! Press enter on your keyboard


If you did it correctly it should say something like filename written And return you to the command prompt.

Once you are back at the command prompt, type

reboot

and hit enter on your keyboard.

Your system should reboot, and load up the new ip address. After you login again as username root , type ifconfig the IP address you specified. and make sure eth0 is getting

50

Now go to different computer, running Windows, and make sure you can ping that IP address. Type ping 192.168.2.111 (or whatever IP address you gave it)

If youre not familiar with ping on a Windows machine. Just click on the start button and type cmd

51

In the black DOS like window, type

ping 192.168.2.111

Make sure it replies back from the IP youre pinging. If it comes back saying something like Destination Unreachable go back and figure out whats wrong. Look for typos Maybe your network card is eth1, and not eth0 Dont continue with the how-to until it replies.

52

Now go back to the Linux box, and make sure youre connected to the internet try to ping www.google.com It should reply back something like this, the numbers dont really matter, just make sure its replying.

You can hit control + c on your keyboard to make it stop pinging Thats the Ctrl key and the C key, hold down Ctrl and press the C key If it replies, youre connected to the internet

53

If it doesnt reply, check your internet connection. Make sure in your /etc/network/interfaces file, the IP address of your gateway is the same IP address as your router. If you have checked everything, and determined you are having a DNS issue. And that your Linux box is the only computer having this issue

You can edit the file /etc/resolv.conf by typing vim /etc/resolv.conf And add some name servers

You should see something like this

I got these numbers from dyndns.org http://www.dyndns.com/services/dynguide/readme.html

54

They provide some awesome name servers. Another good one is OpenDNS http://www.opendns.com

And just like before, to save and exit its Escape : wq! Enter

Or you can use the name-servers (DNS servers) from your ISP, that youre actually paying for. To figure out what your name-servers are from your ISP, launch another cmd window from your Windows computer, and type ipconfig /all

55

Look towards the bottom, for DNS servers, and use those IP addresses as your nameservers in /etc/resolv.conf

Once you can ping your Linux box, and your Linux box can ping www.google.com

You can go back over to your Linux box and shutdown by typing It will turn off, and you can remove the monitor and keyboard.

halt p

You may want to just remove the keyboard, and leave the monitor plugged in for now. So you can watch it power on \ boot up the first time, and make sure your computer isnt complaining that it cant find the keyboard. If it complains about the keyboard, go into your BIOS and tell it not to warn about missing keyboards or mice.

56

Once you sure it will boot up without a keyboard, you can go ahead and remove the monitor. Fight any temptation to plug the monitor and keyboard back in. doing so will hurt your learning experience, as its no longer needed. We will be accessing and managing the computer remotely from here on. So the rest of this how to will be completed remotely, using a Windows computer. You will be using two forms of remote management tools to access the Linux server. Putty is one of them and Webmin is the other. You will be using Webmin most of the time, until you get more familiar with Putty. You can download Putty from http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe Or from my sever http://t3.woodel.com/my-linux-how-to/putty.exe *Due to upgrades some versions may no longer be available, if you run into this just use the links to my server, this will ensure matching print screens, or go to http://the.earth.li/~sgtatham/putty/latest/x86/ and find the newer link.

You have to choose save, not run or open It isnt an installer, its a self contained exe, and has to be saved to the hard drive before running. We will use Putty to install Webmin onto the Linux box. Then you wont need Putty again until much later in the how-to. Launch Putty, and enter the IP address of the Linux box.

57

You should see something like this

Everything else is already configured correctly, just enter the IP address of the Linux box and click Open The very first time you connect, it will ask you if you want it to remember that you trust this computer you can say yes. If successful you should get a black box asking you to login. Login as username root. (We will continue to use root until the setup is complete)

58

You should see something like this

Once logged in, type or copy and paste the following commands To paste into Putty Window, all you have to do is right-click Once it is pasted into the Putty window, press the enter key on your keyboard. Your Linux box will run the pasted or typed commands. Say yes if prompted.

Paste in the following command, then press enter.

apt-get install apache2 vsftpd quota bind9 perl libnet-ssleay-perl


Paste in the following command, then press enter.

apt-get install libauthen-pam-perl libpam-runtime rssh libio-pty-perl

59

Paste in the following command, then press enter.

apt-get install libmd5-perl etherwake ntpdate libio-socket-ssl-perl


Paste in the following command, then press enter.

apt-get install monit libapt-pkg-perl ethtool exim4 rsync

This should take awhile to complete, after it finishes Type the following command mkdir /options and hit enter on your keyboard

This stands for make directory and will make a folder called options on the root of the hard drive. We are going to use this folder to download the webmin installer into.

60

Type

cd /options

and hit enter on your keyboard

This will put you into the options folder

Next we will use the wget command to download the webmin installer. wget + the full path to the location of a website file, will download that file

Type or paste

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.520_all.deb

and hit enter on your keyboard. (there is a space after wget) Or from my server wget http://t3.woodel.com/my-linux-how-to/webmin_1.520_all.deb *Due to upgrades some versions may no longer be available, if you run into this just use the links to my server this will ensure matching print screens, or go to webmin.com and find the newer link by right-clicking the download link, and viewing its properties.

61

Once you have the http path to the Webmin installer, type

wget http://xxxxxxxxxxxxxxxxxxx

and hit enter

62

You should see it start to download the file, and will show you the download progress. You should see something like this

It will download it to the current folder that youre in, so it just downloaded it to the /options folder When it finishes downloading, type dpkg i webmin_1.520_all.deb Or dpkg i /options/ webmin_1.520_all.deb if newer version or and hit enter on your keyboard.

dpkg i /options/webmin_x.xxx_all.deb

That stands for Debian Package Install, and will install the Webmin program packaged for Debian. If it tells you youre missing something, just type apt-get install those-things-it-says-your-missing and hit enter on your keyboard.

63

It will remember you were trying to install Webmin, and will finish installing it after any missing packages are installed. You should now have Webmin installed, and can exit out of Putty by typing exit or logout To login to Webmin, open Internet Explorer or Firefox and type your IP address, followed by :10000 proceeded by https:// https://the-ipaddress-of your-linux-box:10000 For example if your Linux box IP address is 192.168.2.172 you would type https://192.168.2.172:10000 *Note, If you have been following along, you probably expect my IP address to be 192.168.2.111 or 192.168.2.172 (your right) Im just at a different office and server today. In the example below, this Linux box is now 192.168.2.1 https://192.168.2.1:10000 so I need to type

You would type the same thing, but with your IP address instead.

64

You will probably get a warning telling you not to trust the webpage. You can ignore this, its completely secure. Its just your using a self signed ssl certificate, and not a paid one. This is still completely secure from within your internal network. If you have problems with this later on, switch to Firefox. With Firefox you can choose to save the certificate so youre not always prompted. In Internet Explorer you just have to choose Continue to this Webpage every time. You should see something like this

Its safe, just click continue

65

You should get to a screen that looks like this

With all of your management tools are on the left. You can do almost everything from here, Webmin is an extremely powerful tool.

I like to use a combination of Putty and Webmin to administer my Linux servers. But since this how-to is about doing it all through Webmin, we will stop using Putty, and start using the SSH module within Webmin when needed. The copy & paste works best in Putty, so if you see me switch back to Putty, its because I want you to copy \ paste a command, simply to avoid a hand cramp or typo. I just wanted you to have the experience of using Putty, in case you lock yourself out of Webmin, and to hopefully influence you to learn Putty, and learn command line later on down the road.

66

First thing we have to do is remove the current SSH module that came with Webmin, it has outdated ciphers in it, and will not work. To remove the SSH Webmin Module, click on Webmin in the top left corner and choose Webmin Configuration

67

Next click on the icon that says Webmin Modules

68

Once inside the Webmin Modules page, click on the delete tab towards the top

Choose SSH Login and then click on Delete Selected Modules *Make sure you dont accidently choose SSH Server, its SSH Login you want to click on

69

Put a checkbox in the Remove from users and reset control settings and then choose Delete

70

If successful, it should say the module was successfully deleted

Thats it, its uninstalled. Now we have to install the new one.

71

Click on Webmin in the top left corner and choose Webmin Configuration again

Click on the icon that says Webmin Modules

Make sure youre in the Install tab of the webpage And choose from ftp or http URL And paste the following URL into the box to the right

72

http://www.webmin.com/download/modules/ssh2.wbm.gz Or from my server http://t3.woodel.com/my-linux-how-to/ssh2.wbm.gz *Due to upgrades some versions may no longer be available, if you run into this just use the links to my server, this will ensure matching print screens, or go to webmin.com and find the newer link.

Click on Install Module and Webmin will go get the module file, and install it

73

If successful you should see something like this, telling you it put it in your access control list, under the category Others

Click on the Others category on the left menu and choose SSH2 Login The SSH2 Module will begin to open If youre ever prompted to install Java, its talking about the web browser on your Windows PC, not Java for your Linux box. Just go to http://java.com from your Windows PC and run the install if needed. If youre using Firefox, you may need to do this after every time you upgrade your browser.

74

Once you see the MindTerm logo below, youre good to go. Just hit the enter key on your keyboard, and you can login using username root

If you still dont see SSH2 Login, try hitting the Refresh Modules button at the bottom left, and or looking under Un-used Modules.

75

If you dont like this single window view, you can click on the Module Config button and tell it to open in separate window.

76

Make the following changes Then Click on Save and the next time you launch the SSH2 Module, it will open in its own little window.

77

Here is what it will look like in separate window mode

Click enter on your keyboard, and login as root

78

This should look familiar to you, it works almost the same as Putty. When youre done, type

logout

and press enter on your keyboard.

Wait 10 seconds for the logout to happen, then you can hit the X in the right hand corner to close the window. This will be helpful when you want to run a command, that answers you back, asking a question, like are you sure or hit yes to continue

Webmin has a built-in command shell, that works awesome. And most commands have a built in yes option that can answer some prompts. But it doesnt allow you to interact and answer questions the way this SSH2 Module and Putty can. Putty allows you a much wider copy\paste range than this SSH2 module. So if youre a copy and paster, you will like Putty much more (right-click = paste in Putty) Again, I would encourage you to use Putty instead of this, but this particular how-to isnt about that :- )

79

For the next step we are going to use Webmins built in command shell. Its super convenient when you dont need to interact with the answer. Click on Others and click on Command Shell

We are going to execute the command mii-tool Type

mii-tool

in the box and then click Execute Command

80

You should see something like this

The grey area is where it will show you the results of the command. We need to make sure youre getting a full duplex connection and not half duplex

If yours answers back full duplex then youre all set, and you can skip this part of the how-to. If it says half duplex then do not skip any pages If you simply got an error, that means mii-tool doesnt support your network card, this isnt a problem. Just run the command Click on Others click on Command Shell and Execute command ethtool eth0 (there is a space after ethtool) (thats eth ZERO, not eth OH) ethtool eth0

81

If it says Duplex: Full

then your good to go, you can skip the commands below.

If it says Duplex: Half then do not skip any parts, you must fix this.

If mii-tool told you that you had a half duplex connection, then the fix is to add the following line to the /etc/rc.local file mii-tool F 100baseTX-FD eth0 If that doesnt work, try ethtool, ethtool is better for newer network cards anyway. If you got an error running mii-tool, and or if ethtool eth0 told you that you had a half duplex connection, then add the following line to the /etc/rc.local file ethtool s eth0 speed 100 duplex full autoneg off

82

Here is how to edit that file the Webmin way, using the File Manager (youre going to like this) It makes everything a lot easier Click on Others and then Click on File Manager

Click on the etc folder and then in the right side window, scroll down until you find the file name

rc.local

This file is executed at startup, so we can use it to make changes that happen every time the computer restarts.

83

Single click on the rc.local file (do not double-click) double-click will try to download the file, that isnt what you want. Single click the file, so that it is highlighted, then using the buttons along the top, choose Edit A new window should open, and will let you edit the contents of that file.

You should see something like this

You can type directly into that window If mii-tool told you that you had a half duplex connection, copy and paste this above exit 0 mii-tool F 100baseTX-FD eth0 (if you know the card is giga-bit, use 1000base in place of 100 in these commands)

84

You should have something like this

Click Save & Close and thats it, the file is edited, all you need to do is reboot, I will show you how to do that on the next couple pages.

If mii-tool gave you an error and or ethtool eth0 told you that you had a half duplex connection, then edit the rc.local file and copy\paste this instead ethtool s eth0 speed 100 duplex full autoneg off

85

Click Save & Close and thats it, the file is edited (if you know the card is giga-bit, use speed 1000 in place of 100 in these commands)

86

If you have skipped to this page, you missed how to use the Webmin File Manager to edit files. We are going to do it again so that everyone is on the same page. Click on Others and then Click on File Manager

Click on the etc folder and then in the right side window, scroll down until you find the file name

rc.local

This file is executed at startup, so we can use it to make changes that happen every time the computer restarts. Single click on the rc.local file (do not double-click) double-click will try to download the file, that isnt what you want.

87

Single click the file, so that it is highlighted, then using the buttons along the top, choose Edit A new window should open, and will let you edit the contents of that file.

You should see something like this

You can type directly into that window Somewhere above the exit 0, copy and paste this # hello world

88

You should have something like this.

Click Save & Close and thats it, the file is edited We put a # in front of hello world so that it would ignore that line, Linux ignores lines that start with a # And in most cases, will ignore lines that start with a ;

Now we are going to use Webmins Bootup and Shutdown module to reboot the computer.

89

Click on System click on Bootup and Shutdown then scroll down to the bottom and click Reboot System

It will ask you if your sure, tell it to do it, then computer should reboot, at that point your screen will be un-usable while it reboots. Just wait about 5 minutes and you should be able to use Webmin again.

Assuming the reboot went OK, lets go back to the File Manager and edit some more files.

90

Click on Others and then Click on File Manager

We need to disable IPv6, this how-to later on assumes youre only using IPv4 Lets edit the file /etc/modeprobe.d/aliases (*If youre using Ubuntu, this file may not be needed, or may be called aliases.conf)

(you can tell by the line above its a file named aliases inside the folder called modprob.d which is located inside the etc folder.

91

Change the line #alias net-pf-10 ipv6 To alias net-pf-10 off

92

Make sure you remove the # from the beginning, or Linux wont read it. Click on Save and Close

93

Next lets edit the file /etc/modeprobe.d/blacklist

(*If youre using Ubuntu, this file may not be needed, or may be called blacklist.conf)

Adding the line blacklist ipv6 Click on Save and Close

So far we have stopped it from loading, and stopped it from coming back after upgrades. We are done with disabling IPv6, and can move on to something else.

94

It is good practice to make comments in these files, of the changes you make, like #Changed by Kevin, from ipv6 to off But since you have this how-to to refer back to, there isnt much point in making any comments. But it is a good habit to get into once you complete the how-to, and start editing files on your own. This is a good time to mention a few quarks about computer names in Linux. The Webmin installer probably told you that you can access your machine from And you probably found that didnt work. https://your computers - name:10000

This isnt a Webmin problem. Anytime you switch from DHCP to static, or switch from one static IP to another, there are a few files you need to edit. As these files are expecting to get this information from the DHCP server, but static IPs dont communicate back with the DHCP server. /etc/hosts (replace 127.0.1.1 with your Linux boxes static IP address)

*not to be confused with 127.0.0.1 you want to edit\replace 127.0.1.1

Click on Save and Close

95

Then edit /etc/hostname

(make sure its right)

96

Then edit /etc/resolv.conf (make sure your router is listed as one of the nameservers, and that its searching the right local domain)

Click Save and Close Reboot your Server, and the computer name should now be playing nice with your static IP address. This is just the foundation, it wont actually come into play until we configure Samba later on in the how-to, but you now have the right settings for using names along with static IP addresses.

Next lets familiarize ourselves with the Upload and Download module for Webmin. This isnt a very fast way of sending \ receiving files, because of the https encryption Webmin is using. That level of encryption is an awesome thing, and it keeps your passwords very safe from prying eyes. But inside your local network it can be a little over-kill, and will really slow you down. But once we cover it, we can move on to the faster and more convenient ways, like ftp, http, and Samba file shares.

97

Inside of Webmin, click on Others and then Click on Upload and Download

You should see something like this

This module is pretty easy to use, just make sure you change the Download to file to directory field to be /options

This will make it much easier to find files that you upload \ download to the Linux box.

98

Lets walk through it once, click on the Upload to Server tab at the top

Assuming the file you want to upload is located on your Windows PC. Just make sure to change the Download to file to directory field to be /options Then browse to the file you want to upload Click Upload and it will upload it to the /option folder on your server.

99

You can then browse to it using the File Manager Click on Others and then Click on File Manager, and then click on options

Or if the file you want to upload to the server is located on a the web, and not on your Windows PC Go back to the Upload and Download module, and choose the Download from Web tab instead. They work the same way, the file will end up in your /options folder.

Just make sure to change the Download to file to directory field to be

/options

100

And then paste the URL to the website\file you want to download Into the URLs to download field

You wont always know the URL to the file you want, but you should be able to right click on it from your Windows PC, choose properties, and copy and paste the URL into the URLs to download field

101

Paste it into Webmins Upload and Downloads, URLs to download field

102

You probably noticed how very slow that was, thats again due to the encryption, we will speed all that up later on in the how-to Using the File Manager, you should be able to see your newly uploaded file

103

Lets edit some more files Lets edit the file /etc/ssh/sshd_config (to limit the users who are allowed to SSH)

Make sure there is a d in there, this isnt the same as ssh_config, you dont want that, you want to edit sshd_config

104

You should see something like this

Somewhere towards the bottom, add the following line AllowUsers root wood Replacing wood with whatever username you created during the install

Anyone that can SSH can browse all your folders and list all your files, so it's extremely important to limit that. Basically dont give anyone but yourself SSH access. Dont give anyone but yourself Webmin access

105

Later in the how-to we will cover rssh for users That stands for Restricted SSH, and does work as promised. Later in the how-to we will cover Usermin This is a Webmin like interface, but can be locked down for users But basically, dont ever give someone else Webmin or SSH access, it not a good idea until you have mastered Linux and are comfortable with file permissions and jailing home directories. We will even be taking access away for root later on in the how-to. That way youre not ever typing that password over the internet. But for now, during the initial setup on your local network, its ok.

Next we are going to install the second hard-drive (the data drive) and use Webmin to mount it.

Everything in Linux is treated like a file or a folder. So when you are adding hard-drives, you go through a mounting process, which makes that drive appear as a folder amongst the other folders on your system. This can be a little strange at first, but if you do some good planning on your folder names, it can help with some of the confusion.

106

Lets start by powering off the Linux box. You do this the same way you restart it using the Bootup and Shutdown module, but just choose Shutdown System instead of Reboot.

This how-to assumes you know how to physically install the second hard-drive, go ahead and do that now. When you done, use the computers power button to turn it back on.

107

Wait about 5 minutes then you should be able to get back into Webmin. Using the File Manager module create a folder called

/mymounts

As you can probably guess by the name, this folder is going to contain drives that you have mounted. The system mounts a lot of drives and partitions for you, as well as the CD drive, Floppy drives, etc to help avoid some of the confusion of mount points, you will know anything inside this folder is actually a separate device (hard drive or partition) that you mounted yourself, this will help refresh your memory every time you navigate to it.

The forward slash / just tells it to be its own folder, at the root, on the beginning of the drive, and not a subfolder of some other deeper folder.

Just make sure to choose the new folder button, and not new file, and dont be tempted to click on mount, that isnt want you want

108

You should see something like this when youre done

109

Now go inside the mymounts folder and create a folder called d2p1

You should see something like this when youre done

d2p1 stands for (drive two partition one) Its the second drive in the system, and its the first partition on that drive

110

So what this folder structure means is. Its something you mounted yourself, because its in the mymounts folder. And its the second drive inside the computer, and is the first partition on that drive. (If you had a second partition on the second drive, you would mount that in /mymounts/d2p2) a third drive would be /mymounts/d3p1/ and so on

We need to format the second hard-drive. We need to so this before mounting it, because when its mounted, its considered in use. So pre-mounting, lets format it. Using the Webmin module Partitions on Local Disks

Click on your second hard-drive, if you have followed the how-to exactly, it will be the second one in the list (B) Click Device B (assuming that is for sure your second hard-drive)

111

You should see something like this

Click on Number 1 (There should be only 1 number, if there is more than 1, click on them and delete them) (Triple check you are on Device B though!)

112

You should see something that looks like this

Change the Type to Linux Then click Save. This will kick you back to the main screen again, where you will have to click on device B again

Click on device B again And next to the Create Filesystem button change that to Linux Native (Linux Native = filesystem ext3 as of the date of this writing)

Write down your device file name, on mine its /dev/hdb1 This stands for device , hard drive B (B meaning 2nd) , 1 (meaning first partition)

If you have a newer computer, it will most likely list them beginning with an S (example sdb1) Meaning it thinks it a SCSI or SATA disk. Then click Create Filesystem

113

You should see something like this.

Dont check for bad blocks, it takes way too long and the webpage will time out We will talk about how to check for bad blocks later in the how-to

Then click on Create Filesystem

114

You should see something like this

This can take hours to finish

If it fails, just run it again.

115

If successful, you should eventually see command complete at the bottom of the screen.

Now that its installed and formatted, we can mount it.

116

Using the Webmin module Disk and Network Filesystems

Change the Type box next to the Add mount button to Linux Native Filesystem ext3

117

Then click the Add mount button

118

You should see something like this

119

You should see something like this, Make the following changes In the Mounted As field type

/mymounts/d2p1

Change Check Filesystem at boot to Check First

In the Other Device field, check the button so it knows to use that field, and put the actual device name of the second hard-drive. *If you forgot what is was, refer back to previous section. On mine its /dev/hdb1 This stands for device , hard drive B (B meaning 2nd) , 1 (meaning first partition) If you have a newer computer, it will most likely list them beginning with an S (example sdb1)

120

Meaning it thinks it a SCSI or SATA disk. If you get confused just refer back to the previous section, it will show you how to check what your device name is.

Change Use Quotas to User only

If successful, you should see it listed in the next screen

121

Sometimes in this how-to I will have you do things the hard way, or the long way. When it will help you to understand some of the more confusing tasks. Like for instance you probably already wondering why I didnt have you install Putty much much earlier, so you could have copied and paste straight from this how-to. But then you wouldnt have learned how to type them correctly. You probably also saw a few options that would have made mounting easier, like this button

122

But then you wouldnt have learned the \dev\ device names

Or maybe you saw this window during the format

But if you would have used that mount button, you wouldnt have seen how to enable the Quotas. So even if you see a shortcut, try to follow the how-to exactly, because Im going to make assumptions later on in the how-to, that certain things are already enabled. And if you skip any of these steps, you could get lost and have to start over.

123

You done with the mounting part, the second hard drive is now accessible from the File Manager module, under /mymounts/d2p1/

Just for practice, lets put a file in that folder, this will be an example of putting files on your data drive (hard drive #2) Using the File Manager, copy and paste a file from the /options folder to the /mymounts/d2p1 folder

124

Click the file once to highlight it, then click Copy from the toolbar above Navigate to the /mymounts/d2p1/ folder, and paste it using the Paste button from the toolbar above

If successful, you should see something like this

And that would be an example of saving a file to hard-drive number 2

125

If you ever need to un-mount it. (You shouldnt ever need to do this) except maybe to re-format it or scandisk it. Just navigate back to the Disk and Network Filesystems module, and click on /mymounts/d2p1/

126

Check the Save option so it keeps a record of it, then click the Unmount option

Then click Save at the bottom, and it will un-mount the drive. And because you checked the save option you can easily re-mount it by coming back to this page and choosing Save and mount at boot and mount and then click Save at the bottom. Thats it for mounting and un-mounting. Again you shouldnt ever need to un-mount it, but you know how if you need it.

Next lets make sure your Linux box has the right time, and set it to automatically sync up with a time server at midnight each night.

127

Using the System Time module, set the time and date for both fields to be correct. You only have to do this manually once, keeping in mind that its a 24 hour clock.

We have to do it manually once, because the sync feature doesnt work if the time is off by more than a couple of hours, so we do this to ensure the time is almost right, so the sync will work and always keep it accurate. Dont be tempted to use the Set system time to hardware time or the other one, just set each one manually. This should work, but if youre getting errors manually setting the time you can do it the command line way like this (using the SSH2 module) ntpdate pool.ntp.org

128

Once both are set right, navigate to the Time server sync tab at the top right.

129

You should see something like this

Set the Timeserver hostname or address field to the timeserver closest to your area

1.us.pool.ntp.org
*If youre having DNS issues you can use IP addresses here until you fix that. Check the box that says Set hardware time too Check the box that says Yes, at times below Check the box that says Simple schedule and Daily at midnight You can ignore all the time tables below, because youre using the simple schedule above. Click Sync and Apply at the bottom of the screen, and your all set

130

You should be able to navigate back to the Set time tab at the top, and see that it did in fact set the correct time for both fields. Youre all done with setting the time. *If you get errors about the hardware clock not being set, you may have to enable the following at boot time, and then reboot. Only do this if you are experiencing problems with the hardware clock. Navigate to the Bootup and Shutdown module, place a checkmark next to hwclock.sh and click Start Now and on Boot

131

Thats about it for the time settings. Next lets make sure your MTU is set right on your network card. You usually wont see a problem here unless you have multiple NICs, but let make sure anyway. Using the Command Shell module, run the following command ifconfig eth0 then click the Execute command button

132

You should see something like this

For most purposes your MTU should be 1500, if yours comes up right you can skip this part of the how-to. It should have found the right setting for you automatically, Ive only see it get confused when there is more than one NIC. There are some DSL setups that are not 1500, you will have to Google your current situation to find your correct number. 1500 is right for LAN setups and all the major Coax Cable Modem ISPs. This is an advanced problem, but if you have exhausted all other options, here is how you can force the right setting.

133

Using the File Manager module. Edit the file

/etc/network/interfaces

and make the following edits

up /sbin/ifconfig eth0 mtu 1500

134

The placement of that line is important, make sure you put it under the iface command, and make sure if you have two or more NICs that you put it on the right line for that particular NIC. (example, eth0, eth1, eth2, etc..) and of course you would change the command to reflect the NIC number (example : up /sbin/ifconfig ethx mtu 1500)

Again, this is a more advanced problem, make sure you have exhausted other easier fixes first.

Thats it for MTU Now we are going to talk about an optional install, called md or mdadm

md is a software RAID, usually called a fake raid. It can do most everything, but expect a little performance loss, as it doesnt actually use a real hardware raid controller, it just mimics it. So as awesome as it is, its doing the job twice, so limit your expectations accordingly.

You can install this if you want, it does work extremely well. I would just caution you to not use it unless you have a real need for it. For instance, it can group many smaller hard drives together to form one big one. But if you are going to setup a bunch of folders and organize the drive, dividing the data into categories. (example: Folders such as images or software) you could just designate each drive for those categories, and have an Images drive, and a Software drive, and not have to deal with a RAID configuration at all. Another wasted use of this program is setting up RAID 0 Raid 0 is a performance raid, and since you are faking it, you may want to think twice about using this feature. If you looking to combine 2 or more disks into 1 large disk, use concatenated-linear setting (often called JBOD Just a Bunch Of Disks) in the RAID configuration and not RAID 0. But again dont waste your time joining smaller disks if youre going to organize the data into categories that could have fit on the single drives.

RAID 1 is nice, its a 2 disk setup, that is an exact copy of each other. But even with this simple convenient raid, there are many reasons to not use it. Youre adding another disk to the system, so you just doubled your chances of having a bad hard drive, so its almost like your preventing something youre causing. And if youre truly worried about backups (as you should be) you should be doing offsite backups, backups to another computer, external backups. All of these things are superior to raid, because if that computer is involved in a fire, earthquake, flood, etc your RAID is toast. And if your system gets a virus, youre just going to have a bunch of copies of infected files.

135

Where raid really saves you, is when youre lazy with your backups like I am or when you have a real hardware raid solution, that is doing all the work, leaving the computers resources available for computing. mdadm is amazing, but dont use it if you dont need it Dont get me wrong, I use RAID, I love fake RAID, I use this mdadm everyday, its awesome. Just dont set it up if youre not getting the right use out if it. And there are only 4 configurations I would use with fake raid. RAID 1 (mirror, 1 can go bad) or Concatenated-Linear (joining of multiple disks that are so small they are useless, to make one large useable one, just make sure you have a backup, there is no redundancy here) RAID 5 (3 disks, 1 can go bad) RAID 6 (4 disks, 2 can go bad) If you have decided you want to, here is how. If not, you can skip this section.

Using the SSH2 Module, or Putty (preferred) run the following command

apt-get install mdadm

It will probably ask you to say Y or Yes The install will later pop up a GUI window asking you some questions.

136

Using your keyboard, Tab down to the word OK and then hit enter on your keyboard. The screen will look a little fuzzy and off centered, this SSH2 module doesnt handle these GUI pop ups very well. If your screen is totally unuseable, you can use Putty instead. But for the most part, you should be able to follow along.

Next its going to ask you which RAID configs you want it to start, erase ALL and type NONE. Because we are going to use Webmin to configure it.

Once you have the word none typed in there, tab down to OK and press enter on your keyboard.

137

If your cursor is giving you a hard time, it might help to type noneeeeeeeee in the field, and then backspace the extra eeeeeee until it reads just

none
Then it will ask you if you want the raid config to start automatically, tab over to YES and hit enter. This will cause an error at boot up, but its ok, its just telling us we havent configured it yet (we will do that later in Webmin)

138

Once you answer yes, it will take a couple minutes to setup. Then you should eventually get back to the normal SSH2 Module screen, where you can type halt p to shutdown the computer.

139

Once the computer shuts off you can physically install the additional hard-drives.

Using the Partitions on Local Disks module, format any of the new drives to ext3, just like you did on previous section.

If the second hard-drive you install earlier in this how-to is going to be part of this RAID configuration, then you have to un-mount it first. Navigate to the Disk and Network Filesystems module and un-mount it. And this time, tell it to not remember the configuration. This will make it available for RAID.

Once you have them all physically installed, formatted, and un-mounted (if needed) then your ready to configure the RAID using Webmins Linux RAID module.

140

If you do not see the Linux RAID module under other, try hitting Refresh Modules at the bottom left of the screen.

It will look for a couple minutes

141

And the next time you click on the Hardware tab, it should be there.

Enable Monitoring, Enable sending notifications, Send them to your username@localhost and click Save

142

Choose a RAID configuration, in the drop down menu next to the Create RAID device level of button.

Again, for a fake software raid, I would only recommend RAID 1, or J.B.O.D. (Concatenated Linear) unless you have some incredibly fast SATA or SCSI drives, then RAID 6 would be the highest I would go with the fake software raid.

Chose whichever one will work for your situation, and click the Create RAID device level of button. All these RAIDs do work awesomely, Im just saying limit your expectations down to what your hardware can handle.

143

You should see something like this (this is an example of Concatenated Linear) We are joining a 40GB and a 20GB disk together to act like a single 60GB disk.

Set Force initialization of RAID to yes And in the Partitions in RAID field, you have to select the participating disks. They appear to be selected, but they are not. You have to click on them with your mouse. In order to select the second disk, just hold down the control key on your keyboard when selecting the second disk. Click the Create button, and it will create the RAID for you. This can take a very long time. If youre doing Terabyte disks, go to sleep :- ) As you can see its going to treat it as /dev/md0 And earlier in this how-to, you learned how to mount /dev/xxx into folders, so you already know how to mount this virtual raid into a folder for use on your system.

144

You should eventually be returned to a screen that looks like this, if it shows your correct RAID configuration, then youre ready to format it.

Click on the device name, /dev/md0

145

You should see something like this.

Change the drop down box to ext3, and click Create filesystem of type button

This should take a long time, and do not be tempted to use the Mount RAID on button you see above. If you do that you will miss a few important options that are only available by doing it the long way that we covered earlier.

146

You should see something like this

Dont chose check for bad blocks, it will take forever, and the webpage could time out.

147

If successful, you should see something like this

148

You just have to mount it now, as Linux ext3, using the Disk and Network Filesystems module like you did earlier. A good folder name to use would be /mymounts/vraid That name lets you know you mounted it, and that its a virtual or fake raid. You want to use the File Manager module to create that /mymounts/vraid folder first, before you attempt to mount it using the Disk and Network Filesystems module.

149

Here is what it should look like, make the following changes.

Then hit the Create button

150

If successful, it will look like this, and be accessible as a folder in /mymounts/vraid with almost 60GB free space (40GB harddrive + 20GB harddrive)

This is a very small example, I have done multiple Terabyte raids, and they work great. Just make sure you really need it, and are getting a good use out of it. For those of you that skipped to this page, I created a new data drive, in a RAID configuration. Im no longer using /mymounts/d2p1 as my data drive. Im using my virtual raid setup of /mymounts/vraid The how-to will continue to reference the /mymounts/vraid folder as my data drive. Whereas on your system, if you skipped the raid how-to, you will need to be thinking /mymounts/d2p1/ This shouldnt interrupt the flow of the how-to, we are still talking about that same thing, a folder, that is really a second hard drive mount point, that contains our data. Thats it for the data drive, now lets configure the web server (Apache)

151

The web server is already running and functioning, if you type the IP address of your Linux box into a browser window, you should see it displaying something like this.

By default the web server listens in folder /var/www/ and looks for a file called index.html There is already a file called index.html in that folder, that file has the words It works! Inside of it, thats why you see that on your screen.

If you were to delete that file, and replace it with your own index.html file, it would display that instead.

152

So lets use the File Manager module to delete the contents of the /var/www/ so we can replace it with our own index.html file, for our own custom website.

Next you need to create your own index.html file. There are countless ways to do this, in this how-to we are going to use Microsoft Excel to make the webpage file and save it as filename index.html. But if you Google html editor, you will find millions of other ways to achieve this.

153

Launch Excel, and put some words and colors on there.

154

Choose File Webpage Preview to see a preview of what it will look like. Then if you like it, choose File Save as Webpage when you done

And save it as file name

index.html

155

156

Now using Webmins Upload and Download module, upload that index.html file to the /var/www/ directory.

Click on the Upload to server tab Change the File or directory to upload to /var/www/ Then click the Browse button

157

Then browse your Windows PC for that index.html file you created. And choose Open

158

Then click the Upload button

Thats it, it will upload the file to the directory, Apache is listening in that folder, and will read that file the next time you visit your website.

159

To see it, just open a browser window and type your IP address again, and viola, your own custom webpage running on your very own web server, for free.

160

If you didnt want a webpage showing, but instead wanted a file chooser type of view, you could delete the index.html file, and any files you uploaded to the /var/www/ folder would show up in a download like view, like this. This way your users can see what files you have available for download, and can download and navigate just by clicking on them.

------------------------------------------------------------------------------------------------------------

161

Which looks like this from your File Manager view

Or, you could have both a webpage and the file download view by making a deeper subfolder called files and putting the files you want available for download in there.

162

Just put your index.html file back in /var/www/ So when people go to your IP address, they see your webpage file

163

But when they go to you IP address /files (http://192.168.2.1/files) they see this

Which would look like this from your File Manager view

Thats pretty much it for a basic Apache web server setup, it works right out of the box. If you want to be able to setup passwords, so that people cannot get to certain websites or folders without a password, here is how. We are going to install the Protected Web Directories module from Webmin.com

164

Go to http://webmin.com/standard.html from your Windows PC, and look for the module.

Right click on the link that says

htaccess-htpasswd.wbm.gz

and choose Properties

165

This will give you the URL you need

166

Highlight and Copy that URL

167

Now go to the Webmin Configuration module

168

Double-Click Webmin Modules

169

Make sure youre in the Install tab of the module page. And choose from ftp or http URL And paste the following URL into the box to the right http://download.webmin.com/download/modules/htaccess-htpasswd.wbm.gz Or from my server http://t3.woodel.com/my-linux-how-to/htaccess-htpasswd.wbm.gz *Due to upgrades some versions may no longer be available, if you run into this just use the links to my server, this will ensure matching print screens, or go to webmin.com and find the newer link.

170

Click on Install Module and Webmin will go get the module file, and install it

171

If successful you should see something like this, telling you it put it in your access control list, under the category Others

172

Click on it, you should see something like this

But we arent ready to use it just yet. We have to make a change to our Apache configuration file, before it will allow password files to be used.

173

Using the File Manager module, edit the following file.

/etc/apache2/sites-available/default

174

Change the following two lines from AllowOverride None to AllowOverride AuthConfig

Click the Save and Close button.

175

Then use the Bootup and Shutdown module to restart Apache (called apache2)

Click

Restart

*Advanced* If you know youre not going to use apple-talk on your network, you can disable it on this page By putting a checkmark next to netatalk and choose Disable Now and On Boot

If you know you dont need it, this will speed up the boot time and free up some resources

Once its been restarted, navigate back to the Protected Web Directories module

176

And click on Add protection for a new directory

Directory meaning folder

In this example we will password protect the files folder on your website

177

After you click on Add protection for a new directory You should see something like this, make the following changes.

In the Directory path type

/var/www/files

Because that is the directory we are wanting to password protect Set the File containing users button to In the selected file field type selected file

/options/.htpasswd-4-var-www-files

Notice there is a dot in that filename. Thats important, it means hidden.

178

Its going to create this file for you, but it wont create folders for you. So make sure your specifying a directory that already exists, like /options

In the Authentication realm type

Restricted Area .htpasswd

Usually you would name the file containing users Thats the industry standard.

But we named it Or

.htpasswd-4-var-www-files

/options/.htpasswd-4-var-www-files Meaning to me, its in the /options folder

179

I like to name it more descriptive then just .htpasswd, because I tend to have three or four of these files protecting different directories and with different passwords.

In Linux the leading period or dot in front of a filename means its a hidden file So when I see the filename .htpasswd-4-var-www-files we know its a hidden password file, protecting the folder /var/www/files

So if I were going to protect a second folder, something like /var/www/photos/wedding I would name the file containing users .htpasswd-4-var-www-photos-wedding Or /options/.htpasswd-4-var-www-photos-wedding Meaning the answer to the password for that directory is in the /options folder

Once you have it all filled out, click the create button

180

If successful, you should see something like this

181

So the structure is all there, now you just have to add usernames and passwords to it. Click on Add a new user

You should see something like this

Here you can add as many usernames and passwords that you want. These arent real accounts on your server. You can make something up here, these are just password prompts on your websites. For instance, maybe you had family photos in that files folder, and you only wanted your family members and your friend Ed to see them. You could add a username and password like Username: Password: my family

And another one like Username: Password: ed 12345

182

Whenever someone tries to your website, it works just fine.

But if they try to go any deeper into your website, or are sent a deeper link. like /files. Then they are prompted for a password

183

And if they enter the right username and password here, they will be able to see the files inside the files folder (directory)

184

Its a good idea to use made-up usernames and passwords for these websites. By made-up I mean not actual usernames and passwords that youre using as accounts on the server. These website passwords are sent over the network and internet in plain text, meaning its easy for a hacker to see the username and password that youre typing, so dont use a username and password here that actually has an account on the server. This isnt a huge deal because (at this point) you shouldnt be exposing files to the internet that you dont want people to see. Not over an http website anyway. If youre doing really private information make sure youre using the Webmin File Manager module, or something else that uses ssl (https) or ssh. Youre not going to provide Webmin access to your users, so later on in the how-to we will cover how to allow your users to securely transfer files using https. The s stands for secure and will secure the transfer using ssl. These http (non s) website passwords above will keep 95% of people out, but you would be putting yourself at a huge risk if you put anything confidential on a non https website. And as a rule of thumb, dont expose anything confidential to the internet. And never type your password on a website that isnt https. And never type your password on a website you dont know, trust, and recognize. Without the s your sending them in plain text. So a hacker would see your typing just as you see the words in this sentence. Later on we will cover how to do it securely, but at this point dont put any confidential files on your web server, and dont type usernames and passwords that matter, over a non https connection. No worries about Webmin and Putty, they are safe, Im mainly talking about http and ftp sites.

185

And if you ever want to remove the passwords permanently, you can use the Protected Web Directories module, and click the Un-protect and Remove Files button

Apache is very powerful and can do a million more things. Later on in this how-to we will change its listening directory from /var/www/ to our data drive, so that files on our data drive can be accessible over the web. Later on in this how-to we will also create users whose home directories are on the data drive, so they will be able to upload and download their files, over the web, all residing on the data drive. You can probably see where this is going. Your users will have a home directory on the web. Often referred to as web space. But with a lot more functionality. They will be able to FTP, build websites, use the secure https File Manager, change their passwords, see graphs on how much space is available, have disk space Quotas, etc all over a webpage.

186

Lets configure the FTP server (vsftp) Using the File Manager module, edit the file /etc/vsftpd.conf

187

You should see something like this

188

You need to make the following changes to it

Change line 23 from anonymous_enable =YES to anonymous_enable =NO Uncomment line 26 by removing the # so that it reads local_enable=YES Uncomment line 29 by removing the # so that it reads write_enable=YES Uncomment line 33 by removing the # so that it reads local_umask=022 On or around line 34, add the following entry file_open_mode=0755

Uncomment line 94 by removing the # and change the Welcome string to something custom of your own Uncomment line 105 by removing the # so that it reads chroot_local_user=YES

189

You should eventually see something like this When you have made all the changes, click save and close

The next time the computer is restarted, the FTP server will read the new changes, and will be ready to use. We havent added any users for it yet, we will get to that later, but we are done as far as its configuration.

190

If you dont want to reboot, you can just restart the vsftp service instead.

Using the Bootup and Shutdown module, find vsftpd

Put a check in the box next to vsftpd

and click the Restart button

This will restart the FTP service, without restart your computer. Either way is fine. Now you have a fully functional FTP server. We will test it later, when we add some more users with less important passwords. Much like HTTP, passwords sent over FTP are also sent in plain text, thats why I dont want you to test it right now with your important accounts and important passwords.

Thats it for FTP for now

191

Next lets see how to check local email messages and syslog. When something goes wrong with the system, or there is a change, or a scheduled job has failed, you can use one of these two messaging systems to check it. Similar to Windows Event Viewer, you can find a lot of helpful information here. Using the Read User Mail module, you can see if you have any mail.

As you can see I have messages here. In this configuration you can send and receive local emails to users of this server, using this module.

192

And to check the syslog, use the System Logs module

193

You can also find useful information in the View Module Logs module

A lot of the time the answer to your problems will be in one of those (3) places

194

And the homepage (also called the System Information module) does a good job of showing you your current usages.

As we can see above, even with everything we have added to the computer, its still only using 34MB of ram, 0MB of the Pagefile, and 0.02 of the processor. *** note, this particular computer is a only a P3 \ 450Mhz a paper-weight at best. Isnt Linux amazing?

These awesomely low numbers are because we are using the command line version of Linux, and not a GUI Operating System. You can also see your Uptime and OS version, Disk-Space, and other important information.

195

Next lets add some user accounts, these would be people you would give access to your server and its resources. We will create the accounts, and setup their home directories to be on the data drive, and exposed to the network\internet. Using the Users and Groups module

We are going to get a lot of use out of this module. It will allow us to make users, groups, set passwords, set home directories, and even setup their shell, where we can further restrict them if needed. Click on Create a new user

196

You should see something like this, make the following changes

197

With the username jdoe and the real name jdoe. I like to keep the username and the real name the same, but the only important one is the username, that will be the actual login name. You could set the real name to Mr. John Doe, or something more descriptive if you like. I personally like to keep them the same. Un-check Automatic and set the Home directory to /mymounts/vraid/users/xhomes/jdoe If you arent using raid, and are using d2p1, you would type /mymounts/d2p1/users/xhomes/jdoe What these descriptive folder structures tell us is -Its a drive I mounted -What drive its on -Its user data -Its and exposed home directory xhomes -Its user jdoe

By exposed home directory, I mean that directory is exposed to the network or the internet. A constant reminder to me about security and confidentiality of what goes in there

We are later going to change the web server (Apache) to listen in those directories, so these home directories will be folders that are exposed and viewable over the network or internet. Thats on purpose, to give them web space.

After you have set the username and home directory, choose normal password and lets type in the password jdabc123 Set the Group to New Group With Same Name As User

Then click the Create button

198

If successful, you should see something like this

199

Little advice, careful if you ever click on a user, it will go into Edit User mode, and will try to reset the password. Of course it wont do it unless you hit apply, but try not to edit your users once they start using it, unless you know their password.

You probably noticed I didnt have you put jdoe in a group, but instead created a group with the same name of jdoe. Groups are awesome, so thats a good question. We will cover groups later, but for now lets focus on users. In this scenario you really dont need groups, because your users will be accessing their own home directories. And the entire operating system is kind of built around that idea, and gets the right settings and permissions by default. Its when you venture outside the home directories that you will find yourself overwhelmed with permissions, and then groups are a wonderful thing. Also if you want your users to be able to edit each others files, then you would have a big need for grouping. In our current configuration, every time you create an account the way we just did above. The users will have access to other users files, and shares, for like downloading and viewing and such, but wont have the rights to change or deleting anything they didnt create. Which is usually what youre trying to achieve with non confidential user data. But is easily tweak-able to fit any need you might have.

200

Now that you have a user with a password we dont care about, lets make sure your FTP is working. Remember this password will be sent in plain text, if there is a hacker on your network, he is about to see it, so make sure you dont type any of your important passwords in these next couple of steps. We are going to use Windows Explorer to test our FTP. Not to be confused with Internet Explorer. Windows Explorer is not the same as Internet Explorer. If you dont know how to access Windows Explorer, open up my computer

In that address bar, you can type FTP addresss, and hit the Go button or the Enter key on your keyboard. Its important you are not in browser like Internet Explorer or Firefox, those are for viewing, and are not fully functional FTP clients.

201

Make sure youre in a My Computer like window

Type

ftp://

followed by your IP address

Mine would be ftp://192.168.2.1 And would look like this

If your IP was 192.168.2.178, then you would type ftp://192.168.2.178

202

Hit go or enter, and you should be prompted for a username and password

Use the username and password you created earlier Username: jdoe Password: jdabc123 And click the Log on button

203

It should login, and you should see something like this (if not, re-read this section, and fix it before moving on)

Its empty because we havent put anything in there yet. Uploading file this way is as easy as copy \ paste. You should be able to copy a file and or folder from your Windows Desktop and paste it right into the FTP window above.

Copy something

204

And paste it

205

206

And you should see something like this

That folder or file that you pasted in there is now in user jdoe home directory.

207

You can see that in a more familiar view by using the File Manager module.

(If you dont see it, hit the refresh button)

Those files are now exposed to the network \ internet. We are going to make it even easier to get to by changing Apache to listen in those folders. We will use the password protected FTP way you just did to upload files, we will use a no-password-needed webpage approach to view and download them. Everyone will be able to view and download these files, but only user jdoe will be able to upload, modify, and delete. Well jdoe and you (root). Logged into the File Manager as root you can do anything you want. Ok, so lets redirect the apache listening folder to our data drive, deep enough to expose our external users home directories.

208

Open the File Manager module and create the following folder /mymounts/vraid/users/xhomes/no_auth Or, if youre not raided /mymounts/d2p1/users/xhomes/no_auth

Then click once to highlight the newly created

no_auth

folder, and click the info button

209

You should see something like this, make the following changes

Un-check all the boxes, make sure username root are the User and Group, and then click save.

210

We want this folder to be totally locked down, this is where apache is going to dump people if they dont know where they are going. And with these super strict permissions, they wont be able to use the back button, or do anything we dont want them to. These permissions are a little over-kill, but we can get away with that because we are root.

211

Next, using the file manager, navigate to the folder /etc/apache2/sites-available Highlight the file And then click the default edit by clicking on it once button

212

You should see something like this, make the following changes

213

That third line can be a little hard to type, if you want to copy and paste it, here it is below. RedirectMatch ^/$ /no_auth/

Make those three changes and click save

We have to restart apache for it to realize the changes

214

Using the Bootup and Shutdown module, restart apache2

Now when you try to go to your webpage, you should get what looks like an error. This is what we want. Open Internet Explorer, and navigate to your Linux box IP address Mine is 192.168.2.111 So I would type http://192.168.2.111

215

You should see something like this

This would be an example of someone who didnt know where they were going. We are creating disk space on the internet for people who know where they going. Notice there is no back button or Parent Directory buttons above the word forbidden, this keeps people from browsing your directories. There is still a back button at the top left of the page, but that back button is ok, it takes them back to the last page they visited. The back button we prevented is the one that is used to move back and forth through your directories. So unless someone knows where they are going, your website would seem down, or not available to them.

But if you were a user of the system, (like jdoe) you would know where you were going, you would know that your homepage or your web space is http://192.168.2.111/jdoe

216

Type that into internet explorer, and you will arrive at user jdoes home directory. You should see something like this

Notice if jdoe had files he wanted to share over the internet, people could download them from this page. Or if user jdoe uploaded a file called index.html Then he would have a webpage, that people could visit And if someone gets snoopy, and clicks on that Parent Directory button, they get dumped back to the no_auth folder, and wont be able to snoop around. This isnt secure by any means, but at this point we are not putting confidential data in there, so this is tight enough for now.

217

Now you can start providing web space and or webpages to people. All you have to do is make them an account. Make sure to put their home directory in folder /mymounts/vraid/users/xhomes/ Or /mymounts/d2p1/users/xhomes/ depending on your setup

And that user can now ftp files to their space, requiring a password. And share them with the world via their webpage (http) without a password The secret behind all of that is

We told apache to listen in the folder xhomes Then we told apache, if anyone lands here, immediately redirect them to the no_auth folder

218

jdoe would never land in xhomes, because he knows to specify the path

/jdoe

http://192.168.2.111/jdoe

Therefore skipping the redirect to no_auth, because he never actually landed in xhomes, he landed deeper in the jdoe folder, where he wanted. If you made a new user account called Kevin could do the same thing http://192.168.2.111/kevin And so on and so on, for all your exposed users. Hence the name xhomes Thats it for redirecting apache, just remember to make their home directory in the xhomes folder, and teach them that these files are in no way confidential. You can also make yourself folders in here, without needing to keep making new accounts. Because anything you put inside the xhomes folder will be exposed to the web. So if you made a few new folders like kevin

/mymounts/vraid/users/xhomes/public /mymounts/vraid/users/xhomes/vegas09pix /mymounts/vraid/users/xhomes/rex-the-dog /mymounts/vraid/users/xhomes/website-for-mom

You could send internal people links like these, and later when we setup port forwarding you can send them to external users as well http://192.168.2.111/public http://192.168.2.111/vegas09pix http://192.168.2.111/rex-the-dog http://192.168.2.111/website-for-mom (internally) or (internally) or (internally) or (internally) or http://your-public-ip-address/public http://your-public-ip-address/vegas09pix http://your-public-ip-address/rex-the-dog (externally) (externally) (externally) (externally)

http://your-public-ip-address/website-for-mom

219

And people could access the files and or webpages inside

And later on in the how-to, when we give your server a public hostname, you can send people links that look like http://MyWebsite/vegas09pix

That has a name, that makes sense, instead of those confusing numbers. But they couldnt look at your other users folders, unless they knew where they were going. This isnt a very secure way of keeping people out, but these are not confidential files, so it works great! And just like you did earlier, you could add a password to the /mymounts/vraid/users/xhomes/vegas09pix directory using the Protetced Web Directories module, and limit who could see those pictures.

This is a little off topic. I am not a Macintosh fan, but if you find yourself having to support some. You can also use this Linux box to image Macintosh boxes. Mac lets you uni-cast images of desktops and laptops from a web-server. So now that you have a fully functioning web-server. You can use the Disk-Utility on the CD that came with your Mac, and create a .dmg image of the computer to a USB or Firewire drive. Upload it to your web-server, and dump it to other Macintoshes.

Once you have the dmg file uploaded It should be available with 755 permissions, and look something like this http://192.168.2.5/macs/g6.dmg And thats it, the other Macs can download that as an image when booted of the Mac CD and running the Disk-Utility And viola, it will reboot fully imaged.

220

Later in the how-to, we setup a DHCP server, this also helps with MAC imaging, as MAC doesnt let you use a static IP address in the disk utility GUI. Thats about it for apache Next we are going to make another user, whos password we dont care about, and whos home directory is not inside the website listening folder. Because right now, anything we upload is instantly exposed to the web-server. And sometimes we will want to upload files without them being exposed to the web. And sometimes on a LAN, FTP is the best way to do this. The Upload and Download module you have been using in Webmin is awesome, its easy to use and keeps your passwords safe but at a price. Because of the https encryption its really slow, it doesnt understand all file type headers, and sometimes it has problems with really large files. So we will us FTP or Samba for those needs, large files, weird file types, etc Just remember that password is sent in plain text, so make sure its a password you dont care about. Same steps as before Using the Users and Groups module

Click on

Create a new user

221

You should see something like this, make the following changes.

222

Name the user

uploadman

Do not change the Home directory option, leave it at Automatic this time Set the password to umabc123

Click Create

Thats it, this users home directory can now be found under /home/uploadman/

(If you dont see it, hit the refresh button)

Now you should be able to ftp in as user

uploadman

223

Remember to use Windows Explorer, not Internet Explorer, when FTPing

Using copy \ paste, lets upload a large file Copy something big, like a CD iso

224

And paste it

Close the FTP window, and go look at it in the Webmin File Manager (If you dont see it, hit the refresh button)

225

Then using the buttons at the top, you could cut that file, and paste it into the /options/ directory And that would be an example of how to get huge files uploaded to your server, and put into the /options folder. Much later in the how-to we will use this method heavily to upload .isos to the Datastore (advanced) Or even easier, if the file youre after is on the internet, you could just use the wget command you learned earlier. By using the ssh2 module or putty, login as root, then change directory to the options directory cd /options Then type wget http://the-website-that-has-it/debian503.iso

That would accomplish the same thing, but the file would have to be on the internet or a web-server for that option to work. Either way, now you have a couple work-arounds, for large files, if the Upload and Download Webmin module gives you problems (and it sometimes will)

226

And now you have an ftp account uploadman whos home directory isnt exposed to the web-server. And a user jdoe whos home directory is exposed to the web-server. Now lets setup disk space restrictions, called Quotas. These are very important, because without them, there isnt anything stopping your users from uploading too many files, eating up your bandwidth, disk space, and ultimately crashing your server. Lets think of user uploadman as an account probably only you, the administrator would use. And lets think of jdoe and an account you made for your friend or your client (John Doe) You most likely wouldnt put a quota restriction on yourself (uploadman) but you should restrict jdoe. And because of the way we have been mounting the hard drives, quota is almost already setup. Just go into Webmin, and click on System in the left menu, and then click on the Disk Quotas module

Notice mine says Filesystem /mymounts/vraid Yours will either say that or /mymounts/d2p1/ Depending on if you followed the raid how-to, or not. I will continue to call it /mymounts/vraid but you will know I mean either one.

227

Click on Enable Quotas

Dont get clicky, this can take a good 10 minutes or longer to respond. And you should finally see something like this

228

Click on Users not groups

You should see something like this

There is a lot of good info here. Notice username uploadman is not listed here. Thats because he doesnt live on this hard drive, and hasnt been given any access to it. uploadman lives on /home/uploadman which is the main hard drive. This is drive number 2. So only jdoe shows up, and of course root, because root has access to everything.

229

Lets setup a quota for user jode To limit the amount of space he can use on

/mymounts/vraid

Click on jdoe

You should see something like this

230

Make the following changes

Soft Limit = 2GB Hard Limit = 3GB

Then click the Thats it

Update

button.

This means the user (jdoe) has 3 Gigs of storage space he can use. You will start to get warned above 2GB, and he will get cut off after 3GB We dont change the file limit, just the overall size limits. I dont really care how many files he puts on there, just as long as the overall size of his home directory doesnt exceed 3GB.

231

When you get back to the main quota screen, you should see something like this.

There is all the information you could need right there. You can see user jdoe is using 26MB. He is allowed to use 3GB. You will be warned when he reaches above 2GB. And I put red xs through the file limits, because I dont care how many files he puts on there.

You dont want to set a quota for root, because root is un-stoppable, and root is you. And you dont want to set a limit for user because that is also you. But always set quotas for your users Lets make another user called testuser with a password of abc123

uploadman

With a home directory of /mymounts/vraid/users/xhomes/testuser *or /mymounts/d2p1/users/xhomes/testuser depending on your setup

232

We will use this user to test things your setup for your users. Because once you go live with this and start giving people access, you wont know their passwords, and will need an account of your own to test user settings with.

So navigate to the Webmin Users and Groups module, and create a new user

233

And very similar to what you did for user setup user testuser

jdoe

234

Click the Create button And using the Disk Quotas module, give him a limit of 5GB, warned at 4GB. Similar to what you did earlier

Click on

testuser

235

Setup the quota, and click update

Thats it for quotas, and now you have a user name Next we are going to setup Usermin.

testuser you can use for testing

Usermin, is a Webmin like interface you can give your users access to. Remember, you never want to give them Webmin access, thats for you, so Usermin is a great medium. After we install it, we have to do a lot to lock it down. Its a little too powerful, so we have to configure to only allow access to the things we want your users to see. First we need to download the Usermin installer from http://webmin.com So lets navigate to our Upload and Download module, so we can download it. Make sure you are on the download from web tab

236

Paste this link into the

URLs to download

field

http://prdownloads.sourceforge.net/webadmin/usermin_1.450_all.deb Eventually these links will stop working due to new versions, so you may have to use the versions from my server, or go to webmin.com and find the newest link. My server http://t3.woodel.com/my-linux-how-to/usermin_1.450_all.deb

This will download the installer to the

/options

folder for you.

237

And we will install it using the

Software Packages

module

Chose From local file, provide the path, and click the install button

You should see something like this

Click the install button

238

If successful, you should see something like this

Ignore the fact its telling you to login above, we are not ready for that yet. Usermin is now installed, we have to lock it down now, because its default install give the user way more control than we want them to have. You should have a Usermin Configuration module within your Webmin screen now, towards the top, under Webmin

239

If you dont see it, you may have to hit

Refresh Modules at the bottom on the screen

Usermin has a lot of features we need to disable for our users.

240

Starting from the top and working to the right lets click on User Interface

241

You should see something like this, make the following changes, and click save.

242

Next click on Upgrade Usermin, but dont click anything else

This is how you would check for updates for Usermin, but resist doing this now if you can, that way our screens continue to look the same. Click Return to Usermin configuration

243

Next click on SSL Encryption

And change And click save

Enable SSL if available

to No

This will disable https for Usermin, and force it run un-encrypted, using http

244

This would normally be a horrible idea, https is awesome. Its what keeps your passwords and transactions safe on the internet. We just disabled one of Usermins best features. But we are going to use Usermin as an FTP alternative for our users. We have already told our users to not put files on the internet they dont want others to see, and have already told our users not to use important passwords (meaning dont use the same password here as you do for your bank or for your email) Since this is just an alternative to FTP we are offering, and since FTP isnt safe, we can go ahead and disable https. This only affects your users and Usermin, your Webmin is still https, so no worries there. Again that was a terrible change we just made. Hopefully someday you will turn it back on. We disabled it for ease of use for our users, as that https certificate warning will get in the way of a lot of stuff they will try to do, and running non https will speed up their downloads. With a little training you could teach them (your users) how to interact with the certificate warning, or better yet, buy your own ssl certificate from http://dyndns.org and not get any warnings at all. If you ever buy one, you could return to this page and insert it here, and change it back to SSL mode

But this how-to is focused on the free and easy, so we will continue with non https for Usermin, and instruct our users to not use re-use important passwords and not put confidential files onto the web.

245

And to make sure I didnt confuse you, do not ever disable SSL for Webmin, I am strictly referring to Usermin and non confidential user files.

Next click on Usermin Module Configuration

Then click on

Upload and Download

246

And make the following changes

Then click save

247

You should be returned to this screen, click on File Manager

248

Make the following changes

249

Then click save

250

You should be returned to this screen, click on File Manager again, there is another change we need to make to it.

251

Click on the

Default users preferences

tab, on the top right, and make the following changes.

Click save

252

You should be returned to this screen

Click Return to Usermin Configuration

253

Then click on Available Modules

254

Make the following changes

Make sure you un-check everything except

File Manager, Disk Quotas, Upload and Download, and Change Password.

Everything else needs to be unchecked

Then click save

255

Next click on Allowed Users and Groups

And make the following changes

Then click save

256

Next click on Access Control Options

And make the following changes

Then click save

Thats it for Usermin, you can login as see the fruits of your labor To login, open your browser and type http://your-linux-box-IP-address:20000

257

My IP address is 192.168.2.111

So I would type

http://192.168.2.111:20000

Login as

testuser

with password abc123

258

You should see something like this

Here your users can use the Browse button to choose and upload files over the internet or network, directly to their home directories.

259

This is the FTP alternative we were talking about. Most users will find this a lot easier to use than FTP. Especially those using a lot of different computers \ operating system. Since its web-based, it will always look the same, no matter if they are on a Mac, PC, Linux, or something else. FTP is still available, and they both still work, side by side. It isnt anywhere near as fast as FTP, but your internet users and non-computer savvy users will like it. For extremely large files, you will want to use FTP or Samba (we will cover Samba later in this how-to) This Upload and Download module will load as the homepage for your users, but they can also click on the menu items on the left.

260

Here they can check their disk space usage and quota, use the File Manager module, and even change their own passwords.

261

Just remember to tell your users about the dangers of entering passwords over a non https connection.

Thats it for Usermin, your users will really like how easy and flexible it is. Hopefully you will change it back to https \ SSL mode, and teach your users about the certificate prompts, disabling that is always a bad idea. Or purchase your own ssl certificate, and have the best of both worlds. If youre going to be offering this server to internet users, youre going to need to setup a dynamic hostname, so you can give your users a website name to go to, instead of an IP address that they will never remember. So instead of telling user jdoe this is his website, which he will never remember http://123.123.123.123/jdoe You can do something like http://example.com/jdoe Or http://jdoe.example.com

262

And instead of telling jdoe this to manage his account http://123.123.123.123:20000 You could do http://members.example.com or http://my.example.com Your users are already accustom to website names like this, most of their other online accounts will start with members, or cardholders, or my. And then the website name

In all of these examples, you would replace example.com IP address will change over time, but the name will not.

with the unique name you chose as your dynamic hostname. Its dynamic because, your

There are many sites that will do this for you. In this example we will use is http://dyndns.org I use them, and I think they do a great job. You can go to their website, and chose either a paid dynamic hostname, like example.com. Or you can choose a free dynamic hostname, but the free ones put a little advertisement in the name, like example.drink-beer.com Its a small price to pay, but every time you tell your users their link, your advertising for beer. I would go with the paid version, the support is better, the names are shorter, and your users will take you more seriously. http://dyndns.org calls their paid version custom dns

263

Start by going to their website http://dyndns.org

Chose a free one, or a paid one

I use the paid one, the names are easier to remember, its more robust and the support is better. With the paid one you can email them, and a real tech will answer you. If you go with the free one, I think email is disabled and you have to use the knowledge base. Both works great, I have a couple free ones I have never had a problem with as well. Chose your poison, type the name you want in the example box, and click the add button. For example, we will say you selected kevin.gotdns.org

*Dont use kevin.gotdns.org, thats an example

264

If the name isnt available, it will ask you to pick a different name. Once you find one your happy with, click add. The website will walk you through everything you need to do, and you will leave with a dynamic hostname and a username \ password for making changes.

Then all you need to do is tell your router at home that information, so it can dynamically update the IP address at your house, to match the hostname you picked out. Your routers management interface should have a tab call DDNS. Log into your router and fill in the information.

You should see something like this, make the following changes.

*Dont use kevin.gotdns.org, thats an example, use the name you picked at the dyndns website.

265

Now your router will tell the dyndns.org website if ever your home IP address changes, so that your hostname will always point back to your router at home, even if your IP address changes (and it will) Now your router will always respond to the hostname you picked. Now all you have to do, is tell your router what computer, inside your house, to send the traffic to. So far we have a need to port forward ports 20, 21, 22, 80, 10000, 20000 to be directed to the Linux box inside your house. Today mine is ip address 192.168.2.111. That would look like this

Now your router will send web traffic (thats port 80) to 192.168.2.111 (your Linux box) Now your router will send ftp traffic (thats ports 20 and 21) to 192.168.2.111 Now your router will send ssh \ putty traffic (thats port 22) to 192.168.2.111 Now your router will send webmin traffic (thats port 10000) to 192.168.2.111 Now your router will send usermin traffic (thats port 20000) to 192.168.2.111

266

This way your Linux box (192.168.2.111) isnt totally exposed to the internet, you control what traffic is allowed to get to it. Now if a user types http://kevin.gotdns.org go. into a browser window, browsers talk on port 80, and you router will know where that is supposed to

Now if you type kevin.gotdns.org into a putty window, putty talks on port 22, and your router will know where that is supposed to go. And so on and so on. Thats pretty much it for the dynamic hostname and the firewall \ port forwarding configuration. If everything is working but ftp, you could be having a min_passv, max_passv problem with your firewall. Or a modprobe ip_conntrack_ftp problem. Those are advanced problem, and we will cover that much later in the how-to. But if everything is working beside ftp, you will want to keep reading into the advanced section.

You should now be able to get to your Linux box from the internet. Meaning you should be able to get to it from work, a friends house, etc using your dynamic hostname.

Next we are going to setup Samba. This isnt something thats going to benefit your internet users, but youre going to love Samba for your network users. Meaning people inside your same small business network or home network. Its basically File Shares for Linux. It has very few limitations, and is really an all in one solution for your LAN. Once you go Samba you will never go back. Everything you do from a Samba share is streamed and or ran live, directly off the server, not downloaded to the users PC. So when you play music or movies from the Samba share, you dont have to wait for them to download first, they play right off the server. Same with documents, they live on the server, and you work on them live, never downloading to your PC. We need to disable one of Sambas coolest feature, the home shares. By default Samba shares every users home directory, with the correct permissions, so only that user can see his or her files over the network. Home shares are awesome, they work perfectly with very little configuration. But we need to disable them because we have ftp enabled on everyones home directories. We are going to consider the data in peoples Samba shares to be confidential. So we do not want them accessible via ftp.

267

We are even going to use Samba to put a users My Documents folder on the server, so when they save to their My Documents folder on the windows PC, it actually saves to the server. There will surely be confidential data in there, so we dont want FTP and Samba listening in the same folders. FTP is not secure, and is provided for our external users. So we need to move our shares to a different directory, only accessible by our internal users. Plus once your internal users experience Sambas awesomeness, they will never want to FTP again anyway. Its our fault for running both FTP and Samba on the same server. Realistically you would want two servers, one private, and one public. But this how-to assumes you have limited resources, and wish to run both FTP and Samba on the box. So unfortunately, we will need to delete all the shares listed below.

268

And then we are going to setup the defaults for all new shares. That way when we create new ones, they already have most the right settings, kind of like a template.

Click on Unix Networking *Reminder, much earlier in this how to, I changed my IP address from 192.168.2.111 to 192.168.2.1 You see me refer to 192.168.2.1 im just talking about the local IP address of your Linux box. so when

269

Make the following changes

For the listen on address, use your local IP address. Mine is 192.168.2.1 use your IP address of your Linux box

This is important later on in the how-to, we when add another network card.

270

Next click on Windows Networking

271

You should see something like this, make the following changes

Click Save

272

Next click on File Share Defaults

There are a few sub menus under File Share Defaults, if you get lost, just click File Share Defaults again from this main screen

273

The Other Share Options are the sub menus I was talking about, if you get lost, just click the File Share Defaults icon on the main menu again. Click the Security and Access Control icon, and make the following changes

Under Host to allow, allow only 127.0.0.1 and your subnet If youre on a 192.168.2.xxx network, then use the settings above If youre on a 192.168.1.xxx network, use 192.168.1.0/24 If youre on a 192.168.0.xxx network, use 192.168.0.0/24 If youre on a 10.10.10.xxx network, use 10.10.10.0/24

274

Dont be worried that we just set the default value to writeable. We are going to fix that later. All that will mean by the time we are done is that they are all writeable by their owner, and not really everyone, the way it appears now. Setting up these defaults will save you a lot of steps, and pre-fill in some information for you when making new shares. So they come up as kind of like a template, where you just have to make a few changes, and it will make more sense.

After you click save, you should be returned to the sub-menu, where you can click on File Permissions

Click on File Permissions

275

You should see something like this, make the following changes

There is a ton of good information right there, and I will explain what it all means as soon as we finish these sub menus. Click save, and you should be returned to the sub menu

276

We dont need to change anything under the File Naming icon, so we will skip to the Miscellaneous Options icon.

Click on the Miscellaneous Options icon

277

You should see something like this, make the following changes.

Click Save

278

This should return you to the sub menu, make the following changes

And then click save

279

This should finally return you to the main share menu

Now that we are back at the main share menu, and are done with the confusing sub menus, I wanted to take a moment to explain these settings, knowledge of what these mean are pretty important

Here is what 700 permissions mean, we will be using 700 the most, and now is a good time to talk about it.

280

Its unlimited rights for the user. (wood) In our setup the user is the owner of the file. The owner of the file is the person that uploaded it to the server. So when your users upload a file, they own it, because its theirs.

281

There are no rights for anyone else, to others it would appear as if the file isnt there. In the group field you see root, its just filling a blank space for us. You have to put something there, we arent using groups just yet, we will be covering that later. So putting root there just fills in the spot for us. All the rights are unchecked anyway, its just filling the field for us.

There is one exception, root doesnt need rights. Root is too cool for that. Using the File Manager module, or being logged in as root, you can see and do anything you want. So as long as youre logged in as root, or using the Webmin File Manager module, then these rules dont apply to you. But try to forget that, its an exception to the rule. You should consider that 700 example above as only being accessible by user wood. And youre the only one that can Webmin anyway. This isnt any less secure, its just so you dont lock yourself out.

So if user wood wishes to it.

uploads a file, he is the user, he owns it, he can do whatever he wants to it. This is pretty standard, its his file, he can do what he

282

Here is where we forced that all to happen by default when we create a share

Any files uploaded to the shares will get the 700 permissions we talked about. Meaning only that user can see and use those files. We dont allow the following of shortcuts (symlinks) And we allow deleting of read only files, because that user put that file there, they own it, they should be able to delete it if they want. Most of the shares we are going to make will use this 700 setting.

283

We will be making a couple that use 755, that looks like this

Above you can see this folder would be usable by everyone, in a read only like mode. This is not the kind of permissions you would want on confidential files. They can download files, run files, view documents, they just cant add files or delete files, because they cant write. Only user wood can write, modify, and delete.

284

So this kind of access would be ideal for providing your users the ability to download files you put in there. But you dont want them to delete anything, add anything, or change anything. At home this may be your media share, with your playlist, music, pictures, moves, etc. In a small business this might be where users could download installers, pdfs, forms, and non confidential data, etc.

These permissions only pertain to files uploaded via Samba. If you interact with these folders using the File Manager (or some other module other than Samba) they wont get the permission we specified, as Samba wouldnt even know it was put there. If you accidently mess up a file\folder permission, you can use the File Manager to fix it. You just have to highlight the file or folder in question and hit the info button

285

Just be careful, youre un-stoppable this way. You wont be warned if youre doing something wrong. Good rule of thumb is never do this to a file or folder that you didnt create. That way youre not messing with system folders ever.

We had to go through all of this with Samba because we disabled the home directory shares. So we caused the problem :- ) but it was necessary for our particular setup, because we have internet exposed home directories. If this were a server only running Samba, and we didnt have so many different ways to access it, we could have avoided a lot of these lock downs.

Ok, back to work. We are almost ready to start making shares, we just have to configure the server to automatically make a samba account every time you make a new user account. Linux treats samba accounts and user accounts as two different accounts, so we need to tell it to stop doing that. Scroll down on the main share page until you see Configure Automatic Unix and Samba user synchronization

286

You should see something like this, make the following changes

This will only work on newly added users, and only if you keep using the Webmin module User and Groups to add them.

287

I say that because at the end of the how-to, im going to encourage you to learn the command-line way of doing everything. This would be the exception. For adding users and groups, keep using this module. So all of the users we add from here on out will automatically get a samba account. Which means we missed user wood As he was created we back before we even installed Samba

This is really easy to fix, just launch the ssh2 module, and run the following command smbpasswd a wood

288

Remember to replace wood with the name you picked during install And use the same password

This will create him a Samba account, and you will be all set

289

You should see something like this, you can now exit the SSH2 module

That should be the only time you need to do that, as now they are being created automatically every time you make a new account. (using the Webmin module) You might be wondering what about user jdoe and user testuser Those are internet users, they dont apply here, you dont need to add them. We dont want them to Samba, because they are examples of people who are not on your local network.

290

Lets make (5) example users, these will be examples of people on your network, in the same house, building, or network as you. Using the Users and Groups module, create the following (5) users

Username: Username: Username: Username: Username:

roommate1 roommate2 roommate3 roommate4 public

Password: Password: Password: Password: Password:

roommate1 roommate2 roommate3 roommate4 public

When creating them, leave their home directories at the default setting, dont specify a custom home directory for them.

291

I used roommate as an example, meaning that they are in the same building as you, meaning same internal network.

292

Continue on, and make all (5) accounts

You should see something like this, notice their home directories are in the default location.

Once you have all (5) accounts created, We are finally ready to start making some shares. Open the File Manager Module, and navigate to /mymounts/vraid/users/ (Or /mymounts/d2p1/users/ depending on your setup)

Create a folder called

nshares

293

To me this means internal shares You should now have something like this /mymounts/vraid/users/nshares Your users folder now contains an xusers This folder structure reminds you that It was mounted by you (mymounts) Its on a virtual raid (vraid) It contains user data (data) xhomes = exposed homes (exposed to the internet, and the web-server) nshares = internal shares (internal to your network) folder and a nshares folder

*Always remember your xhomes folder is exposed to the internet, because apache and FTP are listening in there, so triple check youre not making any shares inside that folder, you want to be at least one directory higher, in the nshares directory. Like this /mymounts/vraid/users/nshares/ Not this ! /mymounts/vraid/users/xusers/nshares/

We wont be using the File Manager to make any folders deeper than /mymounts/vraid/users/nshares/ Because the File Manager wont make the file permissions the way we want.

Here is how you can tell, click on the nshares folder once to highlight it, then press the info button

294

As you can see, these are not the ideal file permissions for our shares. It is the ideal set of permissions for the nshares folder. But not for the shares inside it, the deeper sub-folders we are going to make inside of them need to be created by Samba. And these sub-folders will be the actual shares. So once you have create the nshares folder, you can exit out of the File Manager, and return to the Samba Windows File Sharing Module

295

And click on

Create a new file share

296

You should see something like this every time you create a new share

You were probably expecting that box to say 700 This screen is talking about creating the share. All that 700 template stuff we setup earlier was for the files that will be uploaded by your users, and eventually populate the share. This screen is talking about something else, its talking about creating the share. Lets make the following changes, this will be the share for user roommate1

297

We are considering this a confidential share, as it will house roommate1 personal data. Thats why we need to change the permissions to 700 You probably noticed the directory /mymounts/vriad/users/nshares/roommate1 doesnt exist yet. Thats perfect, thats what we want. This way Samba creates that folder, with the permissions we filled in here.

298

You probably feel like you have entered this information twice. Thats not true. All that default share stuff we did pertains to the files roommate1 will later be uploading and using. This screen is setting up the correct permissions for his share. For the directory put /mymounts/vraid/users/nshares/roommate1 Click the Create button

299

You should be returned to the main screen, and see something like this.

Click on Create a new file share

300

And make all of the following shares

Notice that the fields all say roommate2

Click Create

301

Create another one

Notice that the fields all say roommate3 Click Create

302

Create another one

Notice that the fields all say roommate4

Click Create

303

Create another one

Notice that the fields all say wood

Click Create

304

Create another one

Notice this one is a little different, this one is using 755. As you can probably tell, this one is going to be readable by all, but only writable by you (wood)

Click Create

305

Create another one

Notice this one is a little different. Set the owner to username That isnt an example, really use the name And the permissions to 755 nobody

nobody

We are going to do something different with this one, make sure to type the word nobody in there, just as you see it. This is going to be a publicly writable share, so your users can share files with each other. Right now they probably email everything as an attachment, this will help cut that down a lot. I will explain the username Click create nobody later

306

This should be returned to the main sharing screen, and you should see all the shares you just made listed.

Because of all the defaults you setup, roommates 1 through 4 are done. We have to make a small change to media, and a few changes to public.

307

Click on media, and make the following changes

308

At the media sub-menu, click on File Permissions

Make sure youre at the sub-menu for the media share, and not in the defaults for all shares. It should say Edit File Share at the top, and not File Share Defaults. Then click on File Permissions and make the following changes.

309

Click save You will have to click save at the next screen too. Do these exact same steps for the public share too, and click save.

310

There are a couple more changes we need to make to the public share. Click on public and make the following few changes

You will see a sub menu

Click on

Security and Access Control

311

Make the following two changes

And click save User nobody isnt an example, really use the name nobody

312

You will be returned to the sub-menu, where you need to click save again

You will be returned to the main screen, scroll down to the very bottom and click Restart Samba Server (If youre using Ubuntu you may need to reboot, as Ubuntu uses a different command to restart services)

313

Now all (7) shares are setup and ready to use, you now have a fully functional file server.

314

You can connect to them from your Windows PC now by typing \\your-linux-box-IP-address\ Mine is 192.168.2.1 So I would type \\192.168.2.1\

Do this in an explorer window, like the my computer window.

315

You can click go or hit the enter key on your keyboard You should be prompted to login Lets use username: roommate1 password: roommate1

316

If successful, you should see something like this

Your logged in as username roommate1 So you should be able to do anything you want inside of the roommate1 folder

317

Here you are in the roommate1 folder, making a new folder

318

And you should be able to do anything inside of the public folder

319

If you double-click on any of the other roommates folders, you should get an error, and not be allowed in. This is what we want. Thats their confidential folders. Not yours.

You should also be able to see inside the media folder, there isnt anything there yet, but you should be able to double-click it. You shouldnt be able to add or delete anything. Only user wood can do that.

320

Once user

wood uploads some files into there, your users should be able to access them, but not change or delete them.

That user nobody stuff we did is pretty cool. Its going to force all users as a guest user anytime you enter that folder. Thats the magic behind everyone being able to edit that folder, even though its got 755 permissions. Because it thinks anyone inside that folder is user nobody, and user nobody is the owner.

The username public might never be used, but is needed because we require an account from anyone wanting to access a share. This would be one you could give to someone wanting temporary access to your shares.

321

It would be for someone on your network who doesnt have an account. You could tell them just login as username public password public And they would be able to access the media and public shares, but none of the confidential roommates shares. This is extremely helpful at home, when you have LAN parties. Someone always has a patch or a cd key they need to share, you can tell all of them to use username public, and they can put the needed files up in the public folder for everyone to access. Or in a small business, you might have a vendor stop by to show off a product, and they need share access. Just tell them to use username public password public, and they are in, with no work for you to do, and they cant get to anything confidential.

Its just a complete solution, once you have it you wont be able to live without it. You can combine these shares with this awesome backup utility. Cobian backup Its free, and amazing. You will throw away your paid backup software and use this one, its the best. http://cobiansoft.com/cobianbackup.htm

Just install this on your users windows computers, and tell the backup destination to be the share on the server, and your done. Its beautiful.

322

File permissions vs. share permissions, and why to do it the hard way. There are both File Permissions, and Share Permissions at work whenever you attach to a share. File Permissions are the grand daddy of them all, if the File Permissions dont allow it, its not going to happen, no matter what you tell the Share Permissions to do. On the flip side, you could loosen up the File Permissions, (something greater than 700) and control access over the Share Permissions. There is a great amount of flexibility here, its always tempting, you can pretty much achieve anything this way, but lets talk about why you shouldnt use them. As seen in the screen below, there are some very tempting choices

You probably see a ton of flexibility there. But the reason I dont use this is because these share permissions only apply to Samba access, and in this how-to our Linux box has several different access methods.

323

If someone logs in a different way, via FTP or SSH. They can explore all files and folder that are set to 755, completely ignoring the Samba rules \ checkboxes above. We are of course going to tighten this up later, but you see the point. Limiting users this way is only respected by Samba, and not any of the other modules. Whereas limiting access by Linux Filesystem Permissions keeps everybody out, no matter what access method they try. Thats why I always try to make the Share Permissions match the File Permissions, because Im telling myself this is the maximum access anyone could have, no matter what method they use to access it. And always keep confidential directories 700 or below. This wont always be possible for all of your Samba needs, you may need more flexibility that this, but still another good rule of thumb. Its more work, and slightly less flexible, but its better to make a mistake and not let the right user in, then to make a mistake and let the wrong user in. I always consider permissions on the bottom row to be public. Thats horribly inaccurate, especially on a private LAN but its a good rule of thumb.

Other is basically everyone, not requiring an account on the server to access the file. We used it on a couple of our public shares, just give that bottom row a lot of thought, make sure you really need it.

324

If you dont want the Printers and Faxes folder to show up

Add these three entries to the Samba configuration file /etc/samba/smb.conf # In the section that talks about printer load printers = no disable spools = yes show add printer wizard = no

325

# These have to be in the printers section You can do that with either the File Manger or the Edit Config button on the Samba screen below.

Click on Edit Config File

326

You should see something like this.

Scroll down to the printers area, and add these three lines load printers = no disable spoolss = yes show add printer wizard = no

327

You should have something like this

328

And while youre in there, scroll up and find the line that says And comment it out with a #

include =

Webmin doesnt seem to like that include statement in there, so just comment it out if its there. (it probably wont be there, but look just in case) Click Save. Then just restart the Samba service, or restart the server and you should be good to go.

329

Sometimes the computer will prepend a domain name to your login, if youre having that problem, 127.0.0.1\username as your username should fix that.

or

./username

Also make sure all your Windows computers are in the same workgroup of DIY.LAN or whatever you used on page one during the samba install. Username Example: 127.0.0.1\roommate1

330

Samba is cross-platform, MAC, Unix, Windows. Windows boxes use \\ip-address and or \\server-name and or smb://server-name

GUI Linux clients and Macintosh use

smb://ip-address

In Ubuntu, thats under

Go \ Location

Then just hit enter, and you should see a list of shares, Just as you did in Windows.

331

You want your Workgroup to match on all your computers if possible. On your Windows computers, you can change the workgroup in the same screen where you change the computer name. Just right-click on the My Computer icon, and select properties. In the advanced tab, computer name, you can change the Workgroup to DIY.LAN

332

Say OK, and reboot. At this point SAMBA should be totally working, looking and behaving how you want it to.

============================= Troubleshooting ===========================

If you can access your Samba shares via the IP address, but not via the computer name, check these. I will move fast through this because these settings are not the defaults, if you have these setting in place then you already know what Im talking about.

333

Make sure your getting your DNS info from your local DHCP server.

334

Or better yet

335

If you have given your Linux box a static IP address. Edit the file /etc/hosts and replace the line that reads 127.0.1.1 with your new static IP address.

336

Should look something like this.

Your /etc/resolv.conf should look something like this

337

Also, reboot a few times, and make sure /etc/resolv.conf isnt being changed by your dhcp client. And double-check your computer name is right it /etc/hostname

And reboot Im purposely going to keep moving fast through these next parts, using red font, because I dont recommend you do it unless you have a real need for browsing by name, and arent planning on setting up a local DNS server. This is a manual band aid for not having a local DNS server, which is the real fix to all of this, and is covered later in the advanced section. First, on your Windows computer, edit the file c:\windows\system32\drivers\etc\hosts And add the IP address and name of your Linux box (there are examples in that file that make it easy to understand)

338

Second, on your Windows computers, if youre using static IP addresses, youre probably not getting the right DNS suffix for your local network. If you right-click on your network card, and choose properties. Then double-click on TCP\IP (TCP\IP version 4 if you have two choices) Then click on advanced, and click on the DNS tab at the top. Add the suffix diy.lan (or whatever you picked on page 1) to the field that says DNS suffix for this connection Apply and reboot, and now your windows machines will add .diy.lan to the end of everything youre searching for, which should fix any name resolution problems you may be having. This is a manual band aid for not having a local DNS server and DHCP feeding the machines information about your local network. I dont recommend doing it because its really easy to forget those setting are there, and will cause major headaches if you change your network setup and forget that its still hard coded at each machine.

339

Third, sometimes the following two settings can interfere with name browsing. If you open up Webmin and navigate to the Samba Windows File Sharing module, and click on Unix Networking. Setting the top one back to Automatic and the listen on address back to All can sometimes help. Just a warning though, these settings are needed later if you know youre going to continue onto the advanced section where we add another network card and turn it into a router \ DDNS server. So you really shouldnt change it if youre going onto the advanced section.

340

The fourth fix is pretty extreme. If you open up Webmin and navigate to the Samba Windows File Sharing module, and click on Windows Networking. You should see a field that says Remote announce to Just click the button that says from list and enter an IP address on the left. And your workgroup name on the right (DIY.LAN) You can play around with what IP address works best for you. You can put the IP address of your router, so the Samba server announces its name to the router. Most routers will block directed broadcasts like this, so will have to play around with it, you can put the IP address of certain computers you want the Samba server to announce its name to. You can announce it to all your machines by using 192.168.2.255 on the left and your workgroup name on the right. This is noisy and not recommended.

This ends the non-recommended troubleshooting part. Its my opinion that these settings should not be used. Remote announce to: is very noisy on your network, and static DNS entries are way too easy to forget they are there. But if you have a browsing by computer name need, a combination of those should fix it. ============================= End Troubleshooting =========================== Next we are going to setup Samba groups. On a small home network you probably wont need this. But as your network grows, or if your setting up a small business network, this will become a must have. Extremely similar to what we did early, when we told Samba and Webmin anytime a user account is made, also make a matching Samba account. We need to tell Samba anytime a group is made, also make a matching Samba group. This isnt the law, but if youre following my how-to exactly, we are requiring every user to have a system account, and a Samba account, and are matching filesystem permissions to share permissions. So for this to work right we have to have matching users and groups in both. But after a few clicks that will all be transparent anyway, and the system will automatically take care of all that for us. Navigate to the Samba Windows File Sharing module, and scroll down towards the bottom and click on the Configure automatic Unix and Samba group synchronization icon

341

342

You should see something like this, make the following changes and click

apply

Just a reminder, you have to forever use the Webmin module for creating new users and groups, or this function wont happen.

343

Next navigate to the Users and Groups module, and click on Local Groups.

344

And then click on

Create a new group

345

You should see something like this, make the following changes.

Click Create

Now you have a group called mygroup1 that is both a Linux group and a Samba group With the following members: roommates 1, 2, 3, and 4, and yourself (wood)

346

Next navigate to the Samba module, and click on

Create a new file share

347

You should see something like this, make the following changes.

Notice the share is called pub4roomies Which to me mean a public share, but only the roommates can access it (and you) everyone in the group mygroups1 Notice the Create with permissions are 770 Thats unlimited for the owner, unlimited for the group, and zero for anyone else. Make sure the owner is you, and the group is mygroup1, and click Create.

You should have been returned to the main Samba screen, but there are few more changes we still need to make.

348

Click on the pub4roomies share

You should see something like this

349

Click on File Permissions

350

You should see something like this, make the following changes.

You will have to click save at this screen, and the next one.

Youre almost done, we just have to make one small change to the permissions of the pub4roomies folder.

351

Using the Webmin File Manger module, navigate to the pub4roomies folder, click on it, then click Info.

Click the Files inherit group checkbox, and then click save You could also optionally click the only owners can delete files checkbox. If you didnt want the roommates deleting each others stuff. But this is a public share for them, so I wouldnt recommend check that box, unless you have one jerk roommate :- )

352

Thats it, just navigate back to the Samba module and restart Samba. Now any member of the mygroup1 group can access the pub4roomies share with full rights.

353

Newly uploaded files will get the uploading roommate as the owner, and mygroup1 as the group, and be fully accessible by all of that groups members. Thats pretty much it for Samba, there is just a little preventive stuff we should do.

Lets ... Setup Quotas for these new users Setup restricted password change module Show users how to map their My Documents folder to the server.

We should setup Quotas for the following users roommate1 roommate2 roommate3 roommate4 public nobody

I left wood out, because wood is you

354

You will need some big Quotas here, your users will get a lot of use out of these Samba shares.

Similar to what you did earlier Set them up with a quota

We also need to be concerned about the OS drive. Because we set these users up in the /home directory as well as the /mymounts directory. We need to limit what they can put in /home. Thats on the OS drive or / The roommate users and public user can still access /home via FTP Rather than disable FTP, lets just set them a ridiculously small quota, like 1MB Quota isnt enabled yet on the OS drive, so we need to enable it. We just need to make a simple change to the Disk and Network Filesystem Module.

355

Navigate to the Disk and Network Filesystem Module. And click on / *sometimes listed as / (root filesystem)

356

You should see something like this

Change that from

No

to

User only

And click save

Now the next time you navigate to the Quotas Module, the OS disk / Should now be there

357

Click on

Enable Quotas

Your computer will freak-out for a couple minutes while the Quota is checking the OS. Give it time, it will eventually finish. Once it finishes, click on /

And limit these users to 1MB roommate1 roommate2 roommate3 roommate4 public nobody

358

*If you dont see a name youre looking for, you can click the Edit Quota For and browse for it.

This way everyone you create still gets an FTP account, but these users cant really use it for anything.

359

Now lets give them Usermin access, but restrict it to only password changes and Quota view.

Navigate to the Usermin Configuration Module.

And click on Module Restrictions

360

Then click

Add a new user or group restriction

You should see something like this, make the following changes

361

Do these same steps for

roommate2 roommate3 roommate4 wood You dont have to worry about users public or nobody After you have added those other four users, we need to allow them Usermin access. Click on the Allowed Users and Groups icon

362

You should see something like this, start adding the users

Add the following users roommate1 roommate2 roommate3 roommate4 wood

Click Save

363

Click Restart Usermin

Now you Samba users, from inside your network, should be able to change their own passwords and view their Quota, without seeing the File Manager like your internet users have. To access Usermin, its http://your-ip-iaddress:20000 My ip is 192.168.2.1

So I would type

http://192.168.2.1:20000

364

Login as username

roommate1

And you should see something like this

As you can see, they only have two choices instead of four, because we dont want them to have the File Manager or the Upload and Download modules.

365

This is a really convenient way for your users to change their own password

Thats it for the locked down Usermin config, now you can show your users how to map their My Documents folder to the server (if you want) That way when they save files to their My Documents folder on their PCs and Laptops, they are actually saving them to their server share. First have them login to their share, and make a folder per computer. Something like my_dell_laptop and my_gateway_pc

366

Assuming this is roommate1 your working on, and assuming he has a Gateway Desktop PC and a Dell Laptop And assuming your sitting in front of the laptop right now.

367

Just right-click on his My Documents folder, and choose Properties

And change the Target path from whatever it says to \\192.168.2.1\roommate1\my_dell_laptop

368

Now everything roommate1 saves to his My Documents folder, will actually be on the server. And now from his Gateway desktop, if he goes to \\192.168.2.1\ and logs in

He can get to his laptop files from his desktop And vice versa, once both are setup this way Just make sure to move the current data out of the My Documents first, and paste it back in after the target has been changed. If you change the target while their data is still in there, it will appear to the user like all the data is gone, because the My Document folder isnt looking at their c:\Documents and Settings\user profile anymore.

For users doing the My Documents thing you will probably want to set them up to pass through authenticate. Meaning you will want them logging into windows with the same username and password as their share. In this example, you would set the roommate1s computer to login to windows as username roommate1.

369

That will allow him to pass-through his windows login credentials to the shares.

If this isnt possible, then you will probably want to map a network drive, to a drive letter, and then move the My Documents target to that drive letter. Either way works fine, the pass-through authentication is best. Thats about it for Samba, it would have been better to set it up on a separate computer. A computer without internet access even.

370

In the more advanced parts of this how-to, we are going to setup a VMware Server, which can run multiple virtual machines off this one machine, all managed over a webpage. This can also be a helpful way to separate Samba from FTP into two machines, just have them running on different virtual machines. There are countless ways to do it, depending on your security philosophies. Anyway, back to work

Next we are going to connect to a file share running on a Windows machine. Lets say the IP address of the Windows machine is 192.168.2.6 and its allowing Admin$ shares on C. We will mount this on our Linux box as folder /mymounts/samba2dot6 This folder naming to me means I mounted it (hence the folder mymounts) And that its a samba connection to machine 192.168.2.6 In this example, the entire contents of 192.168.2.6 hard drive will be accessible and useable from your Linux box.

371

Navigate to the Disk and Network File systems and click on Mount type

smbfs

I have had many users say that option isnt there. If it isnt there, the following three steps should make it show up. First, make sure you didnt miss the page that talked about apt-get install smbfs *This how-to isnt written to be able to skip pages

Second upgrade Webmin to the latest version Navigate to the Webmin Configuration module, and click on Upgrade Webmin

372

373

You should see something like this

Choose

Latest Version from www.webmin.com Upgrade Webmin

And then click

374

If successful you should see something like this

Third click on

Refresh Modules

*Note, remember you can also upgrade Usermin the same way

After the refresh is finished you should have smbfs as a mount type in the Disk and Network Filesystems Module

375

Add the mount type smbfs, and you should see something like this

Give some thought to mounting it at boot or not. If 192.168.2.6 is on all the time, this shouldnt be a problem. But for the most part, you wouldnt want to choose to mount it at boot time. Also give some thought to the account you use. Because that password will be saved in the file /etc/fstab This isnt a security risk at all, nobody should have that kind of access to your machine to be able to read that file. Linux is already setup to not allow that. But without local file encryption, and a couple security guards, there is always a chance it can happen. (like if the computer was stolen, or booted off a live cd) We talk about file system encryption later in the how-to. But giving a lot of thought to the passwords you put in that file is important to. As you can see, Im accessing computer 192.168.2.6 admin share on c$

376

Which should mean you have to provide an admin level password of that machine to access that share. But a work around is that Windows Backup Operators can also access admin shares. So if you make and account on the Windows PC your wanting to connect to, and you made that account a Backup Operator, and not an admin, it would still work. Or even better, create an actual share that a user level account can access, instead of using the admin share C$. Im just lazy and use the admin shares, as a Backup Operator, so I can access the entire drive without giving up the admin password. But putting a less important password in the box is smart anyway you look at it. After you create the mount, you can view the Windows PC files on your Linux box by navigating to the folder /mymounts/samba2dot6/

Next we are going to create some scheduled backup schemes.

Using the File Manager, create a folder called /mymounts/vraid/osbackups

We are going to create one schedule for Operating System related stuff, and another for our data. For the Operating System scheduled backup, we are going to use the Backup Configuration Modules module.

377

Navigate to the Backup Configuration Modules module, and click on scheduled backups.

And then click on Add a new scheduled backup

Notice there is also a Restore Now tab at the top. In the event something goes horribly wrong, or your setting up a new system, you can restore them using these backups and the restore now tab.

378

Click on Add a new schedule backup, you should see something like this

Notice how you are able to click on multiple choices in the modules to backup box. You can do this by holding down the control key (Ctrl) on your keyboard, while clicking on the choices.

379

Click on all the modules you would like to be part of this scheduled backup. Select as many as you want.

380

Notice I selected backup destination /mymounts/vraid/osbackups/bcf.tar

local file

Thats That means to me, Backup Configuration Files And its important we put it on disk2 (/mymounts/vraid/) That way if disk 1 goes bad, we have a backup on disk 2 Check all three boxes under Include in backup And list system files you want a backup of, that didnt have a module associated with it. Operating System stuff only ( / ), dont include anything from the second hard-drive (The data drive /mymounts/vraid/) We will make a different kind of backup scheme for that data, using a different module. Put your local email address, username-created-on- page 18 @localhost So mine is wood@localhost If you select Simple schedule You dont have to use the minutes\hours\days schedule below Click the Save button, and it will schedule the backup job, every month, on the 1st. Or better yet, click Save and Backup now so you can make sure it works.

bcf.tar

It will overwrite that file every month, which is probably what you want. But if you rather keep every backup job it makes, you can change the filename from /mymounts/vraid/osbackups/bcf.tar To /mymounts/vraid/osbackups/%m_%d_%Y_bcf.tar

381

This will add the current date to the filename, which will be different every month, and so it wont overwrite your backups.

Thats pretty much it, you can import these backups as a restore, and be back up in running in minutes instead of days.

The backups will be compressed into a single file using the TAR format, you can extract them and see them using the File Manager module. Just navigate to where the backup jobs are, and you should see a .tar file. Extracting can be messy if you dont contain it to a folder. So create a new folder called 2bdeleted

382

And copy the .tar file in there.

Then highlight it, and click extract Say yes if prompted Once they extract, you will see all the configuration files you selected to be backed up were indeed backed up.

383

The folder structure will be a little confusing at first. If you told it to backup /etc/vsftpd.conf . It will copy the folder structure. You wont just see the file vsftpd.conf You will see the folder etc, and the file vsftpd.conf inside of it.

Thats about it, if you ever need to restore the file or refer to it, you can find them here. And you should have a local email, telling you all about it.

384

Now we will setup a scheduled backup for the data drive. That uses a different module called Filesystem Backup. Navigate to the Filesystem Backup Module

Select

in TAR format

And browse to user jdoes home directory Then click the Add a new backup of directory

button

385

You should see something like this

Expand the two green arrows so you can see everything, and make the following changes

386

The Backup to field reads

/options/%m_%d_%Y_jdoe.tar

387

Keep the backup label name short and sweet, they dont allow it to be very long.

You only need to change the Minutes, Hours, and Days. Thats because we want it to run every month, so we dont want to specify A month, or it will only run on that particular month.

This particular schedule says at 23:01 (11:01pm) On the second day of every month, run the backup.

388

I did the second day, because we already have Operating System backups schedule on the first. You dont want to schedule them at the same time, that is too much work for the server to handle, so I did the second on every month. Careful to not select more than one number, like this

Because it will let you, if you not careful. Holding down the Control key on your keyboard will help you deselect them if this happens.

Thats about it, except the backup directory (/options) I selected would be a horrible place for your backups.

You would want to installed a third or fourth disk for these backup jobs, or maybe even a large USB drive. Or even better, take advantage of that SSH button, and do offsite backups. Meaning the backups exist on a different computer. A separate Linux box somewhere.

389

Earlier we talked about having a second computer setup only with Samba and SSH. You could use that SSH option to send the backups to that computer. This is the best form of backups, as it gets the files off the computer, and in a second location. Just in case that computer catches fire or is stolen or something. This second computer doesnt even have to be on your same network, it can be on the internet somewhere, and SSH will encrypt the transfer and the passwords for you. Click the Create Button and it should return you to the main screen.

If you get an error like this one below

Then just click on the Module Config link at the top of the page

390

You should see something like this

And change the following two options to yes. Then click save.

You should be return to the main page

391

Notice the TAR option is gone, because we set it as the default. Also that red error message should be gone as well.

Lets make another backup, they get easier after the first one, because instead of choosing a specific time, you can tell it to start after the one before it finishes.

392

Select the home directory for user testuser Notice now there is an Enable after option now

So instead of picking times, and guessing when you think they will be done by. Just tell it do start the next job, after the previous one finishes. You can keep building on this, have the third job start after the second job finishes, and the fourth job after the third finishes, and so on and so on. Dont forget about your samba users (nshares folder) As your list starts to grow, you can see the schedule on the right

393

Here we can see that second job starts after the first one finishes.

Thats pretty much it for the backups, just set it and forget it. And you should get local emails with the statuses. Just remember /options/ is a horrible place, I just used that as an example. Get some more hard drives, or an external drive, or better yet use SSH to another computer.

You can also export your users and their passwords to a file, this is really useful if youre planning on upgrading to a new server, but dont want to have to reset all your users password.

394

Navigate to the Users and Groups module

Take note of the User ID numbers your interested in (They will usually be over 1,000) And then click on Export to batch file

395

You should see something like this Make the following changes, tweak your UIDs range

Click Export now

396

If successful, you should see something like this

And be a nice admin, and consider that file extremely confidential. Now you can build a new server, import those accounts using the run batch file button under the users and groups module, and your users will never know anything has changed. See why you should change your password more often :- ) Thats pretty much all there is to it

Next we will talk about disk maintenance and trouble shooting. Every so often you should run fsck (File System Check) on your hard drives, its a lot like scandisk. There are few things you need to know before running this. The hard-drive cant be mounted, it first needs to be un-mounted. Some Google searched will tell you the options to force it to check mounted drives, dont ever do that. Never scan a drive that is mounted. It only takes a second to un-mount it, take the time to do that, its well worth it. You cant really scandisk your OS drive, because youre not able to un-mount it. Some Google searches will tell you have to use Single-User-Mode to do it, which is similar to a Windows Safe-Mode, dont ever do that either. Its do-able, but not worth the repercussions of typing something wrong. If you want to scan your OS drive, you should boot off a Linux Live CD, and run the commands below. Being booted of the Live CD will ensure the drive is not in use. Its worth the extra effort. Your data drives are a lot easier to scan, because you can easily un-mount them Lets say you want to run a quick scan on the hard drive /dev/sdb1

397

You would launch a Putty or SSH2 module session, and type umount /dev/sdb1 That will un-mount the partition Then type fsck.ext3 y /dev/sdb1 This command assumes your checking a drive formatted as EXT3. If you have been following this how-to, your drives are ext3. Running this on a non EXT3 formatted drive will cause major problems, and you wont get the warning, because of the y will answer yes to any prompts. This will run a quick scan on the hard drive, and the y tells it to answer yes to any questions. If you wanted to do a more in-depth scan, you could run fsck.ext3 -c -p -v -f /dev/sdb1 The c tells it to look for bad blocks on the hard drive, this scan will take a very very long time. And if you wanted to take it ever further, maybe you have a drive youre having problems with, you could run the following command fsck.ext3 -c -c -p -v -f /dev/sdb1 Specifying c c twice like that, will do a read and then write test to every spot on the partition. It claims to be non-destructive. Im not sure I would feel comfortable doing this command on a drive that I didnt have a backup of. Ive personally never done it on a drive that had data on it that I cared about. Im sure its safe, Linux is amazing, its just the write part of that scares me. Do yourself a favor and make a backup first. Options c and c c will note any bad blocks that are found, and mark them as not useable. At this point the disk is fixed a couple bad blocks is bound to happen. But if you have this problem more that once on the same disk, I would consider replacing it, and making sure your backups are up to date for that drive. If you already have a backup, and you want to really want to try reviving the disk, you can do the following. Note these are destructive, and your data will for sure be gone.

398

Type the following commands (this series of commands will take many days to complete) Do yourself a favor and just buy another hard-drive :- )

fdisk /dev/sdb m d w

dd if=/dev/zero of=/dev/sdb

fdisk /dev/sdb m d n p 1 Enter Enter w

mkfs.ext3 /dev/sdb1

fsck.ext3 c c y /dev/sdb1

You just used fdisk to delete the partition. Then you used dd to zero out the drive. Then you used fdisk to create a new partition. Then you mkfs to format it with the EXT3 file system. Then you checked the file system both read and write using fsck

399

Thats extremely thorough, and will take many days to complete those steps. You may even want to hookup a keyboard and monitor, because it will take so long, you will probably be tempted to close your Putty or SSH2 connection. This would make it hard to watch the progress. This is pretty extreme, with todays prices and warranties, you may want to consider replacing the drive when fsck finds problems more than once. You can then use the Disk and Network Filesystem Module to remount the drive. And thats about it for disk maintenance.

Next we are going to setup the Firewall, using IPTables. This is optional at this point because youre behind the firewall of your router. So this would, at this point, just be a firewall inside your LAN. But in some cases, especially small business networks, not everyone on your internal network is trusted. So if you dont completely trust all the traffic inside your network, then you would want to setup the firewall.

Navigate to the Linux Firewall Module

Choose block all except SSH and IDENT on external interface eth0

400

Do not click the Enable firewall at boot time option. We eventually will enable that, but not yet. Since we are doing this remotely, we need a way to un-do it if we mess something up, so for now, dont start it at boot time. Then click the Setup Firewall button

You should see something like this, stay away from that Apply button for awhile, if you click it now you will lock yourself out of Webmin

401

402

If you lock yourself out, rebooting will let you back in We can get away with this only because we are not setting the firewall to start at boot time (yet) Also stay away from that Apply button for now. Next delete the following conditions by putting a check box next to them, and clicking Delete Selected

Make sure to delete all the ones I have checked. We will add ICMP (ping) later on, but for this test it needs to be gone.

403

You should see something like this Change the default action for forwarded packets to Drop Then click the Set Default Action To button

Stay away from Apply button.

404

Click on the green word Accept next to port 22

405

You should see something like this, dont make any changes

406

We arent making changes to this screen, we are going to press the Clone Rule button at the bottom, this will save us lots of typing. Press Clone Rule the screen will refresh and youre now looking at a copy of the port 22 firewall rules

407

Make the following changes

Change the Rule Comment From Allow connections to our SSH Server To Allow connections to our Webmin Server Change Destination TCP or UDP port From 22 To 10000

408

Now scroll down and press the Create button You should see something like this

Note the port 22 exception is still there, because we didnt change it, we only cloned it. And now we have a port 10000 firewall exception as well

409

Keep doing that for ports

20

(ftp20)

21

(ftp21)

80

(web80)

445

(samba)

20000 (usermin)

Dont forget to click

Clone

every time you click on port 22, you dont want to make changes to port 22, you just want to keep cloning it.

410

You should eventually see something like this

Stay away from the apply button

411

Click on the green word accept next to port 445

We are going to lock Samba down a little further, its a little overkill for this setup, but its expected later on in the how-to

412

You should see something like this

413

Make the following changes

This will tell the firewall to only let in Samba clients that have a 192.168.2.xxx ip address. The /24 tells it to allow any 3 numbers, up to 254 If youre on a 192.168.0.1 network, you would use 192.168.0.0/24 If youre on a 192.168.1.1 network, you would use 192.168.1.0/24 If youre on a 10.10.10.1 network, you would use 10.10.10.0/24

414

Again, a little overkill right now, but we need it later on. You should see something like this

Click on Save

Youre now ready to hit Apply at the bottom, but make sure Active at Boot still says

no

415

416

Test everything, except FTP (there is another change we have to make for FTP before it will work) Make sure you can still get to Webmin, Usermin, Putty, Samba, your websites, etc If everything is working, return to the Linux Firewall module and tell to be active at boot time. Click yes, and then click the button Activate at boot

417

Then hit the Apply Configuration but, and navigate to the Bootup and Shutdown module.

Using the Bootup and Shutdown module, reboot the Linux box.

Wait a couple minutes and make sure you can still get back into everything.

Now from your Windows PC, try to ping your Linux box This should fail

If it fails, then thats good, it means your firewall is loading at startup and doing its job.

418

If it replies like this

Then something isnt right, go back and fix it.

Once you have it working, you will probably want to allow pings. Pinging is very useful for trouble-shooting.

So once youre sure your firewall is working, you can allow ping by going back to the Linux Firewall module and adding the following input rule

419

Click on Add Rule

420

Make the following changes

421

Then click the Create button Then click the Apply button You should now be able to ping the Linux box

Now lets make sure you are still able to access the internet

Using the Command Shell module, run the following command tracert google.com

422

I like to use tracert instead of ping from a Linux box, because I can never remember the ping limit commands off the top of my head. By default ping never gives up in Linux unless you give it extra instructions. So from this view dont use ping, because it will run forever in the background. If you want to use ping, make sure youre using Putty or the SSH2 module, where you can interact with ping, and stop it. (using Control + C on your keyboard) Or include the extra command line options to tell ping to give up after like 5 attempts ping c 5 google.com

If successful, you should see something like this with a bunch of numbers. Its ok if you have more than or less than 13 hops, we are just looking to see that it is hoping outside your network.

If you get a bunch of fails, go back and figure it out. Your firewall is blocking everything incoming, unless you request it. Here your requesting it, so it Established \ Related, and your firewall should be letting that through, as it originated from you, inside the firewall first.

Thats pretty much it, we just have to do one more step to allow FTP through.

423

Navigate to the File Manager module, and edit the file /etc/rc.local

Add the following line /sbin/modprobe ip_conntrack_ftp

424

You should see something like this

Save it, and reboot the computer. That rc.local file executes every time the computer starts up, so it should load every time now.

Once the reboot is finished, try FTP

425

It should be working now, if not, go back and figure it out.

You now have an extremely powerful firewall running, doing per packet inspection and filtering. Thats just the tip of the iceberg of what IPTables can do, but it should be all you need for now. As you get more comfortable with it, you can enable logging, and start reading the log files of blocks and attempts. Next we will setup etherwake A Wake-On-Lan tool that will allow you to Wake On Lan computers on your network, from within Webmin.

426

Navigate to the Custom Commands and click on

Create a new custom command

427

You should see something like this, make the following changes

Give it a description as to what computer it is (A computer on your LAN \ Subnet that you are trying to wake up) And the actual command is etherwake b mac address

Just make sure the MAC address is separated by colons : For help finding the mac address of a computer, refer back to earlier pages (often referred to as hwaddress or physical address) Click Save Make one for every computer you think you would ever want to wake up

*Advanced* Later on in the how-to, you will have two NICs. One will be so strongly firewalled that it will stop etherwake from working, there is a simple fix, just use the interface option i to tell etherwake which NIC to use

428

example: etherwake -b i eth1 00:1a:a0:a9:3b:bo You should eventually see something like this

You can use these custom commands for just about anything you want. I like to use them for hard to remember commands, or commands I run a lot.

Eventually you will have an entire page of custom commands button, just point, click, and viola

I like to make tracert and ping buttons as well, because a Linux ping wont stop unless you interact with it, so you can make a custom command button, with the / option to tell it when to stop and what to do. *Advanced* If you have a smart phone with a browser, you can access these custom command buttons from your phone, and do tasks like wake-on-lan right from your cell phone, without the need for any kind of shell access. Just make sure your phone is not set to remember any passwords or web history. Make a lot of these custom command buttons, they are very cool.

429

Thats it for the basic setup, if you start to have stability problems with your server, you can use a program called monit, that will monitor services, and restart them if they fail. It also has a web interface with some cool functionality. Also if you start to see a lot of hack attempts in your log files you can use a program called fail2ban (apt-get install fail2ban). This program will block a user by their IP address for a configurable amount of time after a configurable amount of attempts. They are super easy to configure and you can find many excellent examples on Google and on http://ubuntuforums.org Next is the optional \ advanced setup. Not that its any harder than anything you have done so far, its just we are going to move on to more dedicated uses, where the computer needs to be up 24 hours and day 7 days a week. We are going to turn the Linux box into your Router \ NAT \Firewall, a VMWare server, a Local DNS box with dynamically updating clients, a DHCP server, etc If youre not interested in any of that, you can stop at the end of this page. Youre encouraged to continue, its all really cool stuff, but setting the Linux box up as your router is kind of a big commitment on your part, when its down, your internet connection is down. Setting up VMWare requires a powerful computer with lots of RAM. DNS is a lot of work for small networks. You dont need a DCHP server if youre not replacing your router and you dont need a DDNS update client if youre not using Local DNS. So this may be a good time to stop if youre not interested in virtualization and networking. Thanks for using my how-to, let me know how it goes. *Side note, if you were interested in setting up software RAID 1 for your Operating System drive, this link will help you get that going. https://help.ubuntu.com/9.04/serverguide/C/advanced-installation.html

If youre stopping here, you can run an apt-get remove dhcp3-server Then run apt-get update and finally an apt-get upgrade

this will remove that DHCP warning at startup.

That will ensure you have the latest patches and upgrades, if youre not stopping here, do not run the You can find my email address and blog link on my homepage http://woodel.com Thanks!

apt-get upgrade

just yet.

KevinTheComputerGuy

430

Advanced. If youre choosing to go on, welcome to the advanced section. First we are going to setup rssh (restricted ssh) Im not going to spend too much time on this one. We are going to move pretty fast through this one, as many of its uses are far more complicated than some of the software solutions that exists today. SSH is awesome, but it gives the users access to way too much. rssh gives you basic SSH functionality, with the ability to pick and choose what access to give them, Which is perfect for giving users shell access. Due to a typo in an earlier version, you may have missed this install, its apt-get install rssh If you are not sure, just run it again. After the install completes, edit the file /etc/rssh.conf You should see something like this, make the following changes

431

Comment everything out except allowscp And change the umask to 777

Then click save and close Thats probably throwing up some red flags to you. 777 means full access right? In file permissions it does, umask is the opposite. Setting the umask to 777 will result in the exact opposite file permissions 000 As you can tell, we are really locking down this user. To the point of paranoia. With file permissions of 000, only root will be able to see these files. Thats because we are going to use this user, in a batch file, to remotely Backup files from a Windows PC. His password will be in plain text in said batch file, and could be compromised. So we want to make sure, even if the password fell into the wrong hands, that they couldnt do anything with it.

432

Next lets create an rssh user, named

backupbot

Navigate to the Users and Groups module, and click on Create a new user Now when you make a new user, rssh is available as a shell you can choose from for newly created users. If you dont see it in the drop down menu, just choose other See below, this user I created, I put in shell /usr/bin/rssh and browser to /usr/bin/rssh

Select normal password, give this user a password

433

And, you want to make sure you dont select to make him in other modules. This user is going to be an rssh user only

Now for the next level of paranoia. Navigate to user backupbot home directory, and set the following permissions.

434

With these permissions, that user wont even be able to see the files they upload. This is because if someone finds this password in your batch file, you dont want them browsing the home directory.

435

Thats some pretty extreme lock down we just did. You can take it even further with chroot in rssh, and use it to jail the user inside a directory. And you can use the file permissions to inherit a group that doesnt exist, or doesnt have a user in it. Im not going to go too much into the rest of this setup, but here are some hints if youre interested in pursuing it.

You could go to Puttys website http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

And download the following tools PSCP.exe and PLINK.exe These are rock solid secure, just like Putty is You could use a command like this one, using a combination of PSCP and WinRar ( http://rarlabs.com ) to do offsite backups of Windows PCs over a secure connection. ===================================================================================== rem start batch file cd %userprofile% taskkill /f /im OUTLOOK.EXE "c:\program files\winrar\rar.exe" a -agHH-MM-SS--MMM-DD-YYYY %computername%_My_Docs_Folder_Win2K_XP "my documents" "c:\program files\winrar\rar.exe" a -agHH-MM-SS--MMM-DD-YYYY %computername%_Docs_Folder_WinVista_7 "documents" %temp%\pscp.exe -4 -2 -P 22 -l backupbot -pw abc123 *.rar backupbot@kevin.gotdns.org: exit rem end batch file ======================================================================================

436

This command closes Outlook if its running, and then compresses the users my documents folder into a single file, then uploads it. It will name the backup file the same name as the users computer, and tell you if its Windows 2000\XP, or Vista\7 and add the date.

As you can see the password abc123 is exposed, thats why the permissions have to be so tight. ================================================================== rem start batch file %temp%\pscp.exe -4 -2 -P 22 -l backupbot -pw abc123 *.rar backupbot@kevin.gotdns.org: rem end batch file ================================================================== But even if it fell into the wrong hands, there isnt much of anything they could do with it. Of course a disk space quota is important for any user, always set disk space quotas to prevent abuse.

Also this will be an outgoing request from your users PCs, so you dont have to worry about a firewall configuration on the users end at all. Thats PSCP Next is PLINK PLINK is a really cool SSH tunneling tool. You can secure almost anything you want to do, because you can wrap the entire communication up in an SSH tunnel, much like a VPN connection. Everything you do on the port you specified for the tunnel, will be secured by SSH. And this will be also be an outgoing request from your users PCs, so you dont have to worry about a firewall configuration at all.

437

For PLINK you could do something like this ====================================================================== rem start batch file %temp%\plink.exe -ssh -4 -P 22 -l backupbot -pw abc123 -R 5900:localhost:5900 kevin.gotdns.org rem end batch file ======================================================================

This would create an awesomely secure tunnel form your users PCs to yours. Port 5900 is VNC, so when you launch VNC from your network, then you can remote the Windows PC user over that tunnel, with no firewall config needed on the users side.

But I dont want to spend too much time on those because there are easier alternatives. If youre looking to remote a user, just use Adobes ConnectNow software at http://acrobat.com (click on Web Conferencing) or TeamViewer at http://www.teamviewer.com/index.aspx both work very very well. These are free and web based and there is no configuration needed on either side. Your user can login as Guest without a need for an account, and all traffic is outbound, so again, no firewall worries. The Acrobat one even works on Macintosh. If youre looking to do offsite backups of user files. You should use something like Cobian backup, over your LAN to a local Linux box running Samba. And then have that Linux box use the Webmin Filesystem Backup module to schedule offsite backups to another Linux box over SSH. Or something like RSYNC or jailed SFTP or SSHFS. But its good to have the knowledge above, and I mostly talk about it so you know to not pick SSH when giving someone else an account to your Linux box. SSH by default lets them change directory to wherever they want. And without jailing knowledge, your files are way too exposed. So think this rssh = SSH for users besides yourself. Thats about it for those.

Next we are going to setup VM Ware Server. This is optional, as it requires a really fast computer with tons of ram and hard-drive space. If you dont have 100+GB of hard drives space and a couple extra gigs of ram, you should probably skip this part.

438

When youre done setting this up, you will have a separate https webpage (not within webmins menus) that you can use to control and create Virtual machines. Virtual machines use file(s) on your server that it treats as a hard-drive. And you can install Operating systems into these files. So your server, with no keyboard and mouse can host multiple GUI virtual operation systems, that you control over Remote Desktop, VNC, Or the VMWare Player. We are going to walk through how to install VMWare Server, and install a virtual instance of Windows 7. Its amazing what you can do with these virtual machines. You can choose bridged networking, and it will appear as a computer on your network. You can create snapshots before making changes and revert back to those snapshots. Or my favorite set it up independent non-persistent. You can make all the changes you want, you can reboot a million times, and all your changes stay there. But it you chose shutdown, instead of reboot, it will then revert back to the original settings. I find that feature to be priceless. So first you have to download VMware Sever from VMwares website https://www.vmware.com/tryvmware/?p=server20&lp=1 I cant provide a direct link to the file. And or put one on my server. Even though VMWare Server is free, they make you register your email address, and send you your serial number that way. Make sure to use a real email address when registering, as they are going to email you the serial number, you have to have that to complete the install. Make sure once you finally get logged in, that youre downloading VMWare Server for Linux (preferably version 2.02xxxxxxxxxxxxxx) Thats the version I used. You want the binary file, in .gz format.

439

It should look something like this

Make sure to get the right version. If you running a 64bit version of Linux, then download the 64-bit installer. If youre running a 32bit version of Linux, then download the 32bit installer. Download this file using your windows PC, and we will upload it to the Linux box, and then move it into place. If this is your first time uploaded a large file to your Linux box, you will notice the Upload and Download manager will take way too long, and will probably fail. So you will want to use FTP or Samba. If your using FTP, make sure to use account name uploadman as his home directory is not exposed to the web. You dont want to share this file with anyone, this is your own registered copy. If using Samba use account name wood or the name you chose on page 18 If you never went back and made that account work with Samba, just use one of the roommate accounts that arent in use.

440

Once you have uploaded that giant VMWare installer file, Open up Webmin and navigate to the File Manager Module. Navigate to the home directory you uploaded the installer file to. Remember uploadmans home directory is in a different place than your other users, he is in /home/uploadman and not /mymounts.

Once you find the installer, cut and paste it to the /options directory. Im on a different computer today and will be using the 64bit installer, so my filename may look a little different than yours. Wait for the paste to finish, then navigate to the options directory, and highlight the VMWare file by clicking on it once

Once you highlight the file, click extract button at the top

441

Choose

Yes

If youre hurting for space you could choose yes, then delete But if youre hurting for space you probably shouldnt be installing this :- )

That file is uber compressed, so give it a couple minutes to finish. When its finished, you should have a folder like this one

442

Youre done with the File Manager for now, the rest of the setup will be done command line. Do yourself a favor and use Putty. The SSH2 module is very convenient, but I havent figured out the copy and paste problems yet, and I want you to be able to copy and paste these next few commands exactly, so lets use Putty. Login to Putty as username root

443

And change directory to the /options directory

Type

cd /options

444

Then type dir, or ls a And press the enter key on your keyboard

Then type or

cd vmware-server-distrib

cd vmw*

Note vmw* will only work if that is the only folder in that directory starting with vmw Remember you can also copy\paste these commands

445

Once youre in the vmware-server-distrib folder, type You should see something like this

dir

Run

apt-get update Then type the following command, and hit enter on your keyboard.

Copy and paste it exactly as shown, even that uname part, thats not your name, copy it exactly. apt-get install linux-headers-`uname -r` libxi6 libx11-6 libx11-dev libxtst6 psmisc build-essential x11-common libxau6 libxdmcp6 libx11-data libxrender1 libice6 libxext6 It may ask you a few times if you are sure, say yes

446

After that completes, run the following command, and hit the enter key ./vmware-install.pl

Its going to ask you a bunch of questions, you can hit enter to almost all of them. Hitting enter accepts the default answer to the questions that its asking you. Almost all are the correct answer, with the exception of a few preferences

So far all of these have just been enter

447

You can also hit enter for that last question in the print-screen, yes it is ok to invoke that process

Its ok that these two failed It trying to stop services that dont exist yet, just hit enter

448

Click enter to read the End User agreement You will have to press enter like 100 times to get to the bottom. Holding down the enter key works nicely for this part if you have already read it before.

You can tell they assumed people would just hold down the enter key, as the next question makes you type yes

449

Type yes and hit the enter key

Its time to slow down here and pay close attention when you get asked this question.

450

Press enter to say yes, but get ready to pay attention

If you get this warning about gcc versions, say no !!!!!!!!!!!!!!!!! No should be the default answer, so you can still get away with pressing enter

451

Saying no will kick you out of the installer, thats ok, thats what we want

Type the following command and press enter on your keyboard export CC=/usr/bin/gcc-4.1 *remember you can copy\paste

452

It will just do it, and not tell you anything back, this is what we want

Now type the following command and press enter vmware-config.pl

453

This will re-start the installer right where we left off Again these fails are ok

Say yes to this question by pressing enter

You shouldnt get the gcc error this time.

454

As long as you dont get that gcc error again, you can keep saying yes for the following. *Never say yes to that gcc error The screen will start scrolling very fast as it installs the modules.

When you get to this question, say yes, its just making sure the gcc error is fixed

If all goes well, the gcc error is gone and the installer will continue

You can say yes, press enter for these

455

Keep pressing enter, these default answer and network names are perfect

456

Say no when asked to configure a 2nd NAT device, this is the default answer anyway, so pressing enter will work here too.

457

Dont be alarmed by that weird looking IP address. That is a private address for the VMs if you choose to not expose them to the network, and pretty much make them invisible. We will cover that later.

You can say yes, we wont use it, but this is the best time to set it up

458

You can keep hitting enter until you are asked if you want to setup a 2nd host only network. Say no, one is enough.

Dont be alarmed by the weird IP addressed, we wont even use them.

The default answer to the second host-only prompt is no, thats what we want, go ahead and click enter.

459

You can say yes to this, this isnt the gcc error

Write down these port numbers, you will need them later

460

Just hit enter to the admin question. This tells the computer you want to use your root password, just hit enter Finally the question we have been waiting for. This question and the gcc error are the only reasons you couldnt just close your eyes and hold down the enter key. Its asking you where to keep the virtual machines at, you want this to be your data drive /mymounts/vraid/vm folder

461

Or

/mymounts/d2p1/vm

depending on your setup

As this is your big hard-drive and you dont want the vm files on your os drive, slowing down your OS.

That VM folder doesnt exist yet, so its going to warn you its going to create it.

462

Notice its warning you its going to make some parent folders, this is OK, say yes

Next it will ask you for your serial number. That should be in your email by now.

Copy and paste the serial number in there and press enter

463

For the VIX questions you can keep hitting enter

464

You should finally see something like this, you done installing the VMWare Server

465

Earlier you wrote down some port numbers Should look something like this

Now open up an internet explorer page on your Windows PC and type https://your-linux-box-ip:8333 *Note, this isnt working in Firefox at the present time, but I am sure they will fix it soon. And is probably more Of a Java problem then a Firefox problem. It does work on IE 7, IE 8, and Chrome Today my IP is 192.168.2.5 So I would type https://192.168.2.5:8333 Get ready to be really impressed :- )

466

If you get the certificate error, say yes or continue It is completely safe

467

Login as root

And viola !!!

468

Your own VMWare Server, running on a non-gui OS !

If youre prompted to install the plug-in, go ahead and do so.

Notice its calling your /mymounts/vraid/vm And its named that Datastore standard

folder a Datastore

These are just VMWare terms, when youre inside VMWare refer to it as Datastore standard, and when youre in Webmin refer to it as /mymount/vraid/vm

469

Now we are ready to install a virtual instance of windows. Im going to do Windows 7, you can do any flavor you want. If you dont have a Windows CD, you could setup Linux instead. The steps will be pretty much the same. Go stick the Windows installer CD\DVD into the CD\DVD drive of the Linux box, and then come back. or even better, upload an .iso of the CD via Samba or FTP, then use the Webmin File Manager module to move it into /mymounts/vraid/vm *Similar to the same way you got the VMWare installer into the /options folder If you doing the .iso file Once you get it pasted into the /mymounts/vraid/vm folder Make sure the permissions are 755, im not sure what user the process uses, so 755 should make it accessible. *reminder, use the Info button to change permissions

470

Once you have either the disk in the drive or the .iso uploaded, return to the VMWare Server Management webpage and click on the Virtual Machines tab,

471

and then click on Create Virtual Machine

472

You should see something like this

I called it from scratch because this isnt the only way to make one. You can actually download the VMware converted from VMwares website, and capture images of real computers on your network, and import them into your server. Never needing to actually build them, and they bootup and act just like the real thing. Its really impressive, and also free. But lets get back to building ours from scratch.

473

After you name it, click next, you should see something like this. Chose your operating system

*Windows 7 wasnt in the list, you can usually get away with choosing something close. Its just trying to determine what type of file system and hardware youre going to use, so choosing something close usually works. Click next

I usually go with double the Recommended ram size, and 1 Processor.

474

Click next

475

Click create new virtual disk

476

You should see something like this

I doubled it from 16GB to 32GB And told it to allocate the space now Click next

477

Here is that cool feature I was telling you about, dont enable it now, as you want it to remember all the changes your doing. But if you get to a point where you want it to start forgetting changes, here is where the setting is at

Again, dont select that now, you can change that later once the OS is installed. But I wanted to show you where it was at. Its under the hard-drive properties of each virtual machine you create.

478

Click on Add and network Adapter

479

Choose Bridged

Click next

480

If youre using a real CD\DVD disk, click next If youre using an .iso like me, then click Use and ISO Image

481

You should see something like this (if you selected iso) Click on Browse, find the .iso under your datastore, under inventory. And click OK

482

Click next

483

Choose dont add a floppy drive And click next

484

Choose Add a USB controller and click next

485

Put a check box next to And click Finish

Power on your Virtual Machine now

486

You should notice a new entry under the Inventory tab Click on the Virtual Machine name Then click on Console

As soon as that progress bar gets to 100%, you should start to see the virtual machine boot up. *it takes a long time the first time, because we told it to allocate that disk space, so its making a 32GB file right now, be patient.

Once it gets to 100%, it will say Powered on, click anywhere in the screen to open the virtual machine

487

Click in the black box, and you should get a pop up, with the new virtual machine

488

You should see something like this

Eventually you will get to a screen where you can start installing the OS

489

Pretty awesome right

This view is called a console view or player view. You probably wont get a lot of use out of this view. Except for the initial install, and maybe some trouble-shooting. Once your installer finished, the Virtual Machine will get an IP address, then you can remote desktop into it (if Windows) and it will appear to you as a real computer, just like any other computer on your network. Its pretty limitless what you can do with this stuff. You can create raids that are actually just copies of the same files. You can create virtual switches, which are actually a bunch of virtual nics on the same computer.

490

Earlier we mentioned NAT and Host-Only networks. We arent going to use those in this how-to. Those are private networks, between your Virtual computers and your server. One is totally private (host only) and the other acts like there is a router between you and the real network. This is useful of you want to run servers that arent allowed on the real network. Example, if you want to play around with a DHCP server, you wouldnt want two of those on your real network. We will only be using Bridged, this way the virtual computer acts like a real computer, and shows up on your network with a real IP address, just like a real computer would.

Dont be scared to format your Virtual Machines hard drives. This wont re-format your Linux Box hard-drive. These are just files to your Linux box, acting like hard-drives for the Virtual machines.

491

You will probably be tempted to share your /mymounts/vraid/vm folder using Samba Dont do that. Its way too easy to run into an access violation. Do like we did earlier and use a combination of different shares, and the Webmin File Manager to move files in and out of that Share. And make sure to always power down your Virtual Machines before clicking, touching, moving any vm files around (this included just copying) If your mouse cursor seems stuck inside the vm, just press Ctrl + Alt on your keyboard to release it

492

You should eventually find yourself at the virtual machines desktop. Again this player view is the worst performance mode, you will want to remote desktop into it, once you have all the IP, Firewall, and port-forwarding settings in place. The player mode is mostly for the initial setup, trouble shooting, guest access, and maybe if you do any VPN type stuff. You could benefit from the player view, but strive to get into a remote desktop session for way better performance.

493

As far as guest \ cloud user access, you can provide shortcuts directly to the player mode. Navigate back to your https :8333 page, click on the virtual machine you want to give access to, and look over in the right-most pane You should see something like this

If you click on create shortcut It will let you download a link you can send to people, to access the virtual machine in player mode.

This is pretty amazing stuff, but be careful here!. This 600 plus page how-to would be about 600,000 pages if we had to talk about local \ internal security. We can skip a lot of that because all access to your internal network from the bid bag internet is blocked. If you give someone access to a bridged VM, it the exact same thing as them walking in with a laptop and plugging directly into your network. They are now on your wired, internal, trusted private network. And following this how-to, we trust all internal wired computers.

494

So, dont give these shortcuts to anyone who you dont trust as a local user inside your network. And remember this view is the worst performance view, consider giving them remote desktop access instead. I only give these shortcuts to people who arent savvy enough to remote desktop in. Or need boot time access to the drive.

If you find yourself needing to add more storage or Datastores as VMware calls them. And you have decided you want to add network storage instead of another local harddrive. VMware is going to try to walk you through setting up a NIS server. Dont do that, thats too much work for something so simple. Use Samba instead. It will appear in the VMware options that you cant. But you can trick it using Samba. Just mount a file share to another computer using the Disk and Filesystem module, mount type SMBFS (like you did earlier ) and VMware will think that folder or mount-point is a another local drive, and will set it up as a Datastore. If youre going to be doing really hardcore stuff, then you should connect to an iSCSI server. But for non enterprise use, the share will work just fine, and only takes seconds to setup. Your VMware server will see /mymounts/samba2dot6/ As a local folder in the add Datastore wizard, and wont bother you to set up a NIS server.

Thats about it for VMware, pretty amazing stuff, enjoy. *Side note, If this VMware Server doesnt meet your needs, you can take it to the next level and setup an ESXi server. On a dedicated 64-bit computer you can install VMwares ESXi operating system. Just go to http://vmware.com make and account, and download the ESXi iso. The install will erase your hard drive and install the proprietary ESXi operating system. All it does is host Virtual Machines, but its very good at it. You manage your Virtual Machines remotely using VMwares Vsphere client, its pretty amazing stuff, if you needed something more than what we have done here. Thats it for VMware.

Next lets stop for a second and talk about file encryption. In the same way that local backups pale in comparison to offsite backups. File encryption pales to Filesystem encryption. We are talking about this now because you are in the Advanced how-to.

495

If you cant lock the door where this Linux box is. If you cant setup a $20 webcam too watch for people trying to steal your Linux box. If youve got enemies at the FBI :- ) Then you would want to setup complete Filesystem encryption. Anything less than encryption at the Filesystem level is un-acceptable. This is really easy to setup. Start this how-to all over again, and on page 12, choose LVM encryption. Thats it, except for the format taking a couple days (literally) your computer will boot up and ask for a password before mounting the drives, without the correct password, its as if the data doesnt exist. Ive tried to break it, leaving just one letter off the right password. No go, its so very strong. Its the only one worth doing. I prefer to only use it on laptops, it can make data rescue a pain in the butt. And I have a fat pad-lock on every one of my servers, so as far as what I practice, I only do this on laptops and servers Im solely responsible for. But once you chose LVM encryption, the kernel will be built correctly during setup, and you can then tweak it via Webmin under the Hardware \ Local Volume Management module (LVM) Make sure your first Linux experience isnt with encryption. It can make disaster recovery a pain, and remote reboots arent really going to work for you, as youre prompted for a password to reboot. A couple Google searches will teach you how to hardcode that password in, but hopefully you see that flaw in that. I prefer to not hide the key next to the lock :- ) If this is your first Linux experience, hold off until your third or fourth time before you dive into that. But its amazing, and worth the effort. Ok, we have come to the final part of our how-to. The next steps deal with setting up your Linux box as a router and then optionally, a local DDNS server. Setting up your Linux box as a router means anytime you want to reboot or trouble-shoot. Your users will have no internet access. So make sure this is something you really want to do. And I say DDNS not DNS because it (D)ynamically updates your local DNS records via your DHCP clients. Basically your DHCP clients will all get DNS entries automatically, when they get their DHCP leases, very cool stuff. Extremely useful on a large network, but can be a little overkill on a small one. I have a problem where I memorize IP address, because I am weird like that, and wind up never using the DNS name. But your users will never remember IP address, thats when it becomes necessary, and the flexibility of name control on your network is nice.

Ok, truth is your about to build a very powerful router. So lets do this. Warning!!! These next steps will disconnect you from the internet for a very long period of time. You might want to finishes reading the how-to before moving on.

496

Warning, if you have ADSL, DSL, PPOE and or an All-In-One Modem\Gateway\Router, you may not want to continue. This how-to was written mostly for Cable internet users, and or small business users on a LAN wishing to create a sub network \ private network. Even Cable internet users, if you have All-In-One Modem\Gateway\Router, you may not want to continue. The reasons ADSL, DSL, and or an All-In-One Modem\Gateway\Router users may not want to continue is, this how-to walks you through setting up your computer as a drop in replacement for your router. But if your router is an all-in-one solution, you cant really remove it from your network, as the modem still needs to do its function in order to get you out to the internet. You could disable the routing feature of the all-in-one, but it would still be powered on and using electricity, and sitting next to a computer doing the same exact function. And even if you decided to disable those features and continue on, most ADSL and DSL modems use proprietary instructions written in their firmware that wont let you back out to the internet without passing through its NAT first, so disabling that function would unfortunately break your internet connection. So long story short, only continue if you have a setup, where the modem is a piece of hardware all by itself, (this is usually only cable subscribers, as in cable TV or coax cable modem) and or a internet source with a public IP address without PPOE, and or youre on a small business network and your wanting to create a sub network behind your current network.

You will also need a second network card to continue. You will later be installing this into your Linux server. You will need to set a couple Static IP addresses, as you are going to be without DHCP for awhile. If your Linux server is still DHCP, you must change it to static. Also if youre still using a static IP address of 192.168.2.111 (x.x.x.111) or 192.168.2.174 (x.x.x.174) You should change it to 192.168.2.1 (x.x.x.1) before continuing. It is good practice to have your router and gateway be x.x.x.1 basically the first IP address of your scheme. Youre about to turn this box into a router \ gateway, so change the IP address if you havent already. You can refer to pages 48 and 49 if you forgot how to make this change. And reboot to make the change affective.

You will need to temporarily set your Windows PC to use a static IP address, within your same IP scheme. Im going to use IP address 192.168.2.9 on my Windows PC. There are some screen shots on the next page on how to do this. Dont move on until you have figured out how to give you Windows PC a static IP address within your same IP scheme. If you right-click on the network card (Local Area Connection) on your Windows PC, and go to properties, we can walk through how to set that up.

497

You should see something like this

Right-click on it and go to Properties

498

You should see something like this

Click-on

Internet Protocol TCP\IP

and then click Properties

499

*Note, if your screen shows IPv4 and IPv6, choose IPv4 You should see something like this, make the following changes and click OK

500

If these numbers look French to you, refer to earlier pages for an IP scheme refresher. Click OK again, as many times as it takes to get out of those screens, and then reboot your Windows PC. At this point, if youre using my same numbering scheme, you should have a Windows PC with a static IP address of 192.168.2.9 And a Linux server, with one NIC, with a static IP address of 192.168.2.1

For now on we will be referring to your original Network card (eth0) as eth_safe And the new NIC, the second one (eth1) as this before moving on. eth_bad

that is the one with IP address 192.168.2.1

thats jumping a little ahead, as we havent even installed it yet, its just important you grasp

eth_safe will be the LAN side of your network, and eth_bad will be your WAN side of your network.

Before moving on, make sure you can still get to Webmin from your Windows PC. Webmin should now be at https://192.168.2.1:10000 if youre following my numbering scheme. *If you just recently changed the IP address, Webmin will take an extra long to load the first time you open it, just give it a minute. We need to stop the Firewall from loading at startup on your Linux server. The configuration of it is no longer valid now that you want to do routing. Navigate to the Linux Firewall module, and stop it from loading at startup.

501

You should see something like this

Change Active at boot to No Then click the Active at boot button to make it stick, then click the Apply Configuration

button

502

Reboot your Linux server, you should have no active firewall at this point. Triple check by logging back into Webmin and Navigating back to the Firewall Module, and make sure that button still says No.

Power off your current router (example: Linksys) and remove it from your network. Note, this assumes you have a switch you will be using instead. If not, you can still use the 4 LAN ports on your old Linksys router. And re-introduce it back into your network as a switch. As long as you dont ever plug anything into the WAN port of the Linksys router ever again. Put a piece of tape over it if you have to, and never use it again. (Some router models call it an uplink port) Never use the Uplink port or WAN port on the Linksys router ever again, this will cause it to act just like a switch. If it has wireless capabilities thats ok, later I will show you how to make that work with your new setup.

Removing your Linksys router from your network, and or using it as a switch instead of a router can be kind of hard to picture the first time you do it. So I drew you a few pictures. This first one would be an example of salvaging your current wireless router.

503

504

This second view would be if you ditched your Linksys router all together, and just used an actual switch.

505

This third view would be if you used both a switch and a wireless router (AKA wireless access point)

506

Decide which picture best describes what you want to do, and then shut off the Linux box. After powering off your Linux box, install the second network card inside the computer, but do not plug the cable in yet! Again do not plug the cable in ! Only your original network card you started this how-to with should have a cable going into it. Keep the cable coming from your ISP out of the picture for now, it should be sitting there not plugged into anything. Once you have the NIC properly installed, power on the Linux box. Once we configure it, the new NIC will then be known to the system as eth1 and known to us as eth_bad Visually you will know it as your WAN port, but we will continue to refer to that as eth_bad. It just helps in visualizing whats going on, as this will be the NIC eventually connected to the big bad internet, via your Cable\DSL modem. eth0, or our trusted NIC, the one plugged into your switch will be referred to as eth_safe. Just for clarification, Im calling your old Linksys router with a piece of tape over the old WAN port, a switch.

Later in the how-to, when we setup our firewall rules, we will trust everything from eth_safe, so its important to stop here if you dont understand that. You have 2 NICs now, one is eventually going to be plugged into the Cable or DSL modem, thats eth_bad. And again, it should not have a cable plugged into it right now. If later you get confused, eth_safe should have a static \ private IP address, and eth_bad should have a DHCP IP address it obtained from outside this network, better known as a Public Address. If that doesnt make sense to you, dont continue the how-to until it does. Or maybe keep reading without doing, a wrong choice here could expose your network to the outside world. If your Linux box has internet access right now, stop! You have done something wrong. Next we are going to configure eth_bad (eth1)

507

Using the Webmin File Manager module, navigate to and edit file /etc/network/interfaces Go ahead and enter the following info, or copy \ paste. allow-hotplug eth1 iface eth1 inet dhcp

You can Ignore that up /sbin/ifconfig part for now Also enter anything you might be missing for eth0. Once everything looks good, click on Save and Close

508

Hopefully you wont need that /up/sbin mtu line, we will talk about that later Reboot your Linux box to activate that new NIC You cant really test all that speed, duplex, and MTU stuff until you have a cable plugged in. So we will have to come back to that later. Dont plug the cable in yet, just remind yourself later to check that out. Like you did on earlier in this how-to, use a combination of ifconfig, mii-tool and ethtool to make sure you have the right speed, duplex, and MTU settings. These problems are rare, but nasty. In that last print screen you could see I had a problem with the MTU on this NIC and had to force it. Hopefully you wont have that problem, I rarely see it. But if you do, just Google search the right MTU settings for your ISP. Cable modems and LAN are almost always 1500 MTU, some DSL connections I have seen are 1400+ MTU. Docsis 2.0 = 10\100, Docsis 3.0 = 10\100\1000. A Google search should show the right setting for your situation. Try Google first, most people at your ISP customer support center wont know what you are talking about :- )

We are now going to change a setting that is going to allow packet forwarding between to two NICs. This is reason we have done so many overkill security settings, because after you make this change eth_bad with be able to forward packets to eth_safe and vice versa

Navigate the File Manager module, and edit file

/etc/sysctl.conf

509

Add or un-comment the following line net.ipv4.ip_forward=1

Now is a good time to reboot, This reboot will enable packet forwarding between the two NICs

You computer may take a long time to start up, as its searching for DHCP on eth_bad, but there is no cable plugged in yet, just wait a few more minutes than usual, it will come up. Do not plug in the cable yet. Next we are going to setup the DHCP server, it will hand out DHCP IP addresses to your internal network, originating from eth_safe (eth0) and feeding addresses to anything behind it (your switch)

510

You already have the DHCP server installed, we just have to tell it which NIC to use and enable it. Navigate to the DHCP Sever module, and click on Edit Network Interface

511

You should see something like this

Choose (eth_safe) eth0 and click save

You should be returned to the main DHCP screen, click on Add a new Subnet

512

You should see something like this, make the following changes Subnet description Make something up Network address - 192.168.2.0 Netmask - 255.255.255.0 Address range 192.168.2.50 - 192.168.2.99

Leave all the other options alone and click Create Now and or Save depending on what your screen looks like.

513

Now a new icon should have appeared on the main DHCP server page underneath Subnets, called 192.168.2.0. Click this icon, you will be returned to a screen similar to the one you just left except it has some new buttons at the bottom. Click the one that says "Edit Client Options". Make the following changes

Subnet mask - 255.255.255.0 Default routers - 192.168.2.1 Broadcast address - 192.168.2.255 DNS servers - 192.168.2.1

You will have to hit save twice, here and the next screen.

514

You should be returned to the main DHCP screen, where you can start the DHCP server

You now have a fully functioning DHCP server. You should be able to release the IP address on your Windows PC, and get a new one handed out from your Linux box. If you dont know how to release your IP, just reboot your Windows PC, that will do it to. *If youre using a static IP address on your Windows PC, you would have to switch it to DHCP to see the fruits of your labor.

At this point you have your Windows PC plugged into your switch, and your switch plugged into eth_safe

If your wireless there are a couple setting changes you to need make on the old wireless router (Wireless switch \ Wireless access point) You should be able to access the wireless routers admin webpage using your Windows PC and cable going into one of its LAN ports. Login and make the following changes.

515

-Disable its Built-in DHCP server -Change its routing function from a Gateway to Router (not all models have this feature, if not, just leave it at Gateway) -Disable its Built-in Firewall -And optionally you can delete all your Port-Forwarding, NAT, DDNS, and any other custom settings on your old router, as they are no longer functioning in this scenario. All that will be handled by your Linux server from now on, so these settings are not longer doing anything for you. You can then use the 4 LAN ports just like a switch, never using the WAN port again. (the WAN port is usually 10\100, so you may have just removed a future bottle-neck in your network)

And voila, now you have a wireless router that is dumbed down to act like a wireless switch instead. If you had to set a static IP address to talk to your Wireless router (aka wireless switch) dont forget to set yourself back to DHCP. Whats nice about this setup is you can now put that wireless router wherever you want in your house or building (as long as there is wiring going to it) Youre no longer confined to have it next to your Cable \ DSL modem. Which is normally in some closet somewhere surrounded by lead and 4 foot thick walls :- ) Smart placement of your Wireless router is the key to good signal strength.

Next we need to destroy the current Firewall configuration so we can set it up the right way. Even though its not loading right now, it still has all the wrong settings in it.

516

Navigate to the Linux Firewall Module, and click the Reset Firewall button

517

You should then see a screen like this, make the following changes

Do Network Address Translation (nat) on eth_bad

(eth1)

If you see a checkbox about starting the Firewall at startup, make sure that is not checked. Like before, we want a way back in if we mess something up

Once your screen matches mine, Click

Setup Firewall

518

You should see something like this

At the bottom of the screen change Active at Boot And press the Active at boot button And then press the Apply Configuration button We do eventually want it activate at boot, just not yet

to

No

519

Change the field at the top, next to the

Showing IPtable button

Click the drop down arrow and select

Packet Filtering (filter)

520

Once you are sure you in the filter screen Set the default action for (Forward) to drop Then click the Set Default Action To button next to it

Do not click the Apply Configuration button, not yet anyway

521

Do the same thing for (INPUT)

522

Do not click the Apply Configuration button, not yet anyway. However make sure you are clicking the Set Default Action button. It wont let you change those both at the same time, so double check that (FORWARD) and (INPUT) are set to Drop And double check that you have clicked the Set Default Action To: button for both

Double check that your screen looks like this Do not hit Apply yet

523

If you accidently hit apply and have locked yourself out, just manually reboot the Linux box. We dont have these rules in startup yet, so a reboot will get you back in for now. Once we are sure it is working, we will finally put in startup. Lets talk a brief second about the Firewall and the settings we are going to make. The Linux firewall works with three IP tables: MANGLE, PREROUTING and FILTER. The actual firewall part is done with FILTER

In this configuration we are going to allow anything and everything on eth_safe (eth0) because that network card is internal, and is running from the Linux box, to a local switch inside your network. We are going to allow everything from (lo) the local loopback interface. We are going to block everything (with the exception of outgoing traffic) on eth_bad (eth1) as that network card is exposed to the internet, as it is running from the Linux box, to your high-speed modem or internet feed. The idea is for eth_bad to be a way out to the internet, not a way in, unless requested from behind the Firewall, or explicitly specified by you.

And any PortForwarding you might need is done in PREROUTING, and then passed to the FILTER (FORWARD). Thats why later when we setup PortForwarding, we have to make sure we allow them in both places.

OK, Lets configure the Firewall

524

Here is a glance at rules we will be defining INPUT Accept if protocol is ICMP (This is optional, but recommended, very handy) Accept if incoming interface is lo Accept if incoming interface is eth_safe (eth0) Accept if incoming interface is eth_bad (eth1) and state of connection is ESTABLISHED,RELATED FORWARD Accept if incoming interface is eth_safe (eth0) and outgoing interface is eth_bad (eth1) Accept if incoming interface is eth_bad (eth1) and outgoing interface is eth_safe (eth0) and state of connection is ESTABLISHED,RELATED

525

To add these rules, click the Add Rule

button, under INPUT

526

You should see something like this Make the following changes for ICMP (ping)

Then click Create

527

You should see something like this

Click the

Add Rule

button again

528

You should see something like this Make the following changes for lo (LoopBack)

Then click Create

529

Click the Add Rule button again You should see something like this Make the following changes for eth_safe (eth0)

Then click Create Click the Add Rule

button again

530

You should see something like this Make the following changes for eth_bad (eth1)

531

You have to hold down the control button on your keyboard to select more than one item. Select both Established and Related

Then click Create

532

You should now be seeing something like this

Now under the FORWARD section, click

Add Rule

533

You should see something like this Make the following changes for forwards from eth_safe to eth_bad

Then click Create

534

Click the Add Rule button again , make sure your still under FORWARD You should see something like this Make the following changes for forwards from eth_bad to eth_safe

535

Then click Create You should see something like this

Cross your fingers and click the

Apply Configuration button

Did you disconnected from Webmin? Can you still click around on the other modules?

536

If you can, then congratulations, you did everything right. If you got disconnected, and your sure your plugged into eth_safe, then you did something wrong, you can turn off the firewall by manually rebooting your computer.

If you didnt get disconnected then you are ready to put the Firewall in startup.

537

Navigate back to the Linux Firewall module, and change the Activate at Boot to yes and click the Activate at boot button.

And then click Apply Configuration

538

It is now safe to plug your cable into eth_bad, now you should have two cables in the same machine. The cable coming from your Cable\DSL modem, or your ISP \ internet connection, goes into eth_bad (eth1) The cable from eth_safe (eth0) should be leading back to switch inside your private network. Once you have both cables where they are supposed to be, reboot your Linux box.

After the Linux box reboots, use the Command Shell module to run The ifconfig command

ifconfig

*Note, if there is just too much information on the screen for you after you run ifconfig You can instead run ifconfig eth0 ifconfig eth1 etc.

And only see the details for the NIC you specify after the command

You should see at least 3 network interfaces, you will have more than that if you did the VMware portion of this how-to

539

eth_bad (eth1) should be getting a Public DHCP IP address from your ISP. This IP address should look a little weird to you, and in most cases, shouldnt start with 192.168 Also, this is a good time to make sure the MTU, speed and duplexes are correct.

If youre not getting a Public IP address for eth_bad (eth1) somethings wrong. It could be as simple as your ISP is doing MAC address restrictions, meaning they want you to call them every time you get a new router.

You can do that, call them and give them the MAC address for eth1 (also known as the hardware address)

540

Or you can clone your old routers MAC address, so eth1 acts like its MAC address is the same as your old router, then you dont have to call your ISP. Because they wont know there was a change. But in most cases, you have to call your ISP and give them the MAC address for eth_bad

If you still want to try and clone your old routers MAC address, navigate to the File Manager module, and edit The file /etc/network/interfaces

541

Somewhere under allow-hotplug eth1 Put the following command hwaddress ether xx:xx:xx:xx:xx:xx Use your old routers WAN port MAC address in place of these numbers and or xs

This will force eth1 (eth_bad) to act like it has the MAC address you specified. Save and Close

542

Reboot your Linux box Do an ifconfig And you should see that eth1 now has that MAC address you specified and has a public IP address. At this point your server is configured as a working router/dns/dhcp server. It should work ok in this setup for everything you need it to do The rules implement thus far create a very simple (yet powerful) firewall that allows absolutely nothing in from the outside world unless it is part of an established connection. It also assumes the internal network is completely trusted and allows unfettered access to the server and outside world from the internal network. This is the default setting for pretty much every NAT device ever. At this point you are effectively finished. You can just leave your server as a simple router with no other rules at the point. It is very secure and will work fine for most purposes. If, however, you want to run publicly accessible servers, then we need to add some additional rules. If the server youre trying to get to is on this very same Linux box, then its just an INPUT rule in the filter. For example, if you want to be able to SSH (Putty) into this Linux box from the outside world, that is INPUT rule, or exception to the firewall. That wouldnt involve PREROUTING or FORWARD at all. Lets setup a port 22 Firewall Exception so you can SSH in from the outside world.

543

Navigate back to the Linux Firewall module, make sure youre in the FILTER screen, and make a new rule underneath INPUT

544

You should see something like this, make the following changes

And then click Create These are the easiest exceptions to make, as your explicitly allowing information coming into eth_bad (eth1) to not be dropped by the firewall. Thats it for port 22, go ahead and make anymore you might need. Dont forget to make good use of the Clone Rule button inside each rule, it can make things much easier for you. Just Clone it, and change the port, and youre done.

545

You should see something like this

Make anymore that you need, for example, if you clicked on the port 22 exception, and cloned it, then change the port to 10000, you would then have a port 10000 exception for Webmin. And just keep cloning and changing the info until you have all that you need.

546

Then hit Apply Configuration You should limit the number of direct INPUT rules you allow, as these open up ways into your router, whereas your router should be as invisible as possible. This is still secure, SSH (Putty) is pretty amazing stuff, and Webmin is https, just try to limit the number of holes you allow directly into the router like this. A better way to get into your network and manage systems is to PortForward to another computer already inside your network, and execute commands from there. For example, your Windows PC will accept Remote Desktop connections on port 3389. So if you created a PortForwarding rule, the router can use the PREROUTING and FORWARD feature to redirect your connection to a computer inside your network, and once inside, youre totally trusted by the Firewall, all without exposing the router itself. Windows Remote Desktop also offers some high level encryption options, so-far we havent made any Firewall exceptions that arent highly encrypted, and thats a beautiful thing. Chance are, you will have more than one computer inside your network, that you want to access ports 3389 and port 22 on. Thats not a problem, as you can forward an external number, to an internal number. For example, we can make PREROUTING and FORWARD rules that says

Anything coming in on port 25505, PortForward that to computer 192.168.2.5:3389 Anything coming in on port 25506, PortForward that to computer 192.168.2.6:3389 Anything coming in on port 25507, PortForward that to computer 192.168.2.7:3389 Anything coming in on port 25522, PortForward that to computer 192.168.2.8:22

Specifying 25522 for that last one This leaves port 22 available for the INPUT rule we made earlier Anything coming in on port 22, allow directly into the router

547

This way you can have a bunch of computers, using all the same ports internally, and just specify some meaningless high-port at the end of the hostname or Public IP address. Then tell the router what computer that is really supposed to go too. These require a little bit more work on your part, as you have to specify them in two parts of the Linux Firewall module. One as a PREROUTING rule, and one as a FORWARD rule. But one you have one set done, you can use that Clone rule feature to complete the rest. Navigate back to the Linux Firewall Module and this time make sure you are in the Network Address Translation table

Make sure you are in the PREROUTING section, and Click on Add Rule

548

You should see something like this, make the following changes

Then click on Create

549

You should see something like this

550

Thats one part of two, for the next part of that, Navigate to the Packet Filtering table. You should see something like this

Make sure youre in the FORWARD section, and then click Add Rule

551

You should see something like this, make the following changes

Then click the Create button

552

You should be returned to the main Firewall screen, where you can hit Apply Configuration

What you just did was allow a PortForward to happen from the outside world, to a computer behind your firewall. And as long as you have encryption enabled in your remote desktop clients, you dont have too much you have to worry about.

Now external remote desktop requests like this

Will be forwarded to computer 192.168.2.5:3389 Inside your network

That first rule was kind of a lot of work to create. But now you can use the Clone rule button, inside of each rule, to quickly and easily make more PortForwards.

553

Just dont forget to do it in both places when PortForwarding NAT \ POSTROUTING And FILTER \ FORWARD

As you can see from all those static numbers your entering, it would be a good idea if the computers inside your network had static IP address or DHCP reservations.

554

Setting up a DHCP reservation is the best choice. Navigate back to the DHCP Server module, and we will setup a DHCP reservation for a computer inside the network.

Make sure youre underneath the Hosts and Host Groups field, and click on Add a new host

555

You should see something like this, make the following changes * Hardware address would be the MAC address of the computer inside your network, that you want to always have IP address 192.168.2.5

Click Save

556

You should see something like this

557

Hit Apply Changes And restart the computer inside your network with that MAC address, and it will forever get the IP address of 192.168.2.5

Do this for any computer you have a firewall exception for. Thats about it for the firewall exceptions and PortForwarding. You shouldnt have any problems with you Virtual Machines, as they run bridged off of eth_safe. But if you do, just add a couple rules for your VM nics, similar for what you did for lo and eth_safe The VM nics are usually called something like VMnet1 and VMnet8, and should be available from the same drop down menus as everything else you just did. But I havent had any issues so far in the bridged VM mode. If you want to remotely access the VMware server from the outside world, you need to allow ports 8333 and 902. If the VMware server and the router are the same computer, this is just a simple INPUT rule, similar to the one you made for port 22. If the VMware server is on a different computer inside your LAN, and not on the router itself, you would need to setup four rules. Two PREROUTING rules (8333 and 902) and two FORWARD rule (8333 and 902) As far as security goes, thats a little more access than I want from the outside world, I dont want just anybody to be able to get to my VMware server webpage, so if youre going to do this, you should take advantage of the source address option.

Source address is supported in all of the firewall rules. By limiting a source address, you make something available to the outside world, but only if you have the right from IP address.

558

See below I am allowing connections on port 8333 But only if the computer im at has IP address 204.69.xxx.xxx

Only thing to be aware of is its got to be your public address. If youre at work or on another network, your local IP address is probably not your Public IP address. For example, when Im at work, my computer gets a 10.10.xxx.xxx IP address. But my Public IP address is 204.69.xxx.xxx

So in my Firewall exception I would use the public address. And then port 8333 is only accessible from my work network. Granted its anybody at my work place, as we all have the same public IP address, but youve still eliminated most of the possible connection from the rest of the world.

559

If you dont know what your Public IP is. You can go to http://whatismyip.com/ And a webpage will pop up and tell you. And as far as the port 902. thats for the VMware player. You should be doing most of your stuff through remote desktop, and not the VMware player. But sometimes you will need the player, so you will need port 902 open as well. Earlier we made a port 22 exception, as a PortForward from 25522. you probably wont need to do too many of these, not to SSH (Putty) connection anyway. You can from within Putty, connect to as many other SSH computers as you like. Meaning if you SSH into your router, and youre in a Putty window. You can simply type ssh wood@192.168.2.5 Where wood is the username you want to use And from within your current SSH connection to your router, it will connect you to computer 192.168.2.5 inside your private network, without a need to PortForward anything. And when you exit or logout of that session, youre returned back to your SSH screen on your router. Pretty cool stuff.

Youre almost done with the router setup.

560

If you were using a DDNS update client on your old router, to keep your hostname current, like this one, from Linksys

Youre going to have to install the Linux equivalent (ddclient) So that your hostname stays up to date

561

Launch a Putty session or navigate to the SSH2 module and Type the following command apt-get update

And then press the enter key on your keyboard

After that finishes

Type the following command

apt-get install ddclient

562

And then press the enter key on your keyboard You should see something like this

Press the Enter key on your keyboard

563

You should see something like this, answer the on screen questions

You should see something like this, answer the on screen questions *This is an example, enter your own information, and do not copy mine

564

Pay close attention to this next question

565

Make sure you enter eth_bad here, because you want it to update from your public IP interface, not your private interface. So if you have been following this how-to word for word, then you would enter eth1 in the box above.

Press the Enter key on your keyboard

You should then be returned to the command prompt

566

You can type exit and close Putty Youre not done with ddclient yet, there is three more configs you have to do.

Using the File Manager module, edit the file /etc/ddclient.conf

567

You should see something like this Add the following two lines daemon=300 ssl=yes

Click the

Save and Close button

568

Using the File Manager module, edit the file /etc/default/ddclient

Make sure Make sure Make sure

run_ipup is set to false run_daemon is set to true daemon_interval is set to the same interval you set in /etc/ddclient.conf

Save and Close

Restart your Linux box

569

Navigate to the Command Shell module, and execute the following command /etc/init.d/ddclient status

As long as you see

ddclient is running

You know its launching at startup, and checking for changes Next execute the following command /etc/init.d/ddclient restart

And as long as you dont see any errors, you should be all set. Dont worry that its checking every 300 seconds, I know that sounds too aggressive. But its actually comparing your IP address to a local file, so youre not beating up the DYNDNS website like it sounds.

Your also sending that username and password over ssl encryption. So you might even be better off then you were with your old router

Thats about it for ddclient

570

Next we are going to setup a local DNS server. This is not only a local DNS how-to, but its also a local DDNS how-to, meaning Dynamic DNS. It will not only control the naming on your local network, but will also allow your DHCP clients to build, update, and maintain the list of their own computer names \ DNS entries. I wouldnt recommend setting this up on a small network. Its a pain in the butt the first time you do it, and its very picky if you start making changes. Im not saying it isnt stable, its rock solid stable, Im just saying its easy to break if you want to tweak it later on. On small networks I find myself just referring to everything by their IP addresses, so make sure this is something you want to do before you continue. OK, lets get started First stop the bind service. This service has to be stopped every time you want to make changes to it, its very picky like that. You can either type /etc/init.d/bind9 stop Or you can navigate to the Bootup and Shutdown module, and stop it from there.

571

If you have given your router eth_safe (eth0) a static IP (which you already did if you have been following this how-to) we need to double check and make sure your computer name still matches the static IP address change in the following files /etc/hosts

Where it says 127.0.0.1 add localhost.localdomain Where it says 127.0.1.1, change it to your static IP address and servers hostname

Click Save and Close

572

Then edit file /etc/hostname

And make sure your servers hostname is in there Click Save and Close

573

Then edit file /etc/resolv.conf

Write down all the info inside that file, and then delete everything inside this file. Dont just #comment it out, actually highlight and delete the contents of the file. Just delete the contents, (all the words inside) dont delete the actual file. Although that info is important, we are going to use our DHCP server settings to overwrite this file at startup, but it just appends to the file, and doesnt always overwrite, so we have to make sure its empty first.

Click Save and Close

574

Then edit file /etc/dhcp3/dhcpd.conf Underneath Change it to DNS Update Styles ddns-update-style interim;

Remove the ; comment in front of word authoritative This will make your Linux box the authoritative DHCP server for this network. And under the part that reads subnet 192.168.2.0 netmask 255.255.255.0 { Paste in the following ddns-domainname "diy.lan."; allow client-updates; option domain-name "diy.lan."; max-lease-time 999999; default-lease-time 888888; range 192.168.2.50 192.168.2.99; ddns-rev-domainname "2.168.192.in-addr.arpa."; option broadcast-address 192.168.2.255; option subnet-mask 255.255.255.0; option routers 192.168.2.1; ddns-updates on; option domain-name-servers 192.168.2.1; }

575

You should have something like this

576

Some of that should look a little weird to you Like this. ddns-rev-domainname "2.168.192.in-addr.arpa.";

Thats for reverse DNS

You may have to tweak it to fit your needs.

If you were on a 10.10.50.xxx network, you would use ddns-rev-domainname "50.10.10.in-addr.arpa.";

Or

577

If you were on a 192.168.0.xxx, you would use

ddns-rev-domainname "0.168.192.in-addr.arpa.";

Or If you were on a 192.168.1.xxx, you would use

ddns-rev-domainname "1.168.192.in-addr.arpa.";

Its just written backwards, and in place of the last octet, you just put rev instead

Also make sure you adjust these to fit your scheme option domain-name-servers 192.168.2.1; ddns-domainname "diy.lan.";

That would be the IP address of eth_safe (eth0) on your router And then the local domain name that you selected on page 9

Once you have all that entered correctly, press Save and Close

Youre not done with that file yet, because we have to make a secret key for DNS and DHCP to share with each other, so that only your DHCP clients are able to update the server.

578

To do this, open up a Putty window or SSH2 module, and run the following commands cd /options

Then press the enter key on your keyboard Then run the following command

dnssec-keygen -a hmac-md5 -b 128 -n USER dhcpupdate

579

This will create a 128bit HMAC-MD5 key file called kdhcpupdateXXXX.key In the /options folder

Open the File Manger module, and navigate to the /options folder Edit the Kdhcpupdate file that ends with .key

580

You should see something like this

That last solid string of numbers is your key Do not share this key with anyone, consider this very confidential

Highlight the key, and copy it

581

Then navigate back to editing the file /etc/dhcp3/dhcpd.conf

582

And under the part that says # Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7;

Paste in the following

key dhcpupdate { algorithm hmac-md5; secret Oh+VKKP7uemLxrWg9lwwwQ==; } zone diy.lan. { primary 127.0.0.1; key dhcpupdate; } zone 2.168.192.in-addr.arpa. { primary 127.0.0.1; key dhcpupdate; }

583

You should see something like this

Of course you need to use your own key here, not the example key above Again keep that key confidential

Leave the IP addresses alone, they should be 127.0.0.1 But tweak the zone name to be the same as the domain name you picked And tweak the reverse DNS address to fit your scheme Then click Save and Close

584

Next edit the file

/etc/dhcp3/dhclient.conf

And add the following two lines

supersede domain-name "diy.lan"; supersede domain-name-servers 127.0.0.1;

You should see something like this

Then click Save and Close This is the file that is going to append to /etc/resolv.conf at startup, So youre all set for both of these files now

585

Next navigate to the /var/lib/ folder And use the File Manager module to create a new folder called bind

With 0775 permission, and both owner and group as bind

586

If the directory is already there, thats cool too. Just change the permissions, groups, and owners to match

Now go inside that directory and create the following two files

587

diy.lan.db 2.168.192.in-addr.arpa

You should see something like this

588

And something like this

589

Save both

Set both of the files to the following permissions, And bind as both the user and group

590

These are some seriously wack file permissions, but bind gets a little crazy sometimes, and I find it works best this way

Next, use the File Manger module to edit the file

/var/lib/bind/diy.lan.db

And paste in the following

$ORIGIN . $TTL 86400 diy.lan

; 1 day IN SOA deb32server1.diy.lan. admin.diy.lan. ( 2009122871 ; serial 28800 ; refresh (8 hours) 7200 ; retry (2 hours) 604800 ; expire (1 week) 86400 ; minimum (1 day) ) NS deb32server1.diy.lan. MX 10 deb32server1.diy.lan.

$ORIGIN diy.lan. deb32server1 A 192.168.2.1 printer1 A 192.168.2.74 sanx1 A 192.168.2.5 ; is bind stopped ; did you update the serial number ; sometimes root should be the owner and bind should be the group ; hit enter here, must have one blank line, and only one

591

You should see something like this

It still wants you to have that

MX 10 YourHostname.diy.lan

entry even if its not really a mail server.

Add all computers here that have a static IP address, the rest will populate themselves when they get a DHCP lease. This program is so very picky about the following Spacing, the file must end with one blank line, just one Dont have bind running when youre editing these files And changing the serial number, +1 every time you make a change (its the date) Sometimes it wants root to be the file or folder owner, and bind to be the group.

592

Next, use the File Manger module to edit the file

/var/lib/bind/2.168.192.in-addr.arpa

And paste in the following

$ORIGIN . $TTL 86400 ; 1 day 2.168.192.in-addr.arpa

IN SOA deb32server1.diy.lan. admin.diy.lan. ( 2009122871 ; serial 28800 ; refresh (8 hours) 7200 ; retry (2 hours) 604800 ; expire (1 week) 86400 ; minimum (1 day) ) NS deb32server1.diy.lan. $ORIGIN 2.168.192.in-addr.arpa. 1 PTR deb32server1.diy.lan. 5 PTR sanx1.diy.lan. 74 PTR printer1.diy.lan. ; is bind stopped ; did you update the serial number ; sometimes root should be the owner and bind should be the group ; hit enter here, must have one blank line, and only one

593

You should see something like this

This program is so very picky about the following

Spacing, the file must end with one blank line, just one Dont have bind running when youre editing these files And changing the serial number, +1 every time you make a change (its the date) Sometimes it wants root to be the file or folder owner, and bind to be the group.

594

Next, using the File Manager module edit the file

/etc/bind/named.conf.local

Paste in the following info

key dhcpupdate { algorithm hmac-md5; secret Oh+VKKP7uemLxrWg9lwwwQ==; };

zone "diy.lan" IN { type master; file "/var/lib/bind/diy.lan.db"; allow-update { key dhcpupdate; }; }; zone "2.168.192.in-addr.arpa" { type master; file "/var/lib/bind/2.168.192.in-addr.arpa"; allow-update { key dhcpupdate; }; };

595

You should see something like this

Of course you need to put your own key in there, and tweak the IP scheme if different Click Save and Close

596

Next, using the File Manager module edit the file

/etc/bind/named.conf.options

Paste in the following info *But dont use the same DNS servers or forwarders as I did, make sure obtain that info from your ISP.

forwarders { 216.146.35.35; 216.146.36.36; 71.9.127.107; }; auth-nxdomain no; # conform to RFC1035

listen-on { 192.168.2.1; # listen on local interface only 127.0.0.1; # Make sure machine can get to itself }; listen-on-v6 { none; }; };

597

You should see something like this

Do not use the same forwarders I did, make sure obtain that info from your ISP. Those are your Public DNS servers In the above example, Im using two DNS servers from dyndns.org (safe surfer) and then one from my ISP Click Save and Close

598

Thats about it for dynamically updating local DNS You should be able to reboot your Linux box, and then reboot your Windows PC, and the process should be underway. There are several ways to test to make sure its working You can try pinging computers by their name, and they should reply. You should notice that your ping results are automatically appending the domain name for you. Meaning if you ping the computer name Sanx1 You should see its actually ping the entire name Sanx1.diy.lan. Without you actually typing all of that.

This is of course assuming your PC is set to DHCP and not Static.

599

You should also be able to run the following command from your Linux box And see all kinds of good info host l diy.lan

600

And the reverse, on your Windows PCs, you should be able to do ping a IPaddress And the ping should return back with the computer name

If you were following how-to very closely, you were probably expecting that name to come back as BlueDell. Your right, Im just on a different network today. Another cool feature is you can edit the files /var/lib/bind/diy.lan.db /var/lib/bind/2.168.192.in-addr.arpa

And add multiple names for the same computer. You could have computer 192.168.2.5 respond to as many different names as you want. You could trick your roommates into thinking they each had their own personal server, by giving the same server multiple names like Server4room1 Server4room2 Server4room3, Even though they are actually all the same computer.

601

There are more practical uses for that feature, but you can certainly have fun with it too. Well thats about it for DNS Just remember when editing those DNS files, stop the bind service first. And always up the serial number plus one when editing, and always end the file with a blank line. There is always awesome trouble-shooting info in syslog, for whatever problem you might be having. If you are seeing permission denied errors, it probably wants root to be the owner of the file, and bind to be the group. (file permissions) A pretty common problem is the journals will get out of sync. All you have to do is delete them and reboot. They are in the /var/lib/bind/ folder (.jnl) and are create by the bind service.

Syslog is your friend

602

And check your local email for notices of problems and statuses

Since we added another network card, we need to make sure Samba is for sure listening on your private network card. We have done a lot of steps already to prevent this, but you cant be too careful here.

603

Navigate back to the Samba Windows File Sharing module

Click on Edit Config File

604

You should see something like this Make sure both of those two lines are un-commented (meaning remove the leading # or ;) And change the lines to this interfaces = 127.0.0/8 eth0 bind interfaces only = yes

Where eth0 is eth_safe, Save the changes

And restart the Samba service

Here is how you can check to make sure its working the way it is supposed to.

605

Navigate to the Command Shell module and execute the following command netstat -tapn | grep smbd

Your concern is with the numbers on the left Those represent the interfaces Samba is listening on

606

If you see anything other than 192.168.2.xxx And 127.0.0.1

On the left, then there is something wrong, disconnect your internet cable and figure it out. If you have been following this how-to closely, you probably expected that print screen above to show IP 192.168.2.1. Your right, im just on a different computer today.

This command would make a good Custom Command button to, as its hard to remember netstat -tapn | grep smbd

607

That brings us to the end of the how-to, I hope you enjoyed it. Dont forget to visit my Website, http://woodel.com and click on the blog link(s)

Now you can stop logging in as username root, and start using username wood. Or whatever name you picked on page 1.

You can run an

apt-get update

and finally an

apt-get upgrade

That will ensure you have the latest patches and upgrades for the Debian OS.

Thanks ! Enjoy !!

-Kevin Elwood

KevinTheComputerGuy

You can find my email address, more how-tos, and blog link(s) on my homepage

http://woodel.com http://woodel.com/domore

If you would like to do even more with your server, you can find additional info here

* This how-to is try at your own risk, with absolutely no warranty, no promises, and no guarantees. I cannot be held accountable for claims, statements, or damages of any kind. This how-to is for personal use only, and I reserve all rights.

608

Вам также может понравиться