ubuntu 开启ip转发的方法

ubuntu 开启网关转发

修改文件 /etc/sysctl.conf

cat /etc/sysctl.conf

  1. 找到 net.ipv4.ip_forward=1 这一行,取消注释既可
nano /etc/sysctl.conf
##############################################################3
# Functions previously found in netbase
#

# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks
#net.ipv4.conf.default.rp_filter=1
#net.ipv4.conf.all.rp_filter=1

# Uncomment the next line to enable TCP/IP SYN cookies
# See http://lwn.net/Articles/277146/
# Note: This may impact IPv6 TCP sessions too
#net.ipv4.tcp_syncookies=1

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

# Uncomment the next line to enable packet forwarding for IPv6
#  Enabling this option disables Stateless Address Autoconfiguration
#  based on Router Advertisements for this host
#net.ipv6.conf.all.forwarding=1


###################################################################

  1. 保存生效
$ sysctl -p
上一篇:ansible之获取主机IP地址


下一篇:Go 学习笔记(79)— Go 标准库 net(获取本机IP地址)