Difference between revisions of "DHCP and network configuration"

Line 1: Line 1:
 +
[[Category:Linux]]
 
Hostname and network configuration + DHCP server
 
Hostname and network configuration + DHCP server
  

Revision as of 16:58, 10 June 2014

Hostname and network configuration + DHCP server


Network configuration

Get the current status

Get current IP @ and connection details

Display connection settings

ifconfig

if you have many network card you can filter using interface name (eth0 // eth1 // wlan0).


To get more details

ifconfig -a


Discover your gateway

route

Default gateway is named "default"


Setup DHCP / static IP @

By default the system is using DHCP.

Following procedure will set a fix IP.


Edit configuration file:

vim /etc/network/interfaces


Adjust the file like this:

# The loopback network interface (127.0.0.1)
auto lo
iface lo inet loopback

# The primary network interface [DHCP]
#allow-hotplug eth0
#auto eth0
#iface eth0 inet dhcp


# The primary network interface [static IP]
auto eth0
iface eth0 inet static
        address 192.168.0.100				# mandatory
        netmask 255.255.255.0				# mandatory
        gateway 192.168.0.1				# mandatory
        network 192.168.0.0				
        broadcast 192.168.0.255
        dns-nameservers 8.8.8.8 8.8.4.4                 # Google DNS


Then, restart configuration

/etc/init.d/networking restart


Wifi

WEP

Edit:

vim /etc/network/interfaces


Add:

auto wlan0
iface wlan0 inet dhcp
  wireless-essid NUMERICABLE-F164
  wireless-key f4c1dc12023b916d309c2561cb
  wireless-channel 11
  wireless-mode managed


WPA

Required software

You must install wpa supplicant

apt-get install wpasupplicant


Restrict the permissions of interfaces configuration to prevent code disclosure:

chmod 0600 /etc/network/interfaces


Configuration

Edit

vim /etc/network/interfaces


Adjust like that:

auto wlan0
iface wlan0 inet dhcp 
    wpa-ssid ssid
    wpa-psk password


Take changes into account

Then, you have to start your wireless interface:

ifup wlan0


Restart configuration

/etc/init.d/networking restart


Hostname

Get hostname

Just run the following command:

hostname


Setup hostname

Hosts files

Edit configuration file

vim /etc/hosts


You should have something like that (for fixed IP):

127.0.0.1	localhost
127.0.1.1	myServerName.myDomain  myServerName

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


Hostname

echo myServerName.domain.com > /etc/hostname


Take changes into account

Reboot server

shutdown -r now


Check result

hostname
hostname -f

You should have 2 similar results: server1.example.com


DHCP server

DHCP server