码迷,mamicode.com
首页 > 其他好文 > 详细

Debian10修改静态IP地址

时间:2020-04-25 00:47:57      阅读:493      评论:0      收藏:0      [点我收藏+]

标签:inet6   conda   pretty   oba   ip地址   multicast   www   docker   参数配置   

一、查看当前系统版本

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地址

标签:inet6   conda   pretty   oba   ip地址   multicast   www   docker   参数配置   

原文地址:https://www.cnblogs.com/liuyi778/p/12771084.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!