Figure 1 shows that a FW functions as an egress gateway and connect PCs in an intranet to the Internet. The network plan is as follows:
The configuration roadmap is as follows:
After the FW obtains an IPv4 address from a DHCP server, the DHCP server issues a default route to the FW that function as a DHCP client. The next hop of the default route is a carrier's device. Therefore, there is no need to configure a default route.
To configure a specific route, you can configure a static route and specify GigabitEthernet 0/0/1 (a DHCP client has been configured on the interface) as the outbound interface. You do not need to specify the next-hop address. The device uses the gateway address obtained by the outbound interface from the DHCP server as the next-hop address. You can run the display dataplane-fib command to view the next-hop address in the routing table.
<FW> system-view [FW] interface GigabitEthernet 0/0/3 [FW-GigabitEthernet0/0/3] ip address 10.3.0.1 24 [FW-GigabitEthernet0/0/3] quit [FW] firewall zone trust [FW-zone-trust] add interface GigabitEthernet 0/0/3 [FW] firewall zone untrust [FW-zone-untrust] add interface GigabitEthernet 0/0/1 [FW-zone-untrust] quit
[FW] dns proxy enable [FW] dns resolve [FW] dns server unnumbered interface GigabitEthernet 0/0/1
[FW] interface GigabitEthernet 0/0/1 [FW-GigabitEthernet0/0/1] ip address dhcp-alloc [FW-GigabitEthernet0/0/1] quit
[FW] security-policy [FW-policy-security] rule name policy_sec_1 [FW-policy-security-rule-policy_sec_1] source-zone trust [FW-policy-security-rule-policy_sec_1] source-address 10.3.0.0 24 [FW-policy-security-rule-policy_sec_1] action permit [FW-policy-security-rule-policy_sec_1] quit [FW-policy-security] quit
[FW] nat-policy [FW-policy-nat] rule name policy_nat_1 [FW-policy-nat-rule-policy_nat_1] source-zone trust [FW-policy-nat-rule-policy_nat_1] destination-zone untrust [FW-policy-nat-rule-policy_nat_1] egress-interface GigabitEthernet 0/0/1 [FW-policy-nat-rule-policy_nat_1] source-address 10.3.0.0 24 [FW-policy-nat-rule-policy_nat_1] action source-nat easy-ip
Check the status of GigabitEthernet 0/0/1 (uplink).
Verify that the physical status and IPv4 status of GigabitEthernet 0/0/1 are Up, the connection type is DHCP, and the interface obtained an IPv4 address.
# dns resolve dns server unnumbered interface GigabitEthernet0/0/1 # dns proxy enable # interface GigabitEthernet0/0/1 ip address dhcp-alloc # interface GigabitEthernet0/0/3 ip address 10.3.0.1 255.255.255.0 # firewall zone trust set priority 85 add interface GigabitEthernet0/0/3 # firewall zone untrust set priority 5 add interface GigabitEthernet0/0/1 # security-policy rule name policy_sec_1 source-zone trust source-address 10.3.0.0 mask 255.255.255.0 action permit # nat-policy rule name policy_nat_1 source-zone trust destination-zone untrust egress-interface GigabitEthernet0/0/1 source-address 10.3.0.0 mask 255.255.255.0 action source-nat easy-ip # return