memos/linux/Network Interfaces.md
2024-08-26 20:55:58 +09:00

4.7 KiB

1. ifconfig

deprecated

2. ip

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 noprefixroute
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:1e:06:45:65:a1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.200.10/24 brd 192.168.200.255 scope global enp1s0
       valid_lft forever preferred_lft forever
    inet6 fe80::21e:6ff:fe45:65a1/64 scope link
       valid_lft forever preferred_lft forever
3: enp2s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 00:1e:06:45:65:a2 brd ff:ff:ff:ff:ff:ff
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:0c:2f:cd:cf 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
    inet6 fe80::42:cff:fe2f:cdcf/64 scope link
       valid_lft forever preferred_lft forever
579: br-4b52c6c0b54e: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:ce:aa:2b:64 brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 brd 172.18.255.255 scope global br-4b52c6c0b54e
       valid_lft forever preferred_lft forever
    inet6 fe80::42:ceff:feaa:2b64/64 scope link
       valid_lft forever preferred_lft forever
581: veth8c2a433@if580: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-4b52c6c0b54e state UP group default
    link/ether 66:b7:62:3a:0a:70 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::64b7:62ff:fe3a:a70/64 scope link
       valid_lft forever preferred_lft forever

3. Change IP settings

3.1. netplan

3.1.1. 파일 확인

ls /etc/netplan
50-cloud-init.yaml

3.1.2. 내용 수정

sudo vim /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        enp1s0:
            # IP address
            addresses:
            - 192.168.200.10/24
            
            # DNS
            nameservers:
                addresses: [192.168.200.10]
                search: []
            
            # Gateway
            routes:
            -   to: default
                via: 192.168.200.1
        enp2s0:
            dhcp4: true
            optional: true
    version: 2

3.2. /etc/systemd/resolved.conf

DNS의 경우 /etc/systemd/resolved.conf 파일 수정이 필요할 수 있음

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file (or a copy of it placed in
# /etc/ if the original file is shipped in /usr/), or by creating "drop-ins" in
# the /etc/systemd/resolved.conf.d/ directory. The latter is generally
# recommended. Defaults can be restored by simply deleting the main
# configuration file and all drop-ins located in /etc/.
#
# Use 'systemd-analyze cat-config systemd/resolved.conf' to display the full config.
#
# See resolved.conf(5) for details.

[Resolve]
# Some examples of DNS servers which may be used for DNS= and FallbackDNS=:
# Cloudflare: 1.1.1.1#cloudflare-dns.com 1.0.0.1#cloudflare-dns.com 2606:4700:4700::1111#cloudflare-dns.com 2606:4700:4700::1001#cloudflare-dns.com
# Google:     8.8.8.8#dns.google 8.8.4.4#dns.google 2001:4860:4860::8888#dns.google 2001:4860:4860::8844#dns.google
# Quad9:      9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net
DNS=192.168.200.10
#FallbackDNS=
#Domains=
#DNSSEC=no
#DNSOverTLS=no
#MulticastDNS=no
#LLMNR=no
#Cache=no-negative
#CacheFromLocalhost=no
DNSStubListener=no
#DNSStubListenerExtra=
#ReadEtcHosts=yes
#ResolveUnicastSingleLabel=no
#StaleRetentionSec=0

Note

최초 설치시 /etc/systemd/resolved.conf 파일은 DNS와 DNSStubListener=no 부분이 주석처리되어 있으며 DNS 서버 설치 시 해당 파일을 수정해야 함. ../Home Server/Network/DNS/CoreDNS#추가로 필요한 사항 - 리눅스