Bem segue-se um pequeno how-to sobre alguns comando muito uteis sobre rede no debian, ubuntu e derivados
Todos os comandos abaixo devem ser executados como root ou com o sudo no caso do ubuntu.
No debian existem dois arquivos de configuraçÔes de sua rede eles sĂŁo: â/etc/network/interfacesâ e o â/etc/resolv.confâ
O primeiro vocĂȘ pode definir ip, mascara, etcs o segundo vocĂȘ define seu dns.
/etc/resolv.conf nameserver 192.168.0.250 |
O arquivo hosts , fica a informação do nome da sua mĂĄquina e vocĂȘ pode colocar um nome de uma mĂĄquina dentro da sua rede que vocĂȘ pode criar um apelido para ela , e acessar ela no seu navegado.
/etc/hosts |
ConteĂșdo:
1 2 3 4 5 6 7 8 9 10 | 127.0.0.1 localhost debian 127.0.1.1 debian # 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 ff02::3 ip6-allhosts |
O arquivo interfaces fica dentro do diretĂłrio /etc/network, esse arquivo armazena a configuração das suas interfaces de rede, nele vocĂȘ manipula a forma que sua rede se comporta , vocĂȘ pode escolher em deixar sua interface como dhcp ou como ip stĂĄtico , e tambĂ©m pode criar ip alias . âIP alias Ă© uma apelido que vocĂȘ pode dar a sua interface de rede na qual vocĂȘ pode atribuir outros endereços de rede, vocĂȘ pode criar quantos ip alias desejarâ.
/etc/network/interfaces |
O conteĂșdo do meu arquivo:
1 2 3 4 5 6 7 8 9 10 | auto lo iface lo inet loopback address 127.0.0.1 netmask 255.0.0.0 iface eth0 inet static address 192.168.0.2 net 192.168.0.0 netmask 255.255.255.0 gateway 192.168.0.254 |
Os principais comandos de rede sĂŁo:
ifconfig , ifup, ifdown, route, iwconfig , dhclient.
Usando o dhclient para pegar ip por dhcp.
dhclient eth0 |
Atribuindo um endereço de ip a uma interface de rede usando ifconfig :
ifconfig eth0 192.168.0.3 netmask 255.255.255.0 |
Atribuindo um ip alias a uma interface de rede usando ifconfig, no lugar do 1 vocĂȘ pode colocar qualquer nome ou numero:
ifconfig eth0:1 192.168.0.30 netmask 255.255.255.0 |
Listando as interfaces existentes usando ifconfig:
ifconfig |
Derrubando uma interface usando ifconfig:
ifconfig eth0 down |
Levantando uma interface usando ifconfig:
ifconfig eth0 up |
Agora usando o ifup e ifdown.
Derrubar todas as interfaces e seus endereços de ip:
ifdown -a |
Levantando todas as redes de acordo com os dados do arquivo /etc/network/interfaces:
ifup -a |
Agora usando o comando route. O comando route define a rota ou a interface padrĂŁo da sua placa de rede.
Para saber as rotas existentes na sua maquina use esse comando:
netstat -r |
Atribuindo o gateway padrĂŁo da sua rede usando o comando route:
route add default gw 192.168.0.254 |
Atribuindo uma interface como padrĂŁo:
sudo route add default ppp0 |
Agora vamos configurar a nossa rede usando o arquivo /etc/network/interfaces
Configurando a rede como DHCP padrĂŁo na interface eth0. Coloque o arquivo assim:
1 2 | auto eth0 iface eth0 inet dhcp |
Configurando a interface eth0 com ip estĂĄtico:
1 2 3 4 5 6 | auto eth0 iface eth0 inet static address 192.168.0.2 net 192.168.0.0 netmask 255.255.255.0 gateway 192.168.0.254 |
Depois de configurar o arquivo derrube as interfaces:
ifdown -a |
Depois levante:
ifup -a |
Para reniciar a sua configuração de rede existe esse comando:
/etc/init.d/networking restart |
My wife and i felt absolutely ecstatic when John managed to complete his inquiry using the precious recommendations he came across from your very own blog. It is now and again perplexing to simply be freely giving solutions that many people have been selling. We really keep in mind we need the blog owner to be grateful to because of that. The main illustrations you made, the simple site menu, the friendships you will make it possible to instill â itâs most wonderful, and itâs helping our son and our family consider that that article is entertaining, which is certainly tremendously important. Many thanks for all the pieces!
I was honored to obtain a call from my friend when he uncovered the important recommendations shared on the site. Reading through your blog posting is a real wonderful experience. Thanks again for thinking of readers at all like me, and I wish you the best of achievements being a professional in this realm.