2021-12-03

Linux - forwarding IP traffic while masquerading the source IP address

# the script arguments are:

# $1 is "I" for insert the masquerade in the table before all other iptables enteries

# $2 is the source IP address to be masqueraded be it a specific address "10.11.11.3" or "10.11.11.0/24"

# this is particularly useful for openvpn connections

/usr/sbin/sysctl -w net.ipv4.ip_forward=1

/usr/sbin/sysctl -w net.ipv6.conf.all.forwarding=1

iptables --table nat -$1 POSTROUTING -s $2 -j MASQUERADE

No comments:

Post a Comment

Script to see network interface connection speed

cat network-speed #!/usr/bin/bash # ethtool enp2s0 | grep Speed ethtool $1 | grep Speed # mii-tool -v enp2s0 mii-tool -v $1   network-speed ...