I want to use my computer as a router. So I checked how many ethernet card I have running : lspci | grep -i net
. I got a single line ? Does it mean that I have only one "eth0" ethernet card ?
2 Answers
Yes, but more than 1 line does not mean more than 1 NIC. Example
$ lspci | grep -i net
01:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5716
01:00.1 Ethernet controller: Broadcom Corporation NetXtreme II BCM5716
This is 1 NIC connected to eth0:0 and eth0:1 (so 2 IP adresses) that is a PCI device(!).
There is a better command:
$ifconfig | grep Ethernet
eth0 Link encap:Ethernet HWaddr d4:ae:52:67:58:bd
eth0:0 Link encap:Ethernet HWaddr d4:ae:52:67:58:bd
eth0:1 Link encap:Ethernet HWaddr d4:ae:52:67:58:bd
eth1 Link encap:Ethernet HWaddr d4:ae:52:67:58:be
eth1:0 Link encap:Ethernet HWaddr d4:ae:52:67:58:be
2 NICs both with more than 1 connection. "eth1" is a USB device though so not shown in the 1st command.
--- from comments ip link
is even better:
$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether {mac} brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether {mac} brd ff:ff:ff:ff:ff:f
-
with one network card and 2 IP, can I use my computer as a router ? Jul 22, 2015 at 10:34
-
-
-
-
I followed that
http://www.yourownlinux.com/2013/07/how-to-configure-ubuntu-as-router.html
but it supposes I have two cards. Is there some doc I can get to make this happen on my single network card machine ? Jul 22, 2015 at 10:46
lspci
list alll PCI devices so if you have some old built in network card, or some usb cards it will not shown in the result, so to get more precise result try this:
ifconfig -a | grep Ethernet
Thanks for @gertvdijk note add the -a
option to ifconfig to list all interfaces even if they are down
-
-
ifconfig
without the-a
option will only list interfaces with their link up. Also,ifconfig
is deprecated and one should use theip
toolset, e.g.ip link
to list links. Jul 22, 2015 at 10:55 -
lspci
orifconfig
to find out. Note that if you have a USB card or something it won't show inlspci
, you needlsusb
then.swconfig
). Then ports can be mapped to VLANs/PVIDs and the single interface connected to the system can see all VLANs using the regular 802.11q implementation. This is how for example most home routers work -- they only have a single ethernet chip with integrated switch with port-VLANs separating LAN/WAN.lspci -nnk | grep -iEA3 "(network|ethernet)"
. Either way, to build a home router with scalable network interface I would recommend to buy a managed switch (or install OpenWRT on your home router for example) and use VLANs. Then use a 'trunk' port to connect all the networks with a single cable to your server. That's the most used, scalable and cheap way to do it.