Difference between revisions of "DHCP and network configuration"

(Created page with "Hostname and network configuration =Get the current status= ==Get connection details== Display connection settings <syntaxhighlight lang="bash"> ifconfig </syntaxhighlig...")
 
Line 2: Line 2:
  
  
=Get the current status=
+
=Network configuration=
  
  
==Get connection details==
+
==Get the current status==
 +
 
 +
 
 +
===Get current IP @ and connection details===
  
 
Display connection settings
 
Display connection settings
Line 23: Line 26:
  
  
==Discover your gateway==
+
===Discover your gateway===
 
 
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 34: Line 36:
  
  
=Setup DHCP / static IP @=
+
==Setup DHCP / static IP @==
  
 
By default the system is using DHCP.  
 
By default the system is using DHCP.  
Line 81: Line 83:
  
  
=Wifi=
+
==Wifi==
  
  
==WEP==
+
===WEP===
  
 
Edit:
 
Edit:
Line 96: Line 98:
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Wifi configuration [WEP]
 
 
auto wlan0
 
auto wlan0
 
iface wlan0 inet dhcp
 
iface wlan0 inet dhcp
Line 106: Line 107:
  
  
==WPA==
+
===WPA===
  
  
===Required software===
+
====Required software====
  
 
You must install wpa supplicant
 
You must install wpa supplicant
Line 125: Line 126:
  
  
===Configuration===
+
====Configuration====
  
 
Edit
 
Edit
Line 144: Line 145:
  
  
==Take changes into account==
+
===Take changes into account===
  
 
Then, you have to start your wireless interface:
 
Then, you have to start your wireless interface:
Line 161: Line 162:
  
  
Setup hostname
+
=Hostname=
Hosts
+
 
 +
==Get hostname==
 +
 
 +
Just run the following command:
 +
 
 +
<syntaxhighlight lang="bash">
 +
hostname
 +
</syntaxhighlight>
 +
 
 +
 
 +
==Setup hostname==
 +
 
 +
 
 +
===Hosts files===
  
 
Edit configuration file
 
Edit configuration file
#  vi /etc/hosts
 
  
127.0.0.1      localhost.localdomain  localhost
+
<syntaxhighlight lang="bash">
192.168.0.100  server1.example.com    server1
+
vim /etc/hosts
 +
</syntaxhighlight>
 +
 
 +
 
 +
You should have something like that (for fixed IP):
  
 +
<syntaxhighlight lang="bash">
 +
127.0.0.1 localhost
 +
127.0.1.1 myServerName
  
 
# The following lines are desirable for IPv6 capable hosts
 
# The following lines are desirable for IPv6 capable hosts
Line 177: Line 197:
 
ff02::1 ip6-allnodes
 
ff02::1 ip6-allnodes
 
ff02::2 ip6-allrouters
 
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
+
</syntaxhighlight>
 +
 
 +
 
 +
===Hostname===
 +
 
 +
 
 +
<syntaxhighlight lang="bash">
 +
echo myServerName.domain.com > /etc/hostname
 +
</syntaxhighlight>
 +
 
  
Hostname
+
===Take changes into account===
#  echo server1.example.com > /etc/hostname
 
  
Take changes into account
 
 
Reboot server
 
Reboot server
shutdown -r now
+
 
 +
<syntaxhighlight lang="bash">
 +
shutdown -r now
 +
</syntaxhighlight>
 +
 
  
 
Check result
 
Check result
hostname
+
 
hostname -f
+
<syntaxhighlight lang="bash">
 +
hostname
 +
hostname -f
 +
</syntaxhighlight>
  
 
You should have 2 similar results: server1.example.com
 
You should have 2 similar results: server1.example.com

Revision as of 16:20, 21 May 2014

Hostname and network configuration


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

# 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