Archive

Posts Tagged ‘Linux Internet Connection Sharing’

Creating a server Linux Mint

July 19th, 2011 No comments


Linux Mint Server

 

This tutorial will this base and user not starting because it contains only useful information but if you want a full tutorial on a step or several steps of this tutorial and is not available on our database, we simply advise on the forum.

Otherwise look at the other tutorials you will probably find the answer and if it is not the case the forum is there for.

 

>>> Why Linux Mint as a server?

Indeed there are plenty of distribution server?

Here are the pros and cons:

To:

  • To compare many distributions like Ubuntu for example, it is more stable because the Mint community is very strong on update
  • All the benefits of Mint know that … It is 2010 and the directors also like to use a graphical interface, play videos or listen to MP3, etc …

Cons:

  • Must have a powerful machine (because the GUI uses a lot of resource)
    Mint is designated primarily for basic experience “out-of-the-box” for desktop / laptop
  • Finally, as to installation and configuration of a server, it takes patience not only with a server Mint (although personally it is less capricious than I had to install such a server versus FreeBSD)

 

>>> Installation (finally!)

Installing Linux Mint on your server

To make it less cumbersome we will take the Gnome version of Mint. You choose if it’s the normal version (32 bit) or 64-bit applies to you.

So for this tutorial I chose Linux Mint 8 64-bit.
Download this version on the official website -> http://www.linuxmint.com/edition.php?id=46

Is a blow, burn the ISO to a DVD. Remember to check the integrity of the DVD before rebooting on it.

So start the DVD and choose the function Start Mint 8 Live CD.

Once Mint click the Install icon.

  • For partitioning (such as a 1TB HDD)
  • 80 GB for / (system files)
  • 12 GB for the swap (if you have 1GB of RAM, set as it always x2 2GB memory for your swap)
  • 100GB for / home (for the base directory users)

The rest we create two logical partitions:

  • 200 GB / important (Score or important files are stored and a backup is done regularly)
  • 608 GB / home2 (Score unimportant or files (mp3, etc. ..) are stored and no backup is done)


I suggest you do your partitionsen ext3 but you can use other file systems.

* Important note for users of SATA and PATA *

If, as in rare cases you use a SATA and PATA same time, Linux will not boot after installation due to a bug in Grub.

So in the last step of the installation click the Advanced … and change to the partition where the installation of Linux is installed hd0 change the value (eg hd1).

Grub will crash and says he can not find the installed system after the restart. You must edit the startup parameters and after several trial and error you should find the correct partition to be.

For more details, or search on Google http://linux.knightnet.org.uk/2008/01/more-on-grub-bug-with-mixed-pata-and.html grub bug with mixed PATA and SATA.

After installation you have a functional Linux Mint on your server. :)
>>> Network Configuration

This part is a little more difficult but necessary because it must be done via the console directly from the server (you will see why shortly).

Open a console and type: sudo echo 1> /proc/sys/net/ipv4/ip_forward

However it is temporary so it must be enabled to be activated at each restart routing.

Console open the file /etc/sysctl.conf:nano/etc/sysctl.conf

Find the line net.ipv4.ip_forward=1 and remove the pound sign # in front and save the file.

Later, unfortunately, we must remove the NetworkManager works well. However, the NetworkManager prevents the DHCP server to start at startup. See http://ubuntuforums.org/archive/index.php/t-1094344.html for details.



*** ATTENTION, from this point you will lose your Internet connection / network then read the information requested below before and it should be done directly on the machine.


It must be uninstalled the Network Manager or via the Package Manager or in console: sudo apt-get remove network-manager

We will configure the network interface manually.

You must console edit the file /etc/network/interfaces: sudo nano /etc/network/interfaces

You should normally find this file:

linux mint server

Therefore change with the right information will give something like this:

Linux Mint server

A stroke is save the file and exit. Note that I’m on cable modem and a router configured for DHCP.

Subsequently we must modify the /etc/resolv.conf sudo nano /etc/resolv.conf

linux mint server

You need to change the correct information from your ISP. (Provider Inernet)

linux mint server

If your server is hosted elsewhere and supports a different area and NameServer ask your host configuration to be the same for the interface.

If your ISP to NameServer with names such ns1.videotron.ca ns2.videotron.ca and IP instead of replace the IP in this configuration.

To finish this part that remains is to restart the networking.
In console:

sudo /etc/init.d/networking restart

If everything is correct you will have access to the network again as well as internet.

* It may, however, that you should restart or do with your ISP or web host if it does not work in case of configuration errors.

 


>>> Optional – Install Remote Desktop

For X reason, you want to connect to remote desktop to your server?

Simply follow the same steps as the tutorial for NX/FreeNX available on our website -> HERE
>>> Installing Webmin

I believe this step is important because it allows you to install a Configuration Manager “graphic” in web interface.

There are tons of configurations to more easily (eg firewall, user access, etc. …).

In console:

sudo apt-get install webmin

Read the configurations and even if Apache is not installed it will install what it needs to automatically.

Normally it is accessed through a browser bookmark with: http://votredomain.com:10000 default.

If it’s local you can use the server name instead of ip domain or local,”up to you.”

Example Webmin via your browser:

linux mint server

You see the resources are not necessarily that much vs a FreeBSD server, Ubuntu, CentOS, etc … :)

 

>>> List server application to install (suggestion)

