查看、修改PVE/Ubuntu/Debian(網路IP/網卡ID)

如果沒有內建:

apt install lshw

檢查網卡名稱:

lshw -c network

顯示如下:

*-network:12
       description: Ethernet interface
       physical id: f
       bus info: [email protected]:06:00.0
       logical name: enp6s0
       serial: 00:02:c9:33:01:f0
       capabilities: ethernet physical fibre
       configuration: autonegotiation=off broadcast=yes driver=mlx4_en driverversion=4.0-0 firmware=2.42.5000 link=no multicast=yes port=fibre

其中 logical name: enp6s0 就是網卡ID

or

lshw -c network -businfo
Bus info          Device     Class          Description
=======================================================
[email protected]:01:00.0  enp1s0     network        RTL8125 2.5GbE Controller
[email protected]:02:00.0  enp2s0f0   network        RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
                  vmbr0      network        Ethernet interface
                  vmbr1      network        Ethernet interface
                  vmbr2      network        Ethernet interface
                  vmbr3      network        Ethernet interface
                  vmbr4      network        Ethernet interface
                  vmbr5      network        Ethernet interface
                  tap200i0   network        Ethernet interface
                  veth230i0  network        Ethernet interface
                  veth231i0  network        Ethernet interface

lspci |grep Ethernet
19:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
19:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)


dmesg |grep 19:00
igb 0000:19:00.0 ens10f0: renamed from eth0
igb 0000:19:00.1 ens10f1: renamed from eth2

grep -i pci_slot /sys/class/net/*/device/uevent

#產生出結果如下
/sys/class/net/enp1s0/device/uevent:PCI_SLOT_NAME=0000:01:00.0
/sys/class/net/enp2s0f0/device/uevent:PCI_SLOT_NAME=0000:02:00.0

nano /etc/network/interface

範例:
auto eth0
iface eth0 inet static
address 10.0.1.104
netmask 255.255.255.0
gateway 10.0.1.1
dns-nameservers 1.1.1.1 168.95.192.1

nano /etc/resolv.conf
nameserver 1.1.1.1

MTU9000:

pre-up ip link set enp175s0 mtu 9000 && ip link set enp175s0d1 mtu 9000

Proxmox 免重開機生效IP:

mv /etc/network/interfaces.new /etc/network/interfaces
systemctl restart networking

Ubuntu 17.10之後不再支援靜態IP改用以下方法固定:

nano /etc/netplan/50-cloud-init.yaml

範例:
network:
    ethernets:
        ens18:
            addresses: [10.0.1.108/24]
            gateway4: 10.0.1.1
            nameservers:
              addresses: [10.0.1.1,1.1.1.1]
            dhcp4: no
    version: 2

設定好之後測試:

sudo netplan --debug generate

執行:

netplan apply

Raspberry Pi:

關閉Wifi/BT:

nano /boot/config.txt

dtoverlay=disable-wifi
dtoverlay=disable-bt

#列出WiFi/BT開關狀態清單
rfkill list
#關閉WiFi/BT(軟關閉)
rfkill block wifi
rfkill block bluetooth

Static IP 設置:

/etc/dhcpcd.conf

interface eth0
static ip_address=10.0.1.106/24
static routers=10.0.1.1
static domain_name_servers=1.1.1.1

NanoPi WiFi/BT(NMCLI皆適用):

#切換到root賬戶
su root
#查看網絡設備列表
nmcli dev
#注意,如果列出的設備狀態是 unmanaged 的,說明網絡設備不受NetworkManager管理,你需要清空 /etc/network/interfaces下的網絡設置,然後重啓.
#開啓WiFi
nmcli r wifi on
#掃描附近的 WiFi 熱點
nmcli dev wifi
#連接到指定的 WiFi 熱點
nmcli dev wifi connect "SSID" password "PASSWORD" ifname wlan0
#請將 SSID和 PASSWORD 替換成實際的 WiFi名稱和密碼。連接成功後,下次開機,WiFi也會自動連接。
#設定固定ip
nmcli connection modify 'Wired connection 1' connection.autoconnect yes ipv4.method manual ipv4.address 10.0.1.93/24 ipv4.gateway 10.0.1.1 ipv4.dns 10.0.1.1
#查看連接狀態
nmcli connection show

 

THE END
分享
二维码
< <上一篇
下一篇>>