최소 설치 CentOS6.6 네트워크 구성(업데이트됨)

최소 설치 CentOS6.6 네트워크 구성(업데이트됨)

내 질문을 업데이트합니다.

Stack Overflow에도 같은 질문을 했는데 여기에 질문하는 것이 더 좋습니다.

최소 운영 체제를 설치한 후 워크스테이션 네트워크를 구성하는 데 문제가 있습니다. vi /etc/sysconfig/network-scripts/ifcfg-em1정적이도록 편집했습니다 . 인터넷 검색을 통해 웹 서비스를 계속해서 다시 시작했습니다. 하지만 여전히 인터넷이나 핑에 연결할 수 없습니다( 제외 ping 127.0.0.1). 이것이 내 구성입니다.

[root@workstation ~]# uname -a
Linux workstation.XXXXX 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

[root@workstation ~]# ifconfig
em1       Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
          inet addr:aaa.bbb.ccc.xxx  Bcast:aaa.bbb.211.255  Mask:255.255.252.0
          inet6 addr: XXXX::XXXX:XXX:XXXX:XXXX/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12465754 errors:0 dropped:0 overruns:0 frame:0
          TX packets:238 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1507354446 (1.4 GiB)  TX bytes:35268 (34.4 KiB)
          Interrupt:16

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1316 (1.2 KiB)  TX bytes:1316 (1.2 KiB)

[root@workstation ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    inet aaa.bbb.ccc.xxx/22 brd aaa.bbb.211.255 scope global em1
    inet6 XXXX::XXXX:XXXX:XXXX:XXXX/64 scope link
       valid_lft forever preferred_lft forever
3: em2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff

[root@workstation ~]# vi /etc/sysconfig/network-scripts/ifcfg-em1
DEVICE=em1
HWADDR=54:9F:35:1F:58:D0
TYPE=Ethernet
UUID=7337edf4-f9f0-4dab-9d3d-6f031e7180cc
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=aaa.bbb.ccc.132
NETMASK=255.255.252.0
NAME="System em1"
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
PREFIX=22
GATEWAY=aaa.bbb.156.5
DNS1=aaa.bbb.10.2
DOMAIN=168.126.63.1

[root@workstation ~]# service network restart
Shutting down interface em1:                               [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface em1:  Determining if ip address aaa.bbb.208.132 is already in use for device em1...
                                                           [  OK  ]
[root@workstation ~]# yum list
Loaded plugins: fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os&infra=stock error was
14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"
Error: Cannot find a valid baseurl for repo: base

[root@workstation ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=workstation.XXXXX
GATEWAY=aaa.bbb.156.5

답변해 주셔서 감사합니다. 예 @larsks em1은 DHCP가 아닌 고정 IP입니다. ip 경로입니다

[root@workstation ~]# ip route
aaa.bbb.ccc.0/22 dev em1  proto kernel  scope link  src aaa.bbb.ccc.xxx
169.254.0.0/16 dev em1  scope link  metric 1002

이것은vi /etc/resolv.conf

[root@workstation ~]# vi /etc/resolv.conf
nameserver aaa.bbb.10.2
search 168.126.63.1

변경했는데 NETWORK여전히 GATEWAY인터넷에 연결할 수 없습니다.

또한, 도와주셔서 정말 감사드립니다. 나는 우리가 해결책에 가깝다고 생각합니다.

답변1

마침내 문제를 해결했습니다.

[root@workstation network-scripts]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
aaa.bbb.ccc.0   0.0.0.0         255.255.252.0   U     0      0        0 em1
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 em1

"기본 게이트웨이"가 없습니다.

[root@workstation network-scripts]# ip route add 155.230.156.5 dev em1
[root@workstation network-scripts]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
aaa.bbb.156.5   0.0.0.0         255.255.255.255 UH    0      0        0 em1
aaa.bbb.ccc.0   0.0.0.0         255.255.252.0   U     0      0        0 em1
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 em1

다음,

[root@workstation network-scripts]# route add default gw 155.230.156.5 dev em1
[root@workstation network-scripts]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
aaa.bbb.156.5   0.0.0.0         255.255.255.255 UH    0      0        0 em1
aaa.bbb.ccc.0   0.0.0.0         255.255.252.0   U     0      0        0 em1
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 em1
0.0.0.0         aaa.bbb.156.5   0.0.0.0         UG    0      0        0 em1 ← "default GATEWAY"

연결을 확인하고,

[root@workstation network-scripts]# ping www.google.co.kr
PING www.google.co.kr (216.58.199.99) 56(84) bytes of data.
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=1 ttl=50 time=82.8 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=2 ttl=50 time=47.2 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=3 ttl=50 time=46.9 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=4 ttl=50 time=47.0 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=5 ttl=50 time=57.3 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=6 ttl=50 time=47.0 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=7 ttl=50 time=47.6 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=8 ttl=50 time=47.6 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=9 ttl=50 time=46.9 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=10 ttl=50 time=47.0 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=11 ttl=50 time=47.5 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=12 ttl=50 time=47.0 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=13 ttl=50 time=47.5 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=14 ttl=50 time=57.8 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=15 ttl=50 time=47.5 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=16 ttl=50 time=47.4 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=17 ttl=50 time=53.0 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=18 ttl=50 time=47.6 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=19 ttl=50 time=47.5 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=20 ttl=50 time=47.5 ms
64 bytes from hkg07s22-in-f3.1e100.net (216.58.199.99): icmp_seq=21 ttl=50 time=47.0 ms
^C
--- www.google.co.kr ping statistics ---
21 packets transmitted, 21 received, 0% packet loss, time 20694ms
rtt min/avg/max/mdev = 46.961/50.269/82.824/7.940 ms

하지만 내가 reboot또는 . service network restart이제 영구적으로 저장하는 방법을 알고 싶습니다.

저는 Linux 네트워킹에 대해 어느 정도 지식을 갖고 있습니다. 도와주셔서 다시 한번 감사드립니다.

관련 정보