wireless 大作业 linux,Wire/Wireless Network Configuration in Linux

66b52468c121889b900d4956032f1009.png

8种机械键盘轴体对比

本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?

This article is extracted from Network configuration, ArchWiki and Wireless network configuration, ArchWiki. Considering the chaotic order of the original articles, I try to reorganize the chapters of them according to my own ideas.

To set up a network connection, go through the following steps:Ensure your network interface is listed and enabled.

Connect to the network.Plug in the Ethernet cable

or connect to the wireless LAN.

Configure your network connection:static IP address

dynamic IP address: use DHCP

Utilities

Network Configurationip - show / manipulate routing, devices, policy routing and tunnels

ifconfig - configure a network interface

Arch Linux has deprecated ifconfig in favor of iproute2 (part of base). iproute2 provides the ip command-line interface, used to managenetwork interfaces

IP addresses

the routing table

Be aware that configuration made using ip will be lost after a reboot. For persistent configuration, you can use anetwork manager or

automate ip commands using scripts and systemd units.

Also note that ip commands can generally be abbreviated, for clarity they are however spelled out in this article.

Wireless Network Configuration

recommended:iw - show / manipulate wireless devices and their configuration

deprecated:iwconfig - configure a wireless network interface

Network interfaces

By default udev assigns names to your network interfaces using Predictable Network Interface Names, which prefixes interfaces names withen (wired/Ethernet),

wl (wireless/WLAN), or

ww (WWAN).

Listing network interfacesBoth wired and wireless interface names can be found via ls /sys/class/net or ip link.1

2

3

4

5

6

7$ ls /sys/class/net

enp4s0 lo wlp5s0

$ ip link

1: lo: ...

2: enp4s0: ...

3: wlp5s0: ...

Wireless device names can also be retrieved using iw dev.1

2

3

4

5

6Interface wlp5s0

ifindex 3

wdev 0x1

addr 80:19:34:c5:8d:7f

type managed

channel 6 (2437 MHz), width: 40 MHz, center1: 2427 MHz

Enabling and disabling network interfaces

$ ip link set interface up|down1$ ip link show dev eth0

Static IP Address

A static IP address can be configured with most standard network managers and also dhcpcd.

To manually configure a static IP address,add an IP address as described in IP addresses,

set up your routing table and

configure your DNS servers.

IP Addresses

IP addresses are managed using ip-address.CommandDescriptionip address [show]Shows IPv4 and IPv6 addresses assigned to all network interfaces.

ip address show upSame as above except that only addresses assigned to active network interfaces are shown.

ip address show dev enp4s0Shows IPv4 and IPv6 addresses assigned to network interfaces enp4s0.

ip address add address/prefix_len broadcast + dev interfaceAdd an address (IPv4 or IPv6) with the derived broadcast address to network interface interface.

ip address add 2001:0db8:85a3::0370:7334/64 dev eth1Adds an IPv6 address to network interface eth1.

ip address del address/prefix_len dev interface

ip address flush dev interfaceDeletes all addresses matching a criteria, e.g. of a specific interface.

Routing Table

The routing table is managed using ip-route.

PREFIX is either a CIDR notation or default for the default gateway.CommandDescriptionip route showList routes.

ip route add PREFIX via address dev interfaceAdd a route.

ip route del PREFIX via address dev interfaceDelete a route.

Dynamic IP Address: Using DHCP

A Dynamic Host Configuration Protocol (DHCP) server provides clients witha dynamic IP address,

the subnet mask,

the default gateway IP address and

optionally also with DNS name servers.Note: You should not run two DHCP clients simultaneously.

To use DHCP you need a DHCP server in your network and a DHCP client:ClientPackageArchisoNoteSystemd unitsdhcpcddhcpcdYesDHCP, DHCPv6, ZeroConf, static IP

ISC dhclientdhclientYesDHCP, BOOTP, static IP

Note that instead of directly using a DHCP client you can also use a network manager.

Network Managers

A network manager lets you manage network connection settings in so called network profiles to facilitate switching networks.Network managersGUICLI toolsPPP supportDHCP clientSystemd unitsNetworkManagerYesnmcli, nmtuiYesinternal, dhcpcd, or dhclientNetworkManager.service

systemd-networkdNonetworkctlNointernalsystemd-networkd.service, systemd-resolved.service

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值