Ubuntu 啟用新網卡

把 Linux 主機插上了新的網路卡,並沒有辦法直接使用,還需要經過一些指令設定,以下是設定的步驟:

列出所有 網路卡,查看狀態:
    
ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 00:00:22:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    altname enp2s1
3: ens36: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 00:00:22:33:22:77 brd ff:ff:ff:ff:ff:ff
    altname enp2s4
    

可以看到 ens36 的 state 是 DOWN ,網卡尚未啟用。

將 ens36 網卡啟用:
    
sudo ip link set ens36 up
    

再次查看狀態:
    
ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 00:00:22:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    altname enp2s1
3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 00:00:22:33:22:77 brd ff:ff:ff:ff:ff:ff
    altname enp2s4
    

可以看到 ens36 的 state 是 UP,已經啟用了。

查看 IP:
    
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:00:22:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 192.168.0.10/24 brd 192.168.0.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet 192.168.0.189/24 metric 100 brd 192.168.0.255 scope global secondary dynamic ens33
       valid_lft 60303sec preferred_lft 60303sec
    inet6 fe80::20c:29ff:fe3f:256f/64 scope link
       valid_lft forever preferred_lft forever
3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:00:22:33:22:77 brd ff:ff:ff:ff:ff:ff
    altname enp2s4
    inet6 fe80::20c:22ff:f33f:2277/64 scope link
       valid_lft forever preferred_lft forever
    

可以看到 ens36 網卡有 IPv6 的 IP ,但是不像其他網卡有 IPv4 的 IP。

使用以下指令將 ens36 網卡增加 IPv4 的 ip,這裡指定的 IP 為 192.168.108.100
    
sudo ip addr add 192.168.108.100/24 dev ens36
    

再次查看 IP,發現 ens36 網卡已經有 IPv4 的 IP 了!
    
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:00:22:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 192.168.0.10/24 brd 192.168.0.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet 192.168.0.189/24 metric 100 brd 192.168.0.255 scope global secondary dynamic ens33
       valid_lft 59980sec preferred_lft 59980sec
    inet6 fe80::20c:29ff:fe3f:256f/64 scope link
       valid_lft forever preferred_lft forever
3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:00:22:33:22:77 brd ff:ff:ff:ff:ff:ff
    altname enp2s4
    inet 192.168.108.100/24 scope global ens36
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:22ff:f33f:2277/64 scope link
       valid_lft forever preferred_lft forever
    

留言