Vous êtes sur la page 1sur 5

Some notes about using an ethernet card (NIC) on Linux

(All in a days work)

When I need some tips I search over the internet and take notes.
This is a bunch of notes taken over a long time.
I hope they can be useful.
Please excuse me if I can't give the sources correctly. As I said, taking notes.
But please don't emulate me.
It is a good practice say thank you to the author (normally I do this.), and giv
e the credits.
I promise that if I can, I will edit the document to give the credits.
Good luck.
There are situations when you want or need a second IP on your box, for example
when you are installing a firewall (In this case is always better to have two NI
Cs but you can do it with only one)
We will assume you already have a system running and already has one IP, if not
you wanna read Define a static IP in Linux.
Now we will add the second IP use the same command specifying a virtual NIC
sudo ifconfig eth0:0 netmask up
That's all, but to make changes permanent, edit the file /etc/network/interfaces
There you may have already have something like this
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
Change it to this:
auto lo
iface lo inet loopback
auto eth0 eth0:0
iface eth0 inet static
iface eth0:1 inet static
If you want to specify the gateway also here, proceed this way.
auto lo
iface lo inet loopback
auto eth0 eth0:0
iface eth0 inet static
up route add default gw
down route del default gw
#Second IP same NIC
iface eth0:0 inet static

Define a static IP on Linux, and assign a Default Gateway

There are some networks where DHCP is not yet implemented, and when you enter in
to those networks asking for connection, the Admin of the network will give you
these data.
IP, Netmask, Gateway and sometimes DNS, I see myself in this situations lots of
times as I travel with my Laptop, and in the offices where I have to work I foun
d this types of networks with no DHCP server installed.
Well, what will you do with those info?, I like the command line, so I will show
you how to assign this IP through the Linux command line console.
We will not make it fixed I mean it will be erased when the PC is restarted, so
it will be there only for the current session, the command is.
sudo ifconfig ethX ADDRESS netmask NETMASK
Lets say you have been given this info.
And your NIC is named eth0 on you Linux, to find the NICs available, issue the c
sudo ifconfig
With no options, and all the available interfaces will be on the screen.
Well first assign the IP and the netmask
sudo ifconfig eth0 netmask up
Now add the default Gateway
sudo route add default gw
The last step is to assign a DNS server, if you travel a lot like me, I hardly r
ecommend to have your own DNS on your Laptop, read here how to do it: Configure
pdnsd as local DNS server
Otherwise, you should edit /etc/resolv.conf, and there enter this line, followin
g our example.
You may want to read Add second IP to Linux for more info, and also how to make
changes permanent
Submitted by Anonymous on Thu, 04/30/2009 - 06:03. #
Hey i was wondering if you could explain how to make the settings permanent. In
my case it's because my ISP gave me a static IP, and i heard about faster boot i
n Ubuntu if you disable Network Manager for good and you give your linux rig a s
tatic IP configuration. I want to try that on my Ubuntu box but i lack the CLI k
nowledge. Please help! (T_T)
Submitted by ggarron on Fri, 05/01/2009 - 07:16. #
Depends on your distro, if you are using Debian or a derivative edit /etc/networ
k/interfaces, and make add something like this
# Your static IP - change the interface to your needs, also the IP
auto eth0
iface eth0 inet static
Change it according to your needs, if it is not Debian nor Ubuntu or any other D
ebian relative, let me know and I will try to help you.

Primero mirate que cosas buenas en hardware soportan tus tarjetas con
`ethtool -k eth0` y lo que este en off volvelo on (rtfm), también
mirate con `ethtool -g eth0` que máximos de buffers soportan tus NICs,
luego a todas las NICs aumentales la cola de TX a 4000:

ifconfig eth0 txqueuelen 4000

Luego los parámetros del stack de IP en /etc/sysctl.conf:

net.core.rmem_max = 8388608
net.core.wmem_max = 8388608
net.core.rmem_default = 65536
net.core.wmem_default = 65536
net.core.netdev_max_backlog = 1500
net.ipv4.tcp_rmem = 4096 87380 8388608
net.ipv4.tcp_wmem = 4096 65536 8388608
net.ipv4.tcp_mem = 8388608 8388608 8388608
net.ipv4.tcp_fin_timeout = 20
net.ipv4.tcp_keepalive_time = 1000
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_ecn = 1
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_echo_ignore_all = 0
net.ipv4.ip_forward = 0
net.ipv4.route.flush = 1
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0

Ya con eso deberÍan sokar amargamente...