Archive

Archive for January 6, 2011

Ubuntu Server 10.04 LTS – DHCP Server

January 6, 2011 Leave a comment
  • So you’ve set up a network with your ubuntu server box and shared your internet or something…

You’re not satisfied to enter a static ip on every machine on your network? Well here’s what you need to do:

You need to install a DHCP server so every time a new network device is connected to your local network it automatically gets an IP address.

  • Here’s how:

sudo apt-get install dhcp3-server
vi /etc/dhcp3/dhcpd.conf

  • Edit your /etc/dhcpd3/dhcpd.conf file to match your taste.
  • Here’s my config (just the lines that are not commented and if my local ip is 192.168.17.1 and network name gryphon)

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages (‘none’, since DHCP v2 didn’t
# have support for DDNS.)
ddns-update-style none;

# option definitions common to all supported networks…
option domain-name “vityobug.com”;
option domain-name-servers 192.168.17.1;

default-lease-time 600;
max-lease-time 7200;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# 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;

# A slightly different configuration for an internal subnet.
subnet 192.168.17.0 netmask 255.255.255.0 {
range 192.168.17.10 192.168.17.30;
#  option domain-name-servers ns1.internal.example.org;
option domain-name “gryphon.vityobug.com”;
option routers 192.168.17.1;
option broadcast-address 192.168.17.255;
default-lease-time 600;
max-lease-time 7200;

  • Edit the next file to match your LOCAL network interface (eth0 in the example)

vi /etc/default/dhcp3-server

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
#       Separate multiple interfaces with spaces, e.g. “eth0 eth1″.
INTERFACES=”eth0″

That’s it. Just restart the machine if needed.

Categories: Linux HOWTOs

Ubuntu Server 10.04 LTS – NAT Router

January 6, 2011 Leave a comment

How to share your internet connection with NAT to all or some of the computers on the same LAN.
In other words:  “I want to make my old pc a hardware firewall and/or router which works flawlessly (depending on the hardware ;))
And maybe share some multimedia on the network later. How do i do that?”
note:  uncomment means to remove the # sign in the beginning of the line
Let’s say /dev/eth1 is the interface used for WAN and /dev/eth0 is the LAN interface of your machine.

  • So we’ll edit/add some entries to iptables:

vi /etc/sysctl.conf

  • uncomment the following lines

net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1

  • Next

vi /etc/rc.local

Add the following lines before exit0

/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables –table nat -A POSTROUTING -0 eth1 -j MASQUERADE

Categories: Linux HOWTOs

Ubuntu Server 10.04 LTS: Setup Networking

January 6, 2011 Leave a comment

How to set up the networking in ubuntu server 10.04 LTS, may work on other debian based distributions too:
We’re going to use vi or vim to edit the /etc/network/interfaces

  • First make sure which of your interfaces is used for internet and which for local networking. Check what type and what is your ip (DHCP or STATIC).

Let’s say /dev/eth1 is the interface used for WAN and /dev/eth0 is the LAN interface of your machine.

  • Now if you have static IP edit your /etc/network/interfaces

sudo vi /etc/network/intrerfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth1
iface eth1 inet static
address 17.252.169.74
netmask 255.255.255.0
network 17.252.169.0
broadcast 17.252.169.255
gateway 17.252.169.1
dns-nameservers 80.80.128.161 80.80.128.193

# The local network interface
auto eth0
iface eth0 inet static
address 192.168.12.1
netmask 255.255.255.0
network 192.168.12.0
broadcast 192.168.12.255

Now iface eth1 inet static can be changed to dhcp if you have a dynamic ip address and delete the other lines with options.
address is your ip address
netmask is your network mask (usualy 255.255.255.0 or 255.255.0.0)
network is your network address (just like your ip, but the last part is 0)
broadcast is your network’s broadcast address (just like your ip, but usualy ending on 255)
dns-nameservers are the DNS servers you’re using, you can enter up to 3 separated by space
gateway is the address of your internet gateway

  • Next add the following line in the /etc/resolv.conf file
    (change the numbers to your DNS addresses)

name server 80.80.128.161 80.80.128.193

  • Restart the networking (or the system if needed):

sudo /etc/networking restart

  • Next Step Is Optional:
    • Test your connectivity by pinging some working ip address

ping 4.2.2.2

or

ping 8.8.8.8

or

ping google.com

If you have replies your network is working.

Categories: Linux HOWTOs

Debian/Ubuntu System Update

January 6, 2011 Leave a comment

1st thing you have to do after you’ve installed the system and set up the networking is to install the most important updates:

sudo apt-get install update
sudo apt-get install upgrade

#type “yes” or “y” when asked
#restart if needed

Categories: Linux HOWTOs
Follow

Get every new post delivered to your Inbox.