一臺centos7的系統,有2個網卡,一個鏈接外網網段10.8.20.0/24,一個鏈接內網網段172.168.10.0/24,其ip爲:172.168.10.1,局域網中的其餘機器只能鏈接172.168.10.0/24網段,例如其中一臺的IP爲:172.168.1.100,如今要使局域網中的其餘機器能連上外網,能夠在這臺centos7的系統上作以下操做實現:centos
開啓NAT轉發 服務器
# firewall-cmd --permanent --zone=public --add-masqueradetcp
開放DNS使用的53端口,不然可能致使內網服務器雖然設置正確的DNS,可是依然沒法進行域名解析。ide
# firewall-cmd --zone=public --add-port=53/tcp --permanentcentos7
重啓防火牆spa
# systemctl restart firewalld.servicerest
這樣,在局域網的其餘機器上,設置其IP爲172.168.10.0/24網段,默認網關爲172.168.10.1,便可鏈接外網
ip