Find out which lan card device is active

I used to work with FreeBSD till I resign after working for 10 years. Not touch server for long time make bit nervous when a client ask me to install and configure new server using various OS but mainly still in Linux or BSD environment.

When client change lan card position or change rj45 location system will get error message and not working.

Identify lan card and its ip address in Linux

# ifconfig -a | more

eth0 Link encap:Ethernet HWaddr 00:21:5e:6b:f6:76
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Memory:91a80000-91aa0000

eth1 Link encap:Ethernet HWaddr 00:21:5e:6b:f6:77
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::221:5eff:fe6b:f677/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4607 errors:0 dropped:0 overruns:0 frame:0
TX packets:7707 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:394554 (394.5 KB) TX bytes:10255745 (10.2 MB)
Memory:91980000-919a0000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:226 errors:0 dropped:0 overruns:0 frame:0
TX packets:226 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:36231 (36.2 KB) TX bytes:36231 (36.2 KB)

usb0 Link encap:Ethernet HWaddr 02:21:5e:6b:f6:79
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

# ifconfig -s
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth1 1500 0 4627 0 0 0 7724 0 0 0 BMRU
lo 16436 0 226 0 0 0 226 0 0 0 LRU

How about FreeBSD??

# ifconfig -a
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
ether 00:16:3e:9f:46:a1
inet 216.24.200.111 netmask 0xfffffff8 broadcast 216.24.200.199
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
plip0: flags=108810<POINTOPOINT,SIMPLEX,MULTICAST,NEEDSGIANT> metric 0 mtu 1500
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000

another FreeBSD machine

$ ifconfig -a
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MAGIC>
ether 5c:f3:fc:2a:53:35
inet 118.97.168.200 netmask 0xffffff00 broadcast 118.97.168.255
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MAGIC>
ether 5c:f3:fc:2a:53:36
inet 10.36.2.9 netmask 0xffffff00 broadcast 10.36.2.255
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000
nd6 options=3<PERFORMNUD,ACCEPT_RTADV>

Message from this post :

1. use ifconfig -s in linux to check which lan card device connected with cable.

2. See status in FreeBSD to check which lan card connected with lan cable.