how to setup a static or dynamic IP adress on Debian based Systems, such as: Ubuntu, Debian, Knoppix, Damn Small Linux, Linux Mint, Sparky Linux, Elive, Descent OS, Solus OS, Snow Linux, Crunchbag, etc (trust me, distrowatch knows many others Debian/Ubuntu based Linux distributions)
To make network configurations, you have to open (as root or with sudo) the /etc/network/interfaces file a text editor.
$ sudo vim /etc/network/interfaces
Set a dynamic IP address:
This is how a network having an dynamic IP address (got from a dhcp server) is configured.
auto eth0
iface eth0 inet dhcp
Explanations:
auto eth0 – enable at startup the eth0 interface
iface eth0 inet dhcp – consider that iface eth0 comes from interface eth0, inet tells you that the network configuration is IPv4 and dhcp that the dynamic ip is assigned by a dhcp server.
Set a static IP address
We have a little more work to do for configurationg a network interface with a static IP address. Edit your /etc/network/interfaces file again, so that it looks like this (these are my IP addresses, replace them with yours.) :
auto eth0
iface eth0 inet static
address 192.168.10.5
netmask 255.255.255.0
network 192.168.10.0
broadcast 192.168.10.255
gateway 192.168.10.1
Explanation:
auto eth0 – enable at startup the eth0 interface
iface eth0 inet static- consider that iface eth0 comes from interface eth0, inet tells you that the network configuration is IPv4 and static that your network interface has static ip adresses.
address – the network’s IP address
netmask – the network’s mask address
network – the network’s address
broadcast – the broadcast address
gateway – the gateway address
It is not necesarry to insert the network and broadcast lines in the /etc/network/interfaces file because the system calculates them from the address and the netmask fields.
So, your network interface file could also look like this, for static IP configurations:
auto eth0
iface eth0 inet static
address 192.168.10.5
netmask 255.255.255.0
gateway 192.168.10.1
Set the network’s DNS server:
To set the DNS server address, you have to edit the /etc/resolv.conf file, with root priviledges:
$ sudo vim /etc/resolv.conf
The /etc/resolv.conf file, should look like this:
name server 8.8.8.8
8.8.8.8 is Google’s private DNS address. You can replace 8.8.8.8 with another DNS address, but everything works perfect with the Google DNS.
Reboot the networking service:
All the configurations that are made in configuration files, are persistent. They don’t apply before you reboot the service, but they will not be discarded after reboot. This is how you reboot the network service, to apply the changes:
$ sudo /etc/init.d/networking restart (this is debian based, i'm creatorb used too)
nah what about you? what is your os?
How to restart the network in Fedora/CentOS/openSUSE:
$ sudo /etc/init.d/network restart
$ sudo service network restart
How to restart the network in Debian/Ubuntu/Linux Mint:
$ sudo /etc/init.d/networking restart
How to restart the network in FreeBSD/PCBSD:
# /etc/rc.d/netif restart
AND
# service netif restart
Oke, i hope that's work for you, when didn't work contac me tomorrow :D hahahah
#ngantuxD
0 comments:
Post a Comment