Ubuntu server wifi configuration

1, ubuntu network connection wifi configuration

# This is the network config written by 'subiquity'
network:
  version: 2
  renderer: networkd
  wifis:
    wlo1:
      dhcp4: true
      dhcp6: true
      access-points:
        "712":
          password: "sh712666"

Note that wlo1 in the configuration is the name of your machine’s wifi setting, use the following command to view the corresponding wifi device name:

root@wmh-us01:/etc/netplan# ls /sys/class/net/
enp0s31f6  lo  wlo1

On Ubuntu Server, use the command "ls /sys/class/net" to list the names of the computer's network interfaces. This command displays a list of the names of all network interface devices in the system

Ubuntu 18.04 and later versions usually use a naming scheme called Predictable Network Interface Names, so the "enp0s31f6" you see is the interface name of the wired network card.

"Predictable Network Interface Names" is a convention for naming Linux network interface devices. Through this convention, Linux fixes the name of each network interface device to a predictable name relative to the system hardware device path, which makes it easier for users to identify and configure network interfaces.

Under the Predictable Network Interface Names scheme, the naming of interfaces follows the following rules:

  • Fixed prefix: All network interface device names start with the same prefix, such as "en", "wl", etc.
  • Numbered by device order: The suffix of the interface name contains a number, which represents the position order of the device in the system.
  • Differentiate the type: the letter in the interface name identifies the device type, such as "en" for a wired network card, "wl" for a wireless network card, etc.

For example, "enp0s3" might be the name of the first device connected to the PCI bus of en (wired NIC), and "wlp2s0" might be the name of the second device connected to the PCI bus of wl (wireless NIC) . This naming scheme ensures predictable network device names, making it easier for users to understand and configure network interfaces.

2, ubuntu server 22.04 static IP setting

root@wmh-us01:/etc/netplan# cat 00-installer-config-wifi.yaml
# This is the network config written by 'subiquity'
network:
  version: 2
  renderer: networkd
  wifis:
    wlo1:
      dhcp4: false
      # dhcp6: true
      addresses: [192.168.3.211/24] 
      nameservers:
          addresses: [114.114.114.114,180.76.76.76]
      access-points:
        "wifi_name1":
          password: "wifi_name1_password"
        "wifi_name2":
          password: "wifi_name2_password"
        "wifi_name3":
          password: "wifi_name3_password"
      routes:
        - to: 0.0.0.0/0
          via: 192.168.100.1
          metric: 100
        - to: 10.0.0.0/24
          via: 192.168.200.1
          metric: 200

(1) dhcp4: "dhcp4: false" explicitly specifies to disable the DHCPv4 protocol. This means that the IP address, subnet mask, gateway, and DNS need to be manually configured for the "wlo1" NIC.

(2) nameservers, addresses indicate the DNS service address, you need to configure the domestic DNS IP, otherwise you may not be able to ping www.baidu.com

(3) access-points: configure wifi connection information, you can configure multiple wifi information, as above

(4) routes: routes" can be used to specify other network routes. When your computer needs to access the target IP that is not in the local network, you can achieve access by specifying other network routes. In the above configuration, two routing:

  • The first route specifies that all traffic be routed to the 192.168.100.1 gateway. 0.0.0.0/0 means all IP addresses.
  • The second route specifies that traffic from the 10.0.0.0/24 network segment be routed to the 192.168.200.1 gateway.

The "to" and "via" fields in the "routes" setting specify the destination IP address and the IP address of the next gateway. The "metric" field is used to set the priority in the routing policy, which determines which route has higher priority.

The "routes" setting allows for finer-grained control over network traffic, enabling it to traverse different subnets and networks.

After the configuration is complete, keep the file, netplan apply, and the configuration will take effect

Guess you like

Origin blog.csdn.net/abbcccdde/article/details/131138065