shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [shell-script] Alterar o arquivo /etc/network/interfaces


From: Flavio Junior
Subject: Re: [shell-script] Alterar o arquivo /etc/network/interfaces
Date: Thu, 23 Aug 2007 00:26:03 -0300

Bom...
A primeira coisa q venho a cabeça foi sed + address ...

Da manpage do interfaces:
http://www.fifi.org/cgi-bin/man2html/usr/share/man/man5/interfaces.5.gz
DESCRIPTION /etc/network/interfaces contains network interface configuration
information for the *ifup <http://www.fifi.org/cgi-bin/man2html?ifup+8>*(8)
and *ifdown <http://www.fifi.org/cgi-bin/man2html?ifdown+8>*(8) commands.
This is where you configure how your system is connected to the network.
Lines starting with `#' are ignored. A line may be extended across multiple
lines by making the last character a backslash. The file consists of zero or
more "iface", "mapping" and "auto" stanzas. Here is an example.


UMA forma de fazer, na madrugada: http://pastebin.ca/667568
Segue tambem:
wakku@waKKu:~$ cat x
auto lo eth0
iface lo inet loopback
mapping eth0
        script /usr/local/sbin/map-scheme
        map HOME eth0-home
        map WORK eth0-work
iface eth0-home inet static
        address 666.777.888.999
        netmask 255.255.255.0
        up flush-mail
iface eth0-work inet dhcp
wakku@waKKu:~$ read -p 'Interface: ' NICInterface: eth0-home
wakku@waKKu:~$ read -p 'IP: ' IP
IP: 123.456.123.456
wakku@waKKu:~$ sed -r -e '/^(iface|auto|mapping)/i#' -e
"/^(iface|auto|mapping) +$NIC\b/,/^#$/s/address.*/address $IP/" -e '/^#$/d'
x
#
auto lo eth0
#
iface lo inet loopback
#
mapping eth0
        script /usr/local/sbin/map-scheme
        map HOME eth0-home
        map WORK eth0-work
#
iface eth0-home inet static
        address 123.456.123.456
        netmask 255.255.255.0
        up flush-mail
#
iface eth0-work inet dhcp
wakku@waKKu:~$


Coisas que tu vai ter q resolver, mudar de auto pra static, vice-versa ....

Mas com aqueles delimitadores q eu coloquei ali, talvez de pra fazer tudo
nesse esquema do sed mesmo...

O ultimo "-e" é só pra nao ficar sujando o arquivo toda vez q rodar o
script... ai ele garante q vai manter só uma linha ^#$ ...


Sorte,

Flávio do Carmo Junior


On 8/22/07, do_eduardo <address@hidden> wrote:
>
>   $ cat /etc/network/interfaces
> # The loopback network interface
> auto lo
> iface lo inet loopback
>
> # The primary network interface
> auto eth0
> iface eth0 inet dhcp
>
> auto eth1
> iface eth1 inet static
> address 192.168.0.110
> netmask 255.255.255.0
> broadcast 192.168.0.255
> network 192.168.0.1
>
> Alguém conhece uma forma de criar um script que substituia somente a
> configuração da eth0 por exemplo, sem mexer nas demais interfaces de rede?
> A idéia é; o alterar as configurações da placa de rede, usando o
> xdialog como interface para o usuário. No entanto, o usuário poderá
> selecionar entre:
> eth0 (estática-dhcp)
> eth1 (estática-dhcp)
> Sendo assim deve ser possível mudar apenas o trecho que interessa no
> arquivo /etc/network/interfaces e depois resetar o serviço networking.
>
> Valeu
>
>  
>


[As partes desta mensagem que não continham texto foram removidas]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]