A
A
AliasNameless2019-07-10 10:04:59
bash
AliasNameless, 2019-07-10 10:04:59

How to change iptables rule?

Colleagues, please help me change the rule
SNAT all -- 10.8.0.0/24 !10.8.0.0/24 to:XXXX
to
SNAT all -- 10.8.0.0/24 !10.8.0.0/24 to:YYYY

#  iptables --table nat --list
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
SNAT       all  --  10.8.0.0/24         !10.8.0.0/24          to:X.X.X.X
MASQUERADE  all  --  192.168.2.0/24       anywhere

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2019-07-10
@q2digger

iptables -t nat -D POSTROUTING 1
iptables -t nat -I POSTROUTING -p all -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to-source Y.Y.Y.Y

P
polar_yogi, 2019-07-10
@polar_yogi

iptables-save -f rules.v4
vi rules.v4
iptables-restore rules.v4

man iptables-save/restore won't hurt.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question