These aren’t as polished as my other notes, as they’re mostly meant to serve as notes for repeatable processes I’ve had to do in the past :)
1:1 NAT
192.168.55.15 on the external subnet, it could also have 192.168.55.16 as an IP address on the same NIC
192.168.55.16 would be forwarded to an internal IP, such as 172.16.10.11iptables rule such as -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT will allow inbound, stateful traffic to reach internal machines
NEW to --ctstate
-A POSTROUTING -s 172.16.1.0/24 -j MASQUERADEnet.ipv4.ip_forward kernel runtime param is set to 1
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.d/99-forwarding.conf and reload with sysctl --systemecho 1 > /proc/sys/net/ipv4/ip_forward.16 to the target: -A PREROUTING -d 192.168.55.16/32 -j DNAT --to-destination 172.16.1.11.16: -A POSTROUTING -s 172.16.1.11/32 -j SNAT --to-source 192.168.55.16172.16.10.11) and a default route to the router
/etc/network/interfaces with gateway 172.16.1.10 or manually with something like ip route add default via 172.16.1.10 dev {nic}Ensuring the settings persist
iptables rules, we can use something like iptables-save
apt install iptables-persistent && iptables-save > /etc/iptables/rules.v4/etc/network/interfacesauto ens37
iface ens37 inet static
address 192.168.55.15
netmask 255.255.255.0
network 192.168.55.0
broadcast 192.168.55.255
address line under our first network, we need a second one with :0 to indicate it’s another IP address on the same NICauto ens37:0
iface ens37:0 inet static
address 192.168.55.16
netmask 255.255.255.0
Setup
Issues
Iptables
iptables --list-rulesiptables -A {INPUT/OUTPUT/FORWARD} -p {tcp/udp} --dport {port} -j {ACCEPT/DROP/LOG}
-t {table_like_NAT}-s {IP} to pass an IP (range) for allowing/denying-A with -D and keep the rest of the rule the sameiptables -F INPUT/OUTPUT/FORWARDufw
ufw {enable/disable}ufw status {rule_num}ufw allow 22/tcpufw allow from {IP}
to any port 22ufw default deny outgoingfirewalld is similar and present on RHELnftables
/etc/nftables.confnft list ruleset to list rules, flush with nft flush rulesetnft add rule inet filter input tcp dport 80nft add rule inet filter input ip saddr {IP} dropnft delete rule inet filter input handle {rule_number}Windows
New-NetFirewallRule -DisplayName "{name}" -Direction Inbound -LocalPort {port} -Protocol TCP -Action AllowConnecting to LAN over USB
sudo ifconfig <IFACE> alias 10.0.0.<desired_IP> netmask 255.255.0.0