Tag: network

Renewing your IP address on Linux with dhclient

Let’s say you need to change you ip address because there was a change on the network and now ip settings changed,
you can at anytime request with the command : ‘dhclient‘ a new address to a dhcp server ,

if you only have a single network adapter, the command is very simple
just launch the command

to release the address currently associated to you
then just launch

and you computer will broadcast a dhcp request
if you have multiple adapter ,
you can do

dhclient wlan0[/code]
to spécify that you want a new ip address for you wlan0 adapter
by default the command dhclient is silent , meaning that you will not get any information about what the dhcp server answered.
to add verbosity to the command , just add a -v parameter

Ping a complete /24 subnet with one bash line

if you need to know what devices are currently connected on the same network as you ,
there is no very simple way ,

you could use the command arp -a to see your arp table but it’s not always up to date and can have false entries.

using the broadcast option is never working for me ,  nmap is slow and only show the results when the scan il finished and it’s not installed by default on most distrib.

Most ping loop to cycle through all available address on the network are going to deal with the high minimum timeout time of 1 second before trying the next address.
the Best solution is to launch the ping command in parallel , you could use xarg -P to do that , but xargs is not present on lightweight linux distribs like OpenWRT.

 

using that command , you will launch in parallel 255 time the program ping , ping an address from 192.168.1.1 to 192.168.1.254 with only one paquet and a timeout of 1 second.

the answer you will get will look like that

this loop use only very simple commands included in most linux operating systems

Mount a network share on linux

On linux you have the ability to mount network share as they were part of your local storage ,
On debian , you need to have a package named cifs-utils specialised to mount network share.

after installation of the package using the command :

apt-get install cifs-utils

You have to create a folder to attach the mount to

mkdir /media/netshare
mount -t cifs "//host-of-the-share/disk/" /media/netshare -o guest,iocharset=utf8,file_mode=0777,dir_mode=0777

if you have to identify yourself to use the network share the command is slightly different :

mount -t cifs "//host-of-the-share/disk/" /media/netshare -o user=username,iocharset=utf8,file_mode=0777,dir_mode=0777

the system should ask you for your password

to check if you mount was successfull , you can check the mount using

df