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...")
 
(add debian network manager)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
Hostname and network configuration
+
[[Category:Linux]]
 +
Hostname and network configuration + DHCP server
  
  
=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 27:
  
  
==Discover your gateway==
+
===Discover your gateway===
 
 
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 34: Line 37:
  
  
=Setup DHCP / static IP @=
+
==Setup DHCP / static IP @==
  
 
By default the system is using DHCP.  
 
By default the system is using DHCP.  
Line 69: Line 72:
 
         network 192.168.0.0
 
         network 192.168.0.0
 
         broadcast 192.168.0.255
 
         broadcast 192.168.0.255
         dns-nameservers 8.8.8.8 8.8.4.4                 # Google DNS
+
         # Google 8.8.8.8 8.8.4.4
 +
        # OpenDNS 208.67.222.222 208.67.220.220
 +
        #         https://www.opendns.com/home-internet-security/opendns-ip-addresses/
 +
        dns-nameservers 208.67.222.222 208.67.220.220
  
 +
        ## If you belong to a domain you can add a reference to it
 +
        dns-search smartcards.vehco.com
 +
        dns-domain smartcards.vehco.com
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 80: Line 89:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
==Wifi==
  
=Wifi=
+
===Debian network manager===
  
  
==WEP==
+
<syntaxhighlight lang="bash">
 +
su root
 +
nm-connection-editor
 +
</syntaxhighlight>
 +
 
 +
 
 +
===WEP===
  
 
Edit:
 
Edit:
Line 96: Line 112:
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Wifi configuration [WEP]
 
 
auto wlan0
 
auto wlan0
 
iface wlan0 inet dhcp
 
iface wlan0 inet dhcp
Line 106: Line 121:
  
  
==WPA==
+
===WPA===
  
  
===Required software===
+
====Required software====
  
 
You must install wpa supplicant
 
You must install wpa supplicant
Line 125: Line 140:
  
  
===Configuration===
+
====Configuration====
  
 
Edit
 
Edit
Line 144: Line 159:
  
  
==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 176:
  
  
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.myDomain  myServerName
  
 
# The following lines are desirable for IPv6 capable hosts
 
# The following lines are desirable for IPv6 capable hosts
Line 177: Line 211:
 
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
 
#  echo server1.example.com > /etc/hostname
 
  
Take changes into account
+
===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

Latest revision as of 10:31, 4 October 2015

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
        # Google 8.8.8.8 8.8.4.4
        # OpenDNS 208.67.222.222 208.67.220.220 
        #          https://www.opendns.com/home-internet-security/opendns-ip-addresses/
        dns-nameservers 208.67.222.222 208.67.220.220

        ## If you belong to a domain you can add a reference to it
        dns-search smartcards.vehco.com
        dns-domain smartcards.vehco.com


Then, restart configuration

/etc/init.d/networking restart

Wifi

Debian network manager

su root
nm-connection-editor


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