Domain-Name-System

CentOS 作為路由器 - 無法獲取內部區域的靜態 IP 地址

  • March 16, 2015

我正在嘗試用 CentOS 7 盒子製作路由器。

enp2s2f0 —> 外部區域 —> 直接連接到網際網路。enp2s2f1 —> 內部區域 —> 連接到 PC(將來會連接到交換機)

查看我的實際 ifconfig 結果:

[root@localhost ~]# ifconfig
enp2s2f0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet 192.168.1.1  netmask 255.255.255.0  broadcast 192.168.1.255
       inet6 fe80::216:35ff:fe5c:913a  prefixlen 64  scopeid 0x20<link>
       inet6 2a01:e35:2e02:90f0:216:35ff:fe5c:913a  prefixlen 64  scopeid 0x0<global>
       ether 00:16:35:5c:91:3a  txqueuelen 1000  (Ethernet)
       RX packets 255  bytes 25694 (25.0 KiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 191  bytes 25734 (25.1 KiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
       device interrupt 25  

enp2s2f1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet6 fe80::216:35ff:fe5c:9139  prefixlen 64  scopeid 0x20<link>
       ether 00:16:35:5c:91:39  txqueuelen 1000  (Ethernet)
       RX packets 54  bytes 5486 (5.3 KiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 10  bytes 1644 (1.6 KiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
       device interrupt 26  

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

我的介面配置文件:

enp2s2f0

HWADDR="00:16:35:5C:91:3A"
TYPE="Ethernet"
BOOTPROTO="dhcp"
ONBOOT="yes"
ZONE="external"

enp2s2f1

HWADDR="00:16:35:5C:91:39"
TYPE="Bridge"
BOOTPROTO="static"
ONBOOT="yes"
IPADDR="10.100.0.1"
NETMASK="255.255.255.0"
NM_CONTROLLED="no"

DHCPD 配置文件:

ddns-update-style interim;

allow booting;
allow bootp;
authoritative;

ignore client-updates;
set vendorclass = option vendor-class-identifier;


subnet 10.100.0.0 netmask 255.255.255.0 {
     interface                         enp2s2f1;
     range                             10.100.0.10 10.100.0.200;
     default-lease-time                21600;
     max-lease-time                    43200;
     option subnet-mask                255.255.255.0;
     option broadcast-address          10.100.0.255;
     option routers                    10.100.0.1;
     option domain-name-servers        8.8.8.8;
     next-server                       10.100.0.1;
}

防火牆規則:

[root@localhost dhcp]# firewall-cmd --list-all
internal (default, active)
 interfaces: enp2s2f1
 sources: 
 services: dhcpv6-client dns http https ipp-client mdns samba-client ssh
 ports: 
 masquerade: no
 forward-ports: 
 icmp-blocks: 
 rich rules:

當然,IPv4 轉發是啟用的。

我的問題是,如果你查看 ifconfig 的結果,enp2s2f1 沒有得到他的靜態 IP,通常是 10.100.0.1

我刪除了 NetworkManager。

內部 PC 獲得 IP,但我無法 ping 路由器也無法訪問網際網路。

有任何想法嗎 ???

謝謝

對於 enp2s2f1,更改:

TYPE="Bridge"

到:

TYPE="Ethernet"

除非您希望 enp2s2f1 成為橋樑的一部分。如果是這樣,請遵循RHEL 7 說明

引用自:https://serverfault.com/questions/675783