จะดูว่าเครื่องเรามี Card lan กี่ใบใช้งานใบไหนเป็นไอพีไหนใช้คำสั่ง ifconfig ดูได้เลย เหมือนในวินโด้นะครับ ถ้าวินโด้ เราจะใช้คำสั่ง ipconfig เพื่อดูไอพีเครื่อง
ตามรูปมองกันง่าย ๆเลยว่าตอนนี้ linux ของเราเจอ card lan 2 ใบ
คำสั่ง
1. แสดงข้อมูล interface ทั้งหมด
ifconfig -a
$ ifconfig -a enp2s0 Link encap:Ethernet HWaddr 00:1e:c9:54:6b:29 inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::21e:c9ff:fe54:6b29/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2244525 errors:0 dropped:2550 overruns:0 frame:0 TX packets:2996535 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:355746122 (355.7 MB) TX bytes:869249389 (869.2 MB) Interrupt:16 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:65536 Metric:1 RX packets:571968 errors:0 dropped:0 overruns:0 frame:0 TX packets:571968 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:71550491 (71.5 MB) TX bytes:71550491 (71.5 MB)
2. แสดงข้อมูล interface ที่ระบุ
ifconfig <interface>
$ ifconfig enp2s0 enp2s0 Link encap:Ethernet HWaddr 00:1e:c9:54:6b:29 inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::21e:c9ff:fe54:6b29/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2245287 errors:0 dropped:2550 overruns:0 frame:0 TX packets:2997483 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:355899284 (355.8 MB) TX bytes:869430494 (869.4 MB) Interrupt:16
3. เปิดการใช้งาน interface ที่ระบุ
$ ifconfig <interface> up
4. ปิดการใช้งาน interface ที่ระบุ
$ ifconfig <interface> down
5. กำหนดค่า configure ของ interface
$ ifconfig <interface ><xxx.xxx.xxx.xxx> netmask <xxx.xxx.xxx.xxx> broadcast <xxx.xxx.xxx.xxx>.
$ ifconfig eth0 192.168.1.102 netmask 255.255.255.0 broadcast 192.168.1.255
โครงสร้างคำสั่ง
ifconfig [-v] [-a] [-s] [interface] ifconfig [-v] interface [aftype] options | address ...
Facebook Comments