嘗試將網卡配置為具有 IP 位址

嘗試將網卡配置為具有 IP 位址

我是一個新的 Linux Mint 用戶,到目前為止我的筆記型電腦只能使用 wifi,不能使用有線乙太網路。

當我輸入時,ifconfig -a我得到以下資訊:

enp0s25: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
         ether 3c:97:0e:c9:ba:f9  txqueuelen 1000  (Ethernet)
         RX packets 0  bytes 0 (0.0 B)
         RX errors 0  dropped 0  overruns 0  frame 0
         TX packets 0  bytes 0 (0.0 B)
         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
         device interrupt 20  memory 0xf2500000-f2520000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
         inet 127.0.0.1  netmask 255.0.0.0
         inet6 ::1  prefixlen 128  scopeid 0x10<host>
         loop  txqueuelen 1000  (Local Loopback)
         RX packets 6110  bytes 617923 (617.9 KB)
         RX errors 0  dropped 0  overruns 0  frame 0
         TX packets 6110  bytes 617923 (617.9 KB)
         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
         inet 192.168.100.193  netmask 255.255.255.0  broadcast 192.168.100.255
         inet6 fe80::2c47:45b4:9fed:9a4e  prefixlen 64  scopeid 0x20<link>
         ether a4:4e:31:85:3a:50  txqueuelen 1000  (Ethernet)
         RX packets 3067404  bytes 4402855268 (4.4 GB)
         RX errors 0  dropped 0  overruns 0  frame 0
         TX packets 1505375  bytes 112689728 (112.6 MB)
         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

我的朋友告訴我,它enp0s25沒有顯示 IP 位址,這就是為什麼乙太網路電纜無法運作的原因。因此,我嘗試按照此連結上的說明為該卡分配 IP 位址: https://www.ostechnix.com/configure-static-ip-address-linux-unix/

然而,現在的問題是,當我轉到/etc資料夾時找不到sysconfig資料夾。到底是怎麼回事?我的資料夾在哪裡sysconfig?我在哪裡可以找到我的/etc/sysconfig/network-scripts/ifcfg-enp0s25文件?

文件內/etc/network/interfaces有以下幾行:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo eth0
iface lo inet loopback

我該如何配置enp0s25

答案1

透過處理以下檔案 /etc/network/interfaces,我能夠使網路介面卡與乙太網路 LAN 一起使用

我必須更改檔案的權限...

然後使用 vim 等編輯器新增以下程式碼行:

auto enp0s25
    iface enp0s25 inet static
    address 192.168.100.99
    netmask 255.255.255.0
    gateway 192.168.100.1
    dns-nameservers 202.69.174.190 4.4.2.2

enp0s25 是我執行 netstat -i 時的連接埠名稱,192.168.100.1 是路由器的 IP 位址以及我使用的 dns-nameserver 的值http://www.whatsmydnsserver.com/去尋找。將 xxx 替換為您從該網站獲得的任何號碼。

然後我重啟了網路卡

sudo systemctl restart networking

我現在的問題是......每當我將帶有互聯網的以太網電纜插入以太網插槽時,如何讓網路介面自動工作......我不想每次我都必須繼續配置網路介面移動位置並使用新路由器......

相關內容