Como adicionar duas placas de rede a um servidor Ubuntu Server
por Pedro Resende em 20/05/2013 às 09:59:30
Hoje vou-vos explicar como configurar uma segunda placa de rede em linux, mais precisamente Ubuntu Server.
Por vezes é necessário adiconar uma segunda placa de rede (i.e. ligar a uma segunda ligação a uma rede externa, ligar dois servidores directamente).
Após adiconarem a segunda placa de rede, vão começar por alterar o seguinte no ficheiro de interfaces
sudo vi /etc/network/interface
# The loopback network interface
auto lo
iface lo inet loopback
# The primary (public) network interface
auto eth0
iface eth0 inet static
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
# The secondary (private) network interface
auto eth1
iface eth1 inet static
address 10.0.0.1
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
No meu caso a primeira placa de rede irá ser ligada directamente à rede e a segunda é um cabo directo para um segundo servidor, para fazer backup.
Basta agora adicionar a nova rota por onde irão os pacotes
## Ubuntu Linux add persistent route command ###
sudo up route add -net 10.0.0.0 netmask 255.255.255.0 gw 10.0.0.1
sudo route add -net 10.0.0.0 netmask 255.255.255.0 dev eth1
e está feito, como podem ver nada do outro mundo.

Pedro Resende
With over two decades of experience as a Full Stack Developer, I have journeyed through diverse facets of software development. Commencing with the creation of compact institutional websites, I progressed to crafting portals for insurance brokers and contributed to substantial projects for renowned companies such as MS Amlin. My expertise expanded further by delving into product development for Advertiser Kwanko and collaborating with startups in their pivotal ramp-up stages. Notably, I've been involved in architecting extensive e-commerce solutions for global enterprises like Wayfair.
I currently serve as the Tech Lead at Emergn, contributing to the establishment and advancement of the Strategyzer client.