1

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 ?

6
  • Probably. you need to look at the full output of lspci or ifconfig to find out. Note that if you have a USB card or something it won't show in lspci, you need lsusb then.
    – Wilf
    Jul 22, 2015 at 10:26
  • Some network cards have more than one connector (PHY) and will get listed as one PCI device, but will offer multiple links (one for each connector). Also, some ethernet cards with multiple connectors are in fact switches and have the ability to push a switch configuration to them (using 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.
    – gertvdijk
    Jul 22, 2015 at 10:59
  • @gertvdijk thank you, it is interesting - how do I check that my machine supports this feature ?
    – epsilones
    Jul 22, 2015 at 11:10
  • @Newben Just provide the exact hardware you have, preferrably with numeric vendor/product IDs. E.g. 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.
    – gertvdijk
    Jul 22, 2015 at 11:20
  • @Newben How many ethernet plugs do you have? That's usually the best way to start checking. :)
    – Moshe Katz
    Jul 22, 2015 at 15:26

2 Answers 2

4

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
8
  • with one network card and 2 IP, can I use my computer as a router ?
    – epsilones
    Jul 22, 2015 at 10:34
  • @Newben what do you mean use it as router?
    – Maythux
    Jul 22, 2015 at 10:35
  • I want to connect an other ubuntu machine to mine
    – epsilones
    Jul 22, 2015 at 10:37
  • @Newben yes you can do that
    – Maythux
    Jul 22, 2015 at 10:42
  • 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 ?
    – epsilones
    Jul 22, 2015 at 10:46
3

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

3
  • Darn you for being quicker.
    – Rinzwind
    Jul 22, 2015 at 10:29
  • ifconfig without the -a option will only list interfaces with their link up. Also, ifconfig is deprecated and one should use the ip toolset, e.g. ip link to list links.
    – gertvdijk
    Jul 22, 2015 at 10:55
  • So why downvoting?!
    – Maythux
    Jul 22, 2015 at 10:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .