network 설정

yoni·2023년 4월 14일

Linux

목록 보기
6/16

/etc/hosts -> 작은 dns
여기에 ip등록해두면, 도메인 가능

[root@localhost .ssh]# nmtui
[root@localhost .ssh]# ll /etc/sysconfig/network-scripts
total 232
-rw-r--r--. 1 root root   379 Apr 14 10:06 ifcfg-eth0
-rw-r--r--. 1 root root   254 Sep 12  2016 ifcfg-lo
lrwxrwxrwx. 1 root root    24 Apr 13 10:28 ifdown -> ../../../usr/sbin/ifdown
-rwxr-xr-x. 1 root root   627 Sep 12  2016 ifdown-bnep
-rwxr-xr-x. 1 root root  5817 Sep 12  2016 ifdown-eth
-rwxr-xr-x. 1 root root  6196 May 26  2017 ifdown-ib
-rwxr-xr-x. 1 root root   781 Sep 12  2016 ifdown-ippp
-rwxr-xr-x. 1 root root  4201 Sep 12  2016 ifdown-ipv6
lrwxrwxrwx. 1 root root    11 Apr 13 10:28 ifdown-isdn -> ifdown-ippp
-rwxr-xr-x. 1 root root  1778 Sep 12  2016 ifdown-post
-rwxr-xr-x. 1 root root  1068 Sep 12  2016 ifdown-ppp
-rwxr-xr-x. 1 root root   837 Sep 12  2016 ifdown-routes
-rwxr-xr-x. 1 root root  1444 Sep 12  2016 ifdown-sit
-rwxr-xr-x. 1 root root  1621 Nov  6  2016 ifdown-Team
-rwxr-xr-x. 1 root root  1556 Apr 16  2016 ifdown-TeamPort
-rwxr-xr-x. 1 root root  1462 Sep 12  2016 ifdown-tunnel
lrwxrwxrwx. 1 root root    22 Apr 13 10:28 ifup -> ../../../usr/sbin/ifup
-rwxr-xr-x. 1 root root 12688 Sep 12  2016 ifup-aliases
-rwxr-xr-x. 1 root root   859 Sep 12  2016 ifup-bnep
-rwxr-xr-x. 1 root root 11880 Sep 12  2016 ifup-eth
-rwxr-xr-x. 1 root root 10145 May 26  2017 ifup-ib
-rwxr-xr-x. 1 root root 12039 Sep 12  2016 ifup-ippp
-rwxr-xr-x. 1 root root 10525 Sep 12  2016 ifup-ipv6
lrwxrwxrwx. 1 root root     9 Apr 13 10:28 ifup-isdn -> ifup-ippp
-rwxr-xr-x. 1 root root   642 Sep 12  2016 ifup-plip
-rwxr-xr-x. 1 root root  1043 Sep 12  2016 ifup-plusb
-rwxr-xr-x. 1 root root  2772 Sep 12  2016 ifup-post
-rwxr-xr-x. 1 root root  4154 Sep 12  2016 ifup-ppp
-rwxr-xr-x. 1 root root  1925 Sep 12  2016 ifup-routes
-rwxr-xr-x. 1 root root  3263 Sep 12  2016 ifup-sit
-rwxr-xr-x. 1 root root  1755 Apr 16  2016 ifup-Team
-rwxr-xr-x. 1 root root  1876 Apr 16  2016 ifup-TeamPort
-rwxr-xr-x. 1 root root  2682 Sep 12  2016 ifup-tunnel
-rwxr-xr-x. 1 root root  1740 Sep 12  2016 ifup-wireless
-rwxr-xr-x. 1 root root  4623 Sep 12  2016 init.ipv6-global
-rw-r--r--. 1 root root 15780 Apr 13  2017 network-functions
-rw-r--r--. 1 root root 26829 Sep 12  2016 network-functions-ipv6
[root@localhost .ssh]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 
# Generated by dracut initrd
NAME="eth0"
HWADDR=52:54:00:10:51:1B
ONBOOT=yes
NETBOOT=yes
UUID="01239daa-e89f-46aa-88df-f2f828f95805"
IPV6INIT=yes
BOOTPROTO=none
TYPE=Ethernet
IPADDR=192.168.122.101
PREFIX=24
GATEWAY=192.168.122.1
DNS1=192.168.122.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
[root@localhost .ssh]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.253  netmask 255.255.255.0  broadcast 192.168.122.255
        inet6 fe80::5054:ff:fe10:511b  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:10:51:1b  txqueuelen 1000  (Ethernet)
        RX packets 497468  bytes 951679576 (907.5 MiB)
        RX errors 0  dropped 5  overruns 0  frame 0
        TX packets 447364  bytes 30790677 (29.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost .ssh]# nmtui