Here are some tips to install the package manager or console via sudo apt-get install software

  • Apache and PHP
  • Mysql and PhpMyAdmin
  • PostgresSQL
  • SpamAssassin
  • Team Speak Server
  • FTP Server
  • SSH Server (should already be installed from the beginning)
  • TCL / TK
  • Phpsysinfo
  • etc …



And the list goes on and many of these programs are more or less easily configured via Webmin.

Hope this helped you get started in the server world feel free to ask questions on the forum.

Linux: Internet Connection Sharing

July 5th, 2011 No comments

Despite being a basic task for those who manage Linux networks, the Internet Connection Sharing can be an important issue for those who are beginners and want to use Linux as a gateway from your LAN.

 

The first thing we need to understand is the NAT or Network Address Translation. Also called masquerading (masking), is the process of transforming or translating IP addresses from one network to another, in the case of Internet sharing, NAT translates between IP network where the Internet IP address, allowing machines your local network to access the Internet. Thus, a single Internet IP address can be shared with all of its IP network.By using a gateway each data packet is translated by NAT and is recognized as coming from the Internet IP, ie, independent of the computer’s IP network, all packets go out to the Internet as the Internet IP. When the packet returns, the NAT is the translation back to direct you to the source computer.
Sharing the Internet connection

Sharing the Internet connection

Sharing the Internet connection

Before we start to configure our Internet sharing gateway, we check the environment to be used. For the settings to run smoothly you will need an environment like this:

  • A connection (which is working) with an Internet service provider;
  • A machine with Debian or Ubuntu installed;
  • Two network cards installed, one of which should already be with the settings of your Internet service provider;
  • A hub or switch to distribute Internet access across multiple computers.

Below is a simple suggestion of network topology:

LAN: a simple network topology

LAN: a simple network topology

Flushing the routing of packets

The first configuration to do is release the IP packet forwarding. For this we have two alternatives. The first is to change the file ip_forward entering 1 in its content and the second is by changing the sysctl.conf file.

Inserting a file ip_forward :

# echo 1> /proc/sys/net/ipv4/ip_forward

Change the sysctl.conf file:

# vi/etc/sysctl.conf

Remove the # sign from the line:

net.ipv4.ip_forward = 1

Save the file with “:wq”. For more information about the sysctl.conf file, simply enter the command:

# man sysctl.conf

Configuring IP Gateway

Let’s follow the example of topology up and admit that we have two network cards and will use the card named eth0 for Internet access (WAN) and eth1 card to access the local network (LAN).

Tip: To know more information about our network cards, we can use the command:

# cat/var/log/dmesg | grep eth

This command should return the network chipset and the appointment set by Linux.

After properly verify the network cards and we link the cables that were “made” using the standard CAT5e, we then manually configure the network information. Since we are using Debian Lenny (Debian 5.0) or Ubuntu Jaunty (Ubuntu 9.04), then the settings are in /etc/network/interfaces. Let’s edit it:

# vi/etc/network/interfaces

The file should look like the example below:

it self
it iface inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

allow-hotplug eth1
iface eth1 inet static
address 192.168.0.1
netmask 255.255.255.0

Note that not inform the gateway address on the card that will be responsible for receiving all traffic on the local network (LAN). This is done because this machine is the gateway of the LAN.

In Ubuntu, the default setting does not mention allow-hotplug eth0 auto eth0 and yes.

If your Internet connection is using fixed IP, then the eth0 settings may be similar to this:

allow-hotplug eth0
iface eth0 inet static
address 200.174.144.20
netmask 255,255,255,240
broadcast 200.174.144.31
gateway 200.174.144.17

 

Using IPTables to share the Internet connection

The IPTables is the software responsible for configuring packet filtering rules. To use IPTables to share Internet access, before we need to tell the kernel modules to be loaded.

# modprobe ip_tables
# modprobe iptable_nat

The modprobe command is responsible for, among other tasks, add or remove modules in the Linux Kernel. The modules ip_tables iptables_nat and are meant to add to the kernel the ability to filter data packets and make the “translation” of IP addresses from one network to another.

Now let’s clear any pre-existing rule in iptables, so we can ensure the correct operation of NAT and packet forwarding:

# iptables-F INPUT
# iptables-F OUTPUT
# iptables-F FORWARD
# iptables-t nat-F
# iptables-t mangle-F

The clean lines above information input, output, forwarding, “translation” and change packages.

Finally, we will enable packet forwarding via iptables:

# iptables-t nat-A POSTROUTING-o eth0-j MASQUERADE

Understanding the parameters passed to the IPTables on the line above:

-T nat – uses the table of “translation” of IP addresses;
-A POSTROUTING – the rule adds to output packets;
-O eth0 – specifies that the outgoing interface used is eth0;
-J MASQUERADE – says that the focus (target) rule is the IP masquerading.

 

Testing the Internet connection

To test if the settings worked, just use the ping from a client machine on the network. For example:

# ping www.google.com.br

 

Monitoring the packet transfer

Monitoring interfaces iftop

Monitoring interfaces iftop

Iftop is a great utility for monitoring the transfer of packets between your LAN and the Internet. With it we can see in real time, which sites are accessed and measure the throughput. To install iftop in Debian Lenny (Debian 5.0) or Ubuntu Jaunty (Ubuntu 9.04) just run the command:

# apt-get install iftop

To use it you simply specify the interface (card) you want to monitor network. In our example topology of the board named eth0 is responsible for Internet traffic. To monitor it will use the command:

# iftop-i eth0

If you have created a script with the above settings, then you can add it automatically at system startup with the command:

# update-rc.d defaults

Now, you can try your internet connection.