CentOS7에서 Configuration 파일 내용을 수정하여 고정 IP 설정하는 방법

 

현재 IP주소 확인

[root@localhost ~]# ifconfig

eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.45.128  netmask 255.255.255.0  broadcast 192.168.45.255

        inet6 fe80::20c:29ff:feb1:9ef1  prefixlen 64  scopeid 0x20<link>

        ether 00:0c:29:b1:9e:f1  txqueuelen 1000  (Ethernet)

        RX packets 815582  bytes 1221337871 (1.1 GiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 126557  bytes 7832725 (7.4 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 0  (Local Loopback)

        RX packets 4  bytes 340 (340.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 4  bytes 340 (340.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500

        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255

        ether 52:54:00:39:f8:cf  txqueuelen 0  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

Configuration 파일 수정

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno16777736

TYPE=Ethernet

# Change BOOTPROTO dhcp to static

# BOOTPROTO=dhcp

BOOTPROTO=static

DEFROUTE=yes

# Set IPv4 address

IPADDR=192.168.45.3

# Set IPv4 Netmask

NETMASK=255.255.255.0

# Set IPv4 Gateway address

GATEWAY=192.168.45.2

# Set IPv4 DNS address

DNS1=192.168.45.2

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_FAILURE_FATAL=no

NAME=eno16777736

UUID=17f6c4a3-91df-415f-8df3-7c7f2ef899ce

DEVICE=eno16777736

ONBOOT=yes

PEERDNS=yes

PEERROUTES=yes

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes


네트워크
서비스 재시작

[root@localhost network-scripts]# systemctl restart network

 

변경된 IP주소 확인

[root@localhost network-scripts]# ifconfig

eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.45.3  netmask 255.255.255.0  broadcast 192.168.45.255

        inet6 fe80::20c:29ff:feb1:9ef1  prefixlen 64  scopeid 0x20<link>

        ether 00:0c:29:b1:9e:f1  txqueuelen 1000  (Ethernet)

        RX packets 815675  bytes 1221347556 (1.1 GiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 126630  bytes 7840405 (7.4 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 0  (Local Loopback)

        RX packets 16  bytes 1368 (1.3 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 16  bytes 1368 (1.3 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500

        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255

        ether 52:54:00:39:f8:cf  txqueuelen 0  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

+ Recent posts