[root@localhost .ssh]# 
[root@localhost .ssh]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.253  netmask 255.255.255.0  broadcast 192.168.122.255
        inet6 fe80::5054:ff:fe10:511b  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:10:51:1b  txqueuelen 1000  (Ethernet)
        RX packets 497513  bytes 951681944 (907.5 MiB)
        RX errors 0  dropped 5  overruns 0  frame 0
        TX packets 447366  bytes 30790809 (29.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost .ssh]# ping -c 2 localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.060 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.058 ms

--- localhost ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.058/0.059/0.060/0.001 ms
[root@localhost .ssh]# ping -c 2 192.168.122.1
PING 192.168.122.1 (192.168.122.1) 56(84) bytes of data.
64 bytes from 192.168.122.1: icmp_seq=1 ttl=64 time=0.240 ms
64 bytes from 192.168.122.1: icmp_seq=2 ttl=64 time=0.218 ms

--- 192.168.122.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.218/0.229/0.240/0.011 ms
[root@localhost .ssh]# ping -c 2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=111 time=27.3 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=111 time=27.3 ms

--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 27.339/27.361/27.383/0.022 ms
[root@localhost .ssh]# ping -c 2 www.google.co.kr
PING www.google.co.kr (172.217.161.227) 56(84) bytes of data.
64 bytes from kix06s05-in-f3.1e100.net (172.217.161.227): icmp_seq=1 ttl=111 time=27.5 ms
64 bytes from kix06s05-in-f3.1e100.net (172.217.161.227): icmp_seq=2 ttl=111 time=27.4 ms

--- www.google.co.kr ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 27.489/27.535/27.581/0.046 ms
[root@localhost .ssh]# ping -c 2 192.168.122.101
PING 192.168.122.101 (192.168.122.101) 56(84) bytes of data.
From 192.168.122.253 icmp_seq=1 Destination Host Unreachable
From 192.168.122.253 icmp_seq=2 Destination Host Unreachable

--- 192.168.122.101 ping statistics ---
2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 999ms
pipe 2
[root@localhost .ssh]# traceroute www.google.co.kr
traceroute to www.google.co.kr (142.250.206.227), 30 hops max, 60 byte packets
 1  gateway (192.168.122.1)  0.164 ms  0.112 ms  0.067 ms
 2  59.29.225.254 (59.29.225.254)  0.883 ms  0.822 ms  0.740 ms
 3  59.29.225.12 (59.29.225.12)  0.670 ms  0.616 ms  0.548 ms
 4  211.192.200.241 (211.192.200.241)  3.810 ms  3.760 ms  3.758 ms
 5  * * *
 6  * * *
 7  112.189.14.85 (112.189.14.85)  1.261 ms 112.189.13.97 (112.189.13.97)  1.359 ms  1.266 ms
 8  * * *
 9  112.174.90.154 (112.174.90.154)  8.385 ms 112.174.90.130 (112.174.90.130)  7.804 ms  7.793 ms
10  112.174.84.50 (112.174.84.50)  7.773 ms 112.174.84.46 (112.174.84.46)  7.957 ms 112.174.84.50 (112.174.84.50)  7.084 ms
11  142.250.165.78 (142.250.165.78)  27.844 ms 72.14.243.228 (72.14.243.228)  33.514 ms 142.250.165.78 (142.250.165.78)  28.548 ms
12  108.170.243.33 (108.170.243.33)  31.512 ms  29.781 ms *
13  108.170.242.193 (108.170.242.193)  32.138 ms 142.250.58.187 (142.250.58.187)  28.048 ms 172.253.75.94 (172.253.75.94)  32.654 ms
14  108.170.242.208 (108.170.242.208)  32.408 ms 108.170.242.112 (108.170.242.112)  33.541 ms 108.170.242.98 (108.170.242.98)  31.794 ms
15  142.251.254.135 (142.251.254.135)  33.588 ms 209.85.249.18 (209.85.249.18)  33.788 ms 142.251.254.81 (142.251.254.81)  33.138 ms
16  142.250.57.228 (142.250.57.228)  33.823 ms kix06s10-in-f3.1e100.net (142.250.206.227)  28.590 ms 142.250.58.92 (142.250.58.92)  34.561 ms


[root@localhost .ssh]# nslookup www.naver.com
Server:		192.168.122.1
Address:	192.168.122.1#53

Non-authoritative answer:
www.naver.com	canonical name = www.naver.com.nheos.com.
Name:	www.naver.com.nheos.com
Address: 223.130.200.107
Name:	www.naver.com.nheos.com
Address: 223.130.200.104

[root@localhost .ssh]# dig www.daum.net

; <<>> DiG 9.9.4-RedHat-9.9.4-38.el7_3.3 <<>> www.daum.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12430
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;www.daum.net.			IN	A

;; ANSWER SECTION:
www.daum.net.		273	IN	CNAME	daum-4vdtymgd.kgslb.com.
daum-4vdtymgd.kgslb.com. 12	IN	A	121.53.105.193

;; Query time: 2 msec
;; SERVER: 192.168.122.1#53(192.168.122.1)
;; WHEN: Fri Apr 14 10:20:12 KST 2023
;; MSG SIZE  rcvd: 94

[root@localhost .ssh]# nmcli
virbr0: connected to virbr0
	bridge, 52:54:00:7E:B9:D6, sw, mtu 1500
	inet4 192.168.124.1/24

eth0: connected to eth0
	"Red Hat Virtio network device"
	ethernet (virtio_net), 52:54:00:10:51:1B, hw, mtu 1500
	ip4 default
	inet4 192.168.122.253/24
	inet6 fe80::5054:ff:fe10:511b/64

lo: unmanaged
	loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536

virbr0-nic: unmanaged
	tun, 52:54:00:7E:B9:D6, sw, mtu 1500

Use "nmcli device show" to get complete information about known devices and
"nmcli connection show" to get an overview on active connection profiles.

Consult nmcli(1) and nmcli-examples(5) manual pages for complete usage details.

[root@localhost .ssh]# nmcli dev
DEVICE      TYPE      STATE      CONNECTION 
virbr0      bridge    connected  virbr0     
eth0        ethernet  connected  eth0       
lo          loopback  unmanaged  --         
virbr0-nic  tun       unmanaged  --         

[root@localhost .ssh]# nmcli connection
NAME    UUID                                  TYPE            DEVICE 
eth0    01239daa-e89f-46aa-88df-f2f828f95805  802-3-ethernet  eth0   
virbr0  ca54eaeb-de63-4d54-8fa3-631446f13343  bridge          virbr0 
[root@localhost .ssh]# nmcli con 
add      delete   edit     help     load     monitor  show     
clone    down     export   import   modify   reload   up       

[root@localhost .ssh]# nmcli con del
Error: No connection specified.

[root@localhost .ssh]# nmcli con del eth0 
Connection 'eth0' (01239daa-e89f-46aa-88df-f2f828f95805) successfully deleted.
[root@localhost .ssh]# ls /etc/sysconfig/network-scripts
ifcfg-lo     ifdown-ipv6    ifdown-Team      ifup-eth   ifup-plusb   ifup-TeamPort
ifdown       ifdown-isdn    ifdown-TeamPort  ifup-ib    ifup-post    ifup-tunnel
ifdown-bnep  ifdown-post    ifdown-tunnel    ifup-ippp  ifup-ppp     ifup-wireless
ifdown-eth   ifdown-ppp     ifup             ifup-ipv6  ifup-routes  init.ipv6-global
ifdown-ib    ifdown-routes  ifup-aliases     ifup-isdn  ifup-sit     network-functions
ifdown-ippp  ifdown-sit     ifup-bnep        ifup-plip  ifup-Team    network-functions-ipv6

[root@localhost .ssh]# nmcli con del 'Wired connection 1'
Connection 'Wired connection 1' (8966818d-f806-33f7-9e73-b0b7800dae91) successfully deleted.
[root@localhost .ssh]# nmcli dev
DEVICE      TYPE      STATE         CONNECTION 
virbr0      bridge    connected     virbr0     
eth0        ethernet  disconnected  --         
lo          loopback  unmanaged     --         
virbr0-nic  tun       unmanaged     --       

[root@localhost .ssh]# nmcli con add type 
adsl          bridge        generic       macvlan       team          vpn           
bluetooth     bridge-slave  gsm           no-slave      team-slave    vxlan         
bond          cdma          infiniband    olpc-mesh     tun           wifi          
bond-slave    ethernet      ip-tunnel     pppoe         vlan          wimax         
[root@localhost .ssh]# nmcli con add type ethernet 
Display all 141 possibilities? (y or n)
802-1x.altsubject-matches                 dcb.app-fcoe-priority
802-1x.anonymous-identity                 dcb.app-fip-flags
802-1x.ca-cert                            dcb.app-fip-priority
802-1x.ca-path                            dcb.app-iscsi-flags
802-1x.client-cert                        dcb.app-iscsi-priority
802-1x.domain-suffix-match                dcb.priority-bandwidth
802-1x.eap                                dcb.priority-flow-control
802-1x.identity                           dcb.priority-flow-control-flags
802-1x.pac-file                           dcb.priority-group-bandwidth
802-1x.password                           dcb.priority-group-flags
802-1x.password-flags                     dcb.priority-group-id
802-1x.password-raw                       dcb.priority-strict-bandwidth
802-1x.password-raw-flags                 dcb.priority-traffic-class
802-1x.phase1-fast-provisioning           ethernet.auto-negotiate
802-1x.phase1-peaplabel                   ethernet.cloned-mac-address
802-1x.phase1-peapver                     ethernet.duplex
802-1x.phase2-altsubject-matches          ethernet.generate-mac-address-mask
802-1x.phase2-auth                        ethernet.mac-address
802-1x.phase2-autheap                     ethernet.mac-address-blacklist
802-1x.phase2-ca-cert                     ethernet.mtu
802-1x.phase2-ca-path                     ethernet.port
802-1x.phase2-client-cert                 ethernet.s390-nettype
802-1x.phase2-domain-suffix-match         ethernet.s390-options
802-1x.phase2-private-key                 ethernet.s390-subchannels
802-1x.phase2-private-key-password        ethernet.speed
802-1x.phase2-private-key-password-flags  ethernet.wake-on-lan
802-1x.phase2-subject-match               ethernet.wake-on-lan-password
802-1x.pin                                ifname
802-1x.pin-flags                          ipv4.addresses
802-1x.private-key                        ipv4.dad-timeout
802-1x.private-key-password               ipv4.dhcp-client-id
802-1x.private-key-password-flags         ipv4.dhcp-fqdn
802-1x.subject-match                      ipv4.dhcp-hostname
[root@localhost .ssh]# nmcli con add type ethernet ifname 
eth0        lo          virbr0      virbr0-nic  
[root@localhost .ssh]# nmcli con add type ethernet ifname eth0 con-name eth0 autoconnect yes ipv4.
ipv4.addresses           ipv4.dhcp-send-hostname  ipv4.dns-search          ipv4.method
ipv4.dad-timeout         ipv4.dhcp-timeout        ipv4.gateway             ipv4.never-default
ipv4.dhcp-client-id      ipv4.dns                 ipv4.ignore-auto-dns     ipv4.route-metric
ipv4.dhcp-fqdn           ipv4.dns-options         ipv4.ignore-auto-routes  ipv4.routes
ipv4.dhcp-hostname       ipv4.dns-priority        ipv4.may-fail            
[root@localhost .ssh]# nmcli con add type ethernet ifname eth0 con-name eth0 autoconnect yes
Connection 'eth0' (6a23644f-89a1-438c-b834-90849d9f3977) successfully added.
[root@localhost .ssh]# ls /etc/sysconfig/network-scripts/
ifcfg-eth0   ifdown-ippp    ifdown-sit       ifup-bnep  ifup-plip    ifup-Team          network-functions-ipv6
ifcfg-lo     ifdown-ipv6    ifdown-Team      ifup-eth   ifup-plusb   ifup-TeamPort
ifdown       ifdown-isdn    ifdown-TeamPort  ifup-ib    ifup-post    ifup-tunnel
ifdown-bnep  ifdown-post    ifdown-tunnel    ifup-ippp  ifup-ppp     ifup-wireless
ifdown-eth   ifdown-ppp     ifup             ifup-ipv6  ifup-routes  init.ipv6-global
ifdown-ib    ifdown-routes  ifup-aliases     ifup-isdn  ifup-sit     network-functions

[root@localhost .ssh]# nmcli con modi eth0 ipv4.method manual ipv4.addresses 192.168.122.108/24 ipv4.dns 192.168.122.1 ipv4.gateway 192.168.122.1
[root@localhost .ssh]# systemctl restart network
[root@localhost .ssh]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.108  netmask 255.255.255.0  broadcast 192.168.122.255
        inet6 fe80::6f2c:1f29:25e8:7d1f  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:10:51:1b  txqueuelen 1000  (Ethernet)
        RX packets 499027  bytes 951768885 (907.6 MiB)
        RX errors 0  dropped 5  overruns 0  frame 0
        TX packets 447620  bytes 30817357 (29.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost .ssh]# cat /etc/resolv.conf 
# Generated by NetworkManager
nameserver 192.168.122.1

profile
study log

0개의 댓글