酷!學園

技術討論區 => Linux 討論版 => 主題作者是: bottle770209 於 2019-03-14 18:52

主題: [求解]新手請問 iptable問題
作者: bottle7702092019-03-14 18:52
各位大大

小弟新手剛接觸linux
目前需要模擬一個環境,是linux有兩張網卡,eno1端有一個設備,需要向在enp2s0端的dhcp server要IP
但不知道該如何將eno1端所收到的dhcp discover封包再往enp2s0端發送

不知有無大大可以教導小弟如何設置

這是我的網卡資訊:
# ifconfig
eno1: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST>  mtu 1500
        inet6 fe80::62a4:4cff:fee7:a8b5  prefixlen 64  scopeid 0x20<link>
        ether 60:a4:4c:e7:a8:b5  txqueuelen 1000  (Ethernet)
        RX packets 320841812  bytes 36849838963 (34.3 GiB)
        RX errors 23  dropped 0  overruns 0  frame 18
        TX packets 16856562  bytes 2817973018 (2.6 GiB)
        TX errors 140  dropped 0 overruns 0  carrier 140  collisions 434256
        device interrupt 20  memory 0xf7d00000-f7d20000 

eno1.5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.151.96.2  netmask 255.255.255.0  broadcast 10.151.96.255
        inet6 fe80::62a4:4cff:fee7:a8b5  prefixlen 64  scopeid 0x20<link>
        ether 60:a4:4c:e7:a8:b5  txqueuelen 1000  (Ethernet)
        RX packets 1890  bytes 1295219 (1.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3666  bytes 399405 (390.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp2s0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST>  mtu 1500
        inet6 fe80::213:46ff:fe6d:b104  prefixlen 64  scopeid 0x20<link>
        ether 00:13:46:6d:b1:04  txqueuelen 1000  (Ethernet)
        RX packets 3873054  bytes 2002657930 (1.8 GiB)
        RX errors 0  dropped 0  overruns 0  frame 1
        TX packets 4084227  bytes 1887839044 (1.7 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp2s0.5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.68.100  netmask 255.255.255.0  broadcast 192.168.168.255
        inet6 fe80::213:46ff:fe6d:b104  prefixlen 64  scopeid 0x20<link>
        ether 00:13:46:6d:b1:04  txqueuelen 1000  (Ethernet)
        RX packets 4346  bytes 535048 (522.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1205  bytes 109461 (106.8 KiB)
        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 1  (Local Loopback)
        RX packets 6781070  bytes 423385774 (403.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6781070  bytes 423385774 (403.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


這是目前所設置的iptables:
# iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            udp spts:67:68
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            udp dpts:67:68   

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination       


大概架構:
DHCP SERVER <----192.168.68.x/24 vlan5--->(enp2s0) Linux 主機 (eno1) <---10.151.96.x/24 vlan5--->設備

主題: Re: [求解]新手請問 iptable問題
作者: netman2019-03-15 15:49
不知道 dhcp relay 有沒有設好?