目录
Debian网络配置network
Debian网络配置NetworkManager
当前用的是Debian桌面版,网络配置network与NetworkManager,默认网络采用networkManager自动获取ip。
Debian网络配置network
一、查看ip地址,使用ip addr,注意看网络设备名称为ens33,默认自动获取ip
debian11:~$ 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 pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:c5:d0:3d brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet 192.168.60.32/24 brd 192.168.60.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fec5:d03d/64 scope link noprefixroute
valid_lft forever preferred_lft forever
二、修改ip地址/etc/network/interfaces
1、ens33网卡设置动态地址dhcp
root@debian10:/etc/network# vi /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
auto ens33
iface ens33 inet dhcp
2、设置静态ip地址,以及多ip(网卡别名)
root@debian10:/etc/network# vi /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
auto ens33
auto ens33:0
auto ens33:1
iface ens33 inet static
address 192.168.101.30
netmask 255.255.255.0
gateway 192.168.101.1
iface ens33:0 inet static
address 192.168.60.30
netmask 255.255.255.0
iface ens33:1 inet static
address 192.168.40.30
netmask 255.255.255.0
三、重启网络
方式一:root@debian10:~# /etc/init.d/networking restart
方式二:root@debian10:~# systemctl restart networking
四、异常点
重启异常点可通过状态查看:systemctl status networking
基本上就是
1、网络设置没配置好,看报错多检查
2、在network与networkManager上形成冲突,选择其一即可:
解决方式一:最简单直接,reboot重启系统,这个看运气,好的话就是network,不好的话还是networkManager
解决方式二:把network-manager先停,后重启网络
在debian8或则更高系统上:
$ sudo systemctl stop NetworkManager.service 暂时关闭NetworkManager(关闭一次)
$ sudo systemctl disable NetworkManager.service 永久关闭(一直关闭)
在debain7或更早的系统上:
$ sudo /etc/init.d/network-manager stop 暂时关闭NetworkManager(关闭一次)
$ sudo update-rc.d network-manager remove 永久关闭(一直关闭)
完事儿了:
root@Debian9:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
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 pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:95:08:c8 brd ff:ff:ff:ff:ff:ff
inet 192.168.101.30/24 brd 192.168.101.255 scope global ens33
valid_lft forever preferred_lft forever
inet 192.168.60.30/24 brd 192.168.60.255 scope global ens33:0
valid_lft forever preferred_lft forever
inet 192.168.40.30/24 brd 192.168.40.255 scope global ens33:1
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe95:8c8/64 scope link
valid_lft forever preferred_lft forever
Debian网络配置NetworkManager
因为默认采用NetworkManager管理,那么我们只需在UI界面上进行添加或者配置文件里面添加地址即可。network下就不要去配置地址了
方式一,界面:手动并配置ip地址,并应用。
地址信息界面重连即可生效
方式二,文件:/etc/NetworkManager/system-connections下
配置完成重启网络NetworkManager
root@Debian9:/etc/NetworkManager/system-connections# vi Wired\ connection\ 1
[connection]
id=Wired connection 1
uuid=3b28d427-f2ea-424a-b4b8-0f07fef9f96e
type=ethernet
permissions=
timestamp=1669084160[ethernet]
mac-address-blacklist=[ipv4]
#ip地址格式:[ip]/[掩码],【网关】
address1=192.168.101.30/24,192.168.101.1 #单网卡下只能有一个网关
address2=192.168.60.30/24
dns-search=
method=manual[ipv6]
addr-gen-mode=eui64
dns-search=
ip6-privacy=2
method=auto
文章来源:https://www.toymoban.com/news/detail-815454.html
重启:sudo systemctl restart NetworkManager.service文章来源地址https://www.toymoban.com/news/detail-815454.html
到了这里,关于Debian 查看与修改IP,设置多ip,network与networkManager配置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!