Debian10修改静态IP地址
Posted liuyi778
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Debian10修改静态IP地址相关的知识,希望对你有一定的参考价值。
一、查看当前系统版本
root@node1:~# cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 10 (buster)" NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
二、修改网卡配置
2.1、查看当前网卡设备名
root@node1:~# ip a 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:66:44:d2 brd ff:ff:ff:ff:ff:ff inet 192.168.0.106/24 brd 192.168.0.255 scope global dynamic noprefixroute ens33 valid_lft 6873sec preferred_lft 6873sec inet6 fe80::20c:29ff:fe66:44d2/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:66:44:dc brd ff:ff:ff:ff:ff:ff inet 10.1.1.13/24 brd 10.1.1.255 scope global ens34 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe66:44dc/64 scope link valid_lft forever preferred_lft forever 4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default link/ether 02:42:55:7f:00:71 brd ff:ff:ff:ff:ff:ff inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0 valid_lft forever preferred_lft forever
可以看出,此时有两个物理网卡,分别是ens33和ens34
2.2、修改网卡配置文件
2.2.1、查看网卡配置文件内容
root@node1:~# cat /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
2.2.2、追加网卡配置参数
网卡参数配置语法
auto ${网卡名} iface ${网卡名} inet ${static} address ${IP} netmask ${netmask} gateway ${gateway}
设置ens33网卡IP获取方式为dhcp
auto ens33 iface ens33 inet dhcp
设置ens34网卡获取IP方式为手动
auto ens34 iface ens34 inet static address 10.1.1.13 netmask 255.255.255.0 gateway 10.1.1.2
保存退出
2.2.3、网卡参数配置完成
root@node1:~# cat /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 auto ens34 iface ens34 inet static address 10.1.1.13 netmask 255.255.255.0 gateway 10.1.1.2
重启网络服务即可
systemctl restart networking
root@node1:~# systemctl restart networking root@node1:~# ip a 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:66:44:d2 brd ff:ff:ff:ff:ff:ff inet 192.168.0.106/24 brd 192.168.0.255 scope global dynamic noprefixroute ens33 valid_lft 5005sec preferred_lft 5005sec inet 192.168.0.200/24 brd 192.168.0.255 scope global secondary ens33 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe66:44d2/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:66:44:dc brd ff:ff:ff:ff:ff:ff inet 10.1.1.13/24 brd 10.1.1.255 scope global ens34 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe66:44dc/64 scope link tentative valid_lft forever preferred_lft forever 4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default link/ether 02:42:55:7f:00:71 brd ff:ff:ff:ff:ff:ff inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0 valid_lft forever preferred_lft forever root@node1:~# vim /etc/network/interfaces
以上是关于Debian10修改静态IP地址的主要内容,如果未能解决你的问题,请参考以下文章
Debian、ContOS、Ubuntu系统手动配置网卡获取IP方